Skip to content

Commit 418d78a

Browse files
authored
Merge pull request #110 from dihm/get_shot_globals_deprecation
Get shot globals deprecation
2 parents 8151a19 + f003258 commit 418d78a

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

readthedocs.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ python:
2323
path: .
2424
extra_requirements:
2525
- docs
26-
system_packages: true
2726

runmanager/__init__.py

+12-18
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.shot_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+
FutureWarning("get_shot_globals 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

+1-1
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)