def generate_local_run(dbpath: Path) -> str: with initialised_database_at(str(dbpath)): new_experiment(sample_name="fivehundredtest_sample", name="fivehundredtest_name") p1 = Parameter('Voltage', set_cmd=None) p2 = Parameter('Current', get_cmd=np.random.randn) meas = Measurement() meas.register_parameter(p1).register_parameter(p2, setpoints=[p1]) with meas.run() as datasaver: for v in np.linspace(0, 2, 250): p1(v) datasaver.add_result((p1, cast(float, p1())), (p2, cast(float, p2()))) guid = datasaver.dataset.guid datasaver.flush_data_to_database(block=True) return guid
def generate_local_exp(dbpath: Path) -> List[str]: with initialised_database_at(str(dbpath)): guids = [] exp = load_or_create_experiment(experiment_name="test_guid") p1 = Parameter('Voltage', set_cmd=None) p2 = Parameter('Current', get_cmd=np.random.randn) meas = Measurement(exp=exp) meas.register_parameter(p1).register_parameter(p2, setpoints=[p1]) # Meaure for 2 times to get 2 run ids and 2 guids for run in range(2): with meas.run() as datasaver: for v in np.linspace(0 * run, 2 * run, 50): p1(v) datasaver.add_result((p1, cast(float, p1())), (p2, cast(float, p2()))) guid = datasaver.dataset.guid guids.append(guid) return guids