Skip to content

Commit 601852c

Browse files
authored
Cache units to avoid consistent calls to describe (#10)
* Cache units to avoid consistent calls to describe This was the most common method that caused Waldo to fail, and there is no need to contact the daemon/device more than once, so avoid recalculating units * Prep for release
1 parent 33707b7 commit 601852c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
55

66
## [Unreleased]
77

8+
## [2022.4.0]
9+
10+
### Changed
11+
- Cached units using lru cache to avoid consistant calls to describe
12+
813
## [2021.9.0]
914

1015
### Added
1116
- initial release
1217

1318

14-
[Unreleased]: https://github.com/wright-group/wright-plans/compare/v2021.9.0...HEAD
19+
[Unreleased]: https://github.com/wright-group/wright-plans/compare/v2022.4.0...HEAD
20+
[2022.4.0]: https://github.com/wright-group/wright-plans/compare/v2021.9.0...v2022.4.0
1521
[2021.9.0]: https://github.com/wright-group/wright-plans/releases/tag/v2021.9.0

wright_plans/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Bluesky plans and utilities to provide functionality that the Wright Group needs."""
22

3-
__version__ = "2021.9.0"
3+
__version__ = "2022.4.0"
44

55
from ._plans import *
66
from ._constants import *

wright_plans/_units.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
__all__ = ["ureg", "get_units"]
22

3+
from functools import lru_cache
4+
35
import pint
46

57
ureg = pint.UnitRegistry()
@@ -21,6 +23,7 @@
2123

2224

2325
# TODO make sure unit retrival is accurate, robust
26+
@lru_cache
2427
def get_units(device, default=None):
2528
if device is None:
2629
return default

0 commit comments

Comments
 (0)