Skip to content

Commit bde3a73

Browse files
committed
Add deprecation warning to get_shot_globals to notify users to import
from new location.
1 parent 1160ef8 commit bde3a73

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

runmanager/__init__.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
import json
2626
import tokenize
2727
import io
28+
import warnings
2829

2930
import labscript_utils.h5_lock
3031
import h5py
3132
import numpy as np
3233

3334
from labscript_utils.ls_zprocess import ProcessTree, zmq_push_multipart
3435
from labscript_utils.labconfig import LabConfig
36+
import labscript_utils
3537
process_tree = ProcessTree.instance()
3638

3739
from .__version__ import __version__
@@ -915,24 +917,16 @@ def compile_labscript_with_globals_files_async(labscript_file, globals_files, ou
915917
def get_shot_globals(filepath):
916918
"""Returns the evaluated globals for a shot, for use by labscript or lyse.
917919
Simple dictionary access as in dict(h5py.File(filepath).attrs) would be fine
918-
except we want to apply some hacks, so it's best to do that in one place."""
919-
params = {}
920-
with h5py.File(filepath, 'r') as f:
921-
for name, value in f['globals'].attrs.items():
922-
# Convert numpy bools to normal bools:
923-
if isinstance(value, np.bool_):
924-
value = bool(value)
925-
# Convert null HDF references to None:
926-
if isinstance(value, h5py.Reference) and not value:
927-
value = None
928-
# Convert numpy strings to Python ones.
929-
# DEPRECATED, for backward compat with old files.
930-
if isinstance(value, np.str_):
931-
value = str(value)
932-
if isinstance(value, bytes):
933-
value = value.decode()
934-
params[name] = value
935-
return params
920+
except we want to apply some hacks, so it's best to do that in one place.
921+
922+
Deprecated: use identical function `labscript_utils.shot_utils.get_shot_globals`
923+
"""
924+
925+
warnings.warn(
926+
DeprecationWarning("This function has moved to labscript_utils.shot_utils. "
927+
"Please update your code to import it from there."))
928+
929+
return labscript_utils.shot_utils.get_shot_globals(filepath)
936930

937931

938932
def dict_diff(dict1, dict2):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ install_requires =
3131
desktop-app>=0.1.2
3232
importlib_metadata
3333
labscript>=3.0.0
34-
labscript_utils>=3.0.0
34+
labscript_utils>=3.3.0
3535
pandas>=0.13
3636
qtutils>=2.2.2
3737
matplotlib

0 commit comments

Comments
 (0)