Hi Chris,
Your latest commit seems to have worked!
Using test.py:
from lyse import *
ser = data(path)
print(ser)
With lyse (the GUI) running, I'm able to run test.py in Spyder and it pulls up the expected information from the shot .h5 file loaded in lyse.
In Jupyter (with the lyse GUI still running), I'm able to import lyse (the module) without issue but it errors out at "ser = data(path)" with (I'll put the traceback below):
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '-f', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
It seems like it can't find the file path so providing an explicit path to the shot .h5 file seems to get around this issue.
Anyways, thanks again for all your time and help Chris!
Roger Ding
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Input In [22], in <cell line: 2>()
1 from lyse import *
----> 2 ser = data(path)
3 #ser = data(p)
4 print(ser)
File ~\anaconda3\envs\py38\lib\site-packages\lyse\__init__.py:147, in data(filepath, host, port, timeout, n_sequences, filter_kwargs)
82 """Get data from the lyse dataframe or a file.
83
84 This function allows for either extracting information from a run's hdf5
(...)
144 the lyse dataframe, or a subset of it, is returned.
145 """
146 if filepath is not None:
--> 147 return _get_singleshot(filepath)
148 else:
149 if n_sequences is not None:
File ~\anaconda3\envs\py38\lib\site-packages\lyse\dataframe_utilities.py:124, in get_series_from_shot(filepath)
123 def get_series_from_shot(filepath):
--> 124 nested_dict = get_nested_dict_from_shot(filepath)
125 flat_dict = flatten_dict(nested_dict)
126 s = flat_dict_to_flat_series(flat_dict)
File ~\anaconda3\envs\py38\lib\site-packages\lyse\dataframe_utilities.py:29, in get_nested_dict_from_shot(filepath)
28 def get_nested_dict_from_shot(filepath):
---> 29 row = runmanager.get_shot_globals(filepath)
30 with h5py.File(filepath,'r') as h5_file:
31 if 'results' in h5_file:
File ~\anaconda3\envs\py38\lib\site-packages\runmanager\__init__.py:920, in get_shot_globals(filepath)
916 """Returns the evaluated globals for a shot, for use by labscript or lyse.
917 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_):
File ~\anaconda3\envs\py38\lib\site-packages\labscript_utils\h5_lock.py:53, in File.__init__(self, name, mode, driver, libver, **kwds)
51 self.zlock.acquire()
52 try:
---> 53 _File.__init__(self, name, mode, driver, libver, **kwds)
54 except:
55 if hasattr(self, 'zlock'):
File ~\anaconda3\envs\py38\lib\site-packages\h5py\_hl\files.py:507, in File.__init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, **kwds)
502 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,
503 locking, page_buf_size, min_meta_keep, min_raw_keep, **kwds)
504 fcpl = make_fcpl(track_order=track_order, fs_strategy=fs_strategy,
505 fs_persist=fs_persist, fs_threshold=fs_threshold,
506 fs_page_size=fs_page_size)
--> 507 fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
509 if isinstance(libver, tuple):
510 self._libver = libver
File ~\anaconda3\envs\py38\lib\site-packages\h5py\_hl\files.py:220, in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
218 if swmr and swmr_support:
219 flags |= h5f.ACC_SWMR_READ
--> 220 fid = h5f.open(name, flags, fapl=fapl)
221 elif mode == 'r+':
222 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
File h5py\_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py\_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File h5py\h5f.pyx:106, in h5py.h5f.open()
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '-f', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)