Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_dataset_from(path: str, run_id: int) -> 'DataSet':
"""
Loads ``DataSet`` with the given ``run_id`` from a database file that
is located in in the given ``path``.
Note that after the call to this function, the database location in the
qcodes config of the current python process is changed to ``path``.
"""
initialise_or_create_database_at(path)
return load_by_id(run_id=run_id)
def get_runs_from_db(path: str, start: int = 0,
stop: Union[None, int] = None,
get_structure: bool = False):
"""
Get a db ``overview`` dictionary from the db located in ``path``. The
``overview`` dictionary maps ``DataSet.run_id``s to dataset information as
returned by ``get_ds_info`` functions.
`start` and `stop` refer to indices of the runs in the db that we want
to have details on; if `stop` is None, we'll use runs until the end.
If `get_structure` is True, include info on the run data structure
in the return dict.
"""
initialise_or_create_database_at(path)
datasets = sorted(
chain.from_iterable(exp.data_sets() for exp in experiments()),
key=attrgetter('run_id')
)
# There is no need for checking whether ``stop`` is ``None`` because if
# it is the following is simply equivalent to ``datasets[start:]``
datasets = datasets[start:stop]
overview = {ds.run_id: get_ds_info(ds, get_structure=get_structure)
for ds in datasets}
return overview
def load_dataset_from(path: str, run_id: int) -> 'DataSet':
"""
Loads ``DataSet`` with the given ``run_id`` from a database file that
is located in in the given ``path``.
Note that after the call to this function, the database location in the
qcodes config of the current python process is changed to ``path``.
"""
initialise_or_create_database_at(path)
return load_by_id(run_id=run_id)
def get_runs_from_db(path: str, start: int = 0,
stop: Union[None, int] = None,
get_structure: bool = False):
"""
Get a db ``overview`` dictionary from the db located in ``path``. The
``overview`` dictionary maps ``DataSet.run_id``s to dataset information as
returned by ``get_ds_info`` functions.
`start` and `stop` refer to indices of the runs in the db that we want
to have details on; if `stop` is None, we'll use runs until the end.
If `get_structure` is True, include info on the run data structure
in the return dict.
"""
initialise_or_create_database_at(path)
datasets = sorted(
chain.from_iterable(exp.data_sets() for exp in experiments()),
key=attrgetter('run_id')
)
# There is no need for checking whether ``stop`` is ``None`` because if
# it is the following is simply equivalent to ``datasets[start:]``
datasets = datasets[start:stop]
overview = {ds.run_id: get_ds_info(ds, get_structure=get_structure)
for ds in datasets}
return overview