def test_monitor_not_loaded_if_specified(example_station_config): st = Station(config_file=example_station_config, use_monitor=False) st.load_instrument('mock_dac') assert Monitor.running is None
def test_config_validation_comprehensive_config(): Station(config_file=os.path.join( get_qcodes_path(), 'dist', 'tests', 'station', 'example.station.yaml') )
def example_station(example_station_config): return Station(config_file=example_station_config)
def test_monitor_not_loaded_by_default(example_station_config): st = Station(config_file=example_station_config) st.load_instrument('mock_dac') assert Monitor.running is None
def station_from_config_str(config: str) -> Station: st = Station(config_file=None) st.load_config(config) return st
def setUpClass(cls): cls.p1 = ManualParameter('p1', vals=Numbers(-10, 10)) cls.p2 = ManualParameter('p2', vals=Numbers(-10, 10)) cls.p3 = ManualParameter('p3', vals=Numbers(-10, 10)) Station().set_measurement(cls.p2, cls.p3)
def test_load_from_db_dataset_moved(meas_with_registered_param, DMM, DAC, tmp_path): Station(DAC, DMM) with meas_with_registered_param.run( dataset_class=DataSetType.DataSetInMem) as datasaver: for set_v in np.linspace(0, 25, 10): DAC.ch1.set(set_v) get_v = DMM.v1() datasaver.add_result((DAC.ch1, set_v), (DMM.v1, get_v)) ds = datasaver.dataset ds.add_metadata("foo", "bar") ds.export(export_type="netcdf", path=tmp_path) ds.add_metadata("metadata_added_after_export", 69) export_path = ds.export_info.export_paths["nc"] with contextlib.closing(xarray.open_dataset(export_path)) as xr_ds: assert xr_ds.attrs["metadata_added_after_export"] == 69 new_path = str(Path(export_path).parent / "someotherfilename.nc") shutil.move(export_path, new_path) with pytest.warns(UserWarning, match="Could not load raw data for dataset with guid"): loaded_ds = load_by_id(ds.run_id) assert isinstance(loaded_ds, DataSetInMem) assert loaded_ds.snapshot == ds.snapshot assert loaded_ds.export_info == ds.export_info assert loaded_ds.metadata == ds.metadata assert "foo" in loaded_ds.metadata.keys() assert "export_info" in loaded_ds.metadata.keys() assert "metadata_added_after_export" in loaded_ds.metadata.keys() assert loaded_ds.cache.data() == {} with pytest.warns( UserWarning, match="Could not add metadata to the exported NetCDF file"): ds.add_metadata("metadata_added_after_move", 696) with contextlib.closing(xarray.open_dataset(new_path)) as new_xr_ds: assert new_xr_ds.attrs["metadata_added_after_export"] == 69 assert "metadata_added_after_move" not in new_xr_ds.attrs loaded_ds.set_netcdf_location(new_path) assert loaded_ds.cache.data().keys() == ds.cache.data().keys() with contextlib.closing(xarray.open_dataset(new_path)) as new_xr_ds: assert new_xr_ds.attrs["metadata_added_after_export"] == 69 assert "metadata_added_after_move" not in new_xr_ds.attrs # This should have effect neither on the loaded_ds nor on the netcdf file with pytest.warns( UserWarning, match="Could not add metadata to the exported NetCDF file"): ds.add_metadata( "metadata_added_to_old_dataset_after_set_new_netcdf_location", 696977) loaded_ds.add_metadata("metadata_added_after_set_new_netcdf_location", 6969) with contextlib.closing(xarray.open_dataset(new_path)) as new_xr_ds: assert new_xr_ds.attrs["metadata_added_after_export"] == 69 assert "metadata_added_after_move" not in new_xr_ds.attrs assert ("metadata_added_to_old_dataset_after_set_new_netcdf_location" not in new_xr_ds.attrs) assert new_xr_ds.attrs[ "metadata_added_after_set_new_netcdf_location"] == 6969
def test_load_all_instruments_without_config_raises(): station = Station() with pytest.raises(ValueError, match="Station has no config"): station.load_all_instruments()
except Exception: print('pyqtgraph plotting not supported, ' 'try "from qcodes.plots.pyqtgraph import QtPlot" ' 'to see the full error') if plotlib in {'matplotlib', 'all'}: try: from qcodes.plots.qcmatplotlib import MatPlot except Exception: print('matplotlib plotting not supported, ' 'try "from qcodes.plots.qcmatplotlib import MatPlot" ' 'to see the full error') # Initialize singleton station from qcodes.station import Station station = Station() from qcodes.loops import Loop, active_measurement, active_dataset, stop, pause, resume from qcodes.measure import Measure from qcodes.actions import Task, Wait, BreakIf, ContinueIf, SkipIf haswebsockets = True try: import websockets except ImportError: haswebsockets = False if haswebsockets: from qcodes.monitor.monitor import Monitor from qcodes.data.data_set import DataSet, new_data, load_data, set_data_root_folder from qcodes.data.location import FormatLocation from qcodes.data.data_array import DataArray