From 1160ef84baea81579dc887e139da0d023e8314ea Mon Sep 17 00:00:00 2001 From: David Meyer Date: Thu, 12 Oct 2023 15:59:39 -0400 Subject: [PATCH 1/4] Fix RTD build --- readthedocs.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/readthedocs.yaml b/readthedocs.yaml index 35084d6..12f19ff 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -23,5 +23,4 @@ python: path: . extra_requirements: - docs - system_packages: true \ No newline at end of file From bde3a73e37802a1bf64898881233d1b052f4c0d1 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Thu, 12 Oct 2023 16:00:27 -0400 Subject: [PATCH 2/4] Add deprecation warning to `get_shot_globals` to notify users to import from new location. --- runmanager/__init__.py | 30 ++++++++++++------------------ setup.cfg | 2 +- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/runmanager/__init__.py b/runmanager/__init__.py index c2bb430..6696c41 100644 --- a/runmanager/__init__.py +++ b/runmanager/__init__.py @@ -25,6 +25,7 @@ import json import tokenize import io +import warnings import labscript_utils.h5_lock import h5py @@ -32,6 +33,7 @@ from labscript_utils.ls_zprocess import ProcessTree, zmq_push_multipart from labscript_utils.labconfig import LabConfig +import labscript_utils process_tree = ProcessTree.instance() from .__version__ import __version__ @@ -915,24 +917,16 @@ def compile_labscript_with_globals_files_async(labscript_file, globals_files, ou def get_shot_globals(filepath): """Returns the evaluated globals for a shot, for use by labscript or lyse. Simple dictionary access as in dict(h5py.File(filepath).attrs) would be fine - except we want to apply some hacks, so it's best to do that in one place.""" - params = {} - with h5py.File(filepath, 'r') as f: - for name, value in f['globals'].attrs.items(): - # Convert numpy bools to normal bools: - if isinstance(value, np.bool_): - value = bool(value) - # Convert null HDF references to None: - if isinstance(value, h5py.Reference) and not value: - value = None - # Convert numpy strings to Python ones. - # DEPRECATED, for backward compat with old files. - if isinstance(value, np.str_): - value = str(value) - if isinstance(value, bytes): - value = value.decode() - params[name] = value - return params + except we want to apply some hacks, so it's best to do that in one place. + + Deprecated: use identical function `labscript_utils.shot_utils.get_shot_globals` + """ + + warnings.warn( + DeprecationWarning("This function has moved to labscript_utils.shot_utils. " + "Please update your code to import it from there.")) + + return labscript_utils.shot_utils.get_shot_globals(filepath) def dict_diff(dict1, dict2): diff --git a/setup.cfg b/setup.cfg index c25e3e5..56449e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ install_requires = desktop-app>=0.1.2 importlib_metadata labscript>=3.0.0 - labscript_utils>=3.0.0 + labscript_utils>=3.3.0 pandas>=0.13 qtutils>=2.2.2 matplotlib From b2c790b8f43ab9d736257924d8b795daebc4d282 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Thu, 12 Oct 2023 16:09:53 -0400 Subject: [PATCH 3/4] Fix bad import --- runmanager/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runmanager/__init__.py b/runmanager/__init__.py index 6696c41..fa97d2e 100644 --- a/runmanager/__init__.py +++ b/runmanager/__init__.py @@ -33,7 +33,7 @@ from labscript_utils.ls_zprocess import ProcessTree, zmq_push_multipart from labscript_utils.labconfig import LabConfig -import labscript_utils +import labscript_utils.shot_utils process_tree = ProcessTree.instance() from .__version__ import __version__ From f00325858ef3a1aed032e6420ffa7d004e62372e Mon Sep 17 00:00:00 2001 From: David Meyer Date: Thu, 12 Oct 2023 16:13:48 -0400 Subject: [PATCH 4/4] Use proper Warning class so it raises normally. --- runmanager/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runmanager/__init__.py b/runmanager/__init__.py index fa97d2e..bb81b81 100644 --- a/runmanager/__init__.py +++ b/runmanager/__init__.py @@ -923,8 +923,8 @@ def get_shot_globals(filepath): """ warnings.warn( - DeprecationWarning("This function has moved to labscript_utils.shot_utils. " - "Please update your code to import it from there.")) + FutureWarning("get_shot_globals has moved to labscript_utils.shot_utils. " + "Please update your code to import it from there.")) return labscript_utils.shot_utils.get_shot_globals(filepath)