Update scripts/runmanager_remote.py

Complete commenting of the code, removed the manual time.sleep, now it relies on waiting for lyse to respond to each shot termination
This commit is contained in:
castaneda 2025-03-21 15:16:55 +01:00
parent 59741c971b
commit 49bc1ec08a

View File

@ -1,62 +1,62 @@
from labscript.labscript import labscript_init
from runmanager import remote
from datetime import datetime
import time
#from lyse import Run as lyse_run
#from lyse import data as lyse_data
from os import listdir
#from labscript_utils import import_or_reload
def run_experiment(routine_name, global_var):
#import_or_reload('labscriptlib.NNDy_TestSetup.connection_table')
hdf_path = f"C:\\Users\\DyLab\\PrepLab\\Experiments\\NNDy_TestSetup\\{routine_name}"
#this way it should be loading the routine based on past executions, with the possibility of only changing the global variables
#it's possible that there could be some issue if the script is changed before running MLOOP
#without further insights on this, it's recommended to always run the sequence from runmanager GUI before initiating MLOOP
labscript_init(hdf_path,
new = True)
runmanager_client = remote.Client()
runmanager_client.set_view_shots(False)
runmanager_client.set_globals(global_var)
print(f'globals: \n {runmanager_client.get_globals()}')
#print(f'number of shots: \n {runmanager_client.n_shots()}')
hdf_path = runmanager_client.get_shot_output_folder()
runmanager_client.engage()
#print('engaged')
#change measurement_time accordingly
# necessary becasuse engage() doesn't block execution
measurement_time = global_var['T_wlm'] + global_var['wait_AWG'] + global_var['buffer_time']
print(f'now waiting for {measurement_time} s')
time.sleep(measurement_time)
print('waiting time is over')
try:
hdf_files = listdir(hdf_path)
if len(hdf_files) == 0:
raise ModuleNotFoundError
else:
if len(hdf_files) > 1:
raise ImportError
hdf_file = hdf_path + "/" + hdf_files[0]
except (ModuleNotFoundError, ImportError) as e:
raise Error(f'An error has occured while importing from hdf output folder: {e}')
#run = lyse_run(hdf_file, no_write=True)
#print(hdf_file)
return hdf_file
#this file runs the experiment through runmanager
from datetime import datetime
import time
from os import listdir
#import for labscript
from labscript.labscript import labscript_init
from runmanager import remote
def run_experiment(routine_name, global_var):
hdf_path = f"C:\\Users\\DyLab\\PrepLab\\Experiments\\NNDy_TestSetup\\{routine_name}"
#this way it should be loading the routine based on past executions, with the possibility of only changing the global variables
#it's possible that there could be some issue if the script is changed before running MLOOP
#without further insights on this, it's recommended to always run the sequence once from runmanager GUI before running NNDy
labscript_init(hdf_path,
new = True)
runmanager_client = remote.Client()
runmanager_client.set_view_shots(False)
runmanager_client.set_globals(global_var)
#print of all the shot globals
print(f'globals: \n {runmanager_client.get_globals()}')
#set the path to the shot that will be created
hdf_path = runmanager_client.get_shot_output_folder()
print(f'engaged, now waiting')
runmanager_client.engage()
#print('engaged')
#NNDy_ will make sure that the script is put on hold until the shot isn't sent to lyse
#ask Jianshun for further info
print('waiting time is over')
#returns and retrieve the hdf5 file of the shot
try:
hdf_files = listdir(hdf_path)
if len(hdf_files) == 0:
raise ModuleNotFoundError
else:
if len(hdf_files) > 1:
raise ImportError
hdf_file = hdf_path + "/" + hdf_files[0]
except (ModuleNotFoundError, ImportError) as e:
raise Error(f'An error has occured while importing from hdf output folder: {e}')
return hdf_file