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