DatabaseManager
- class qililab.DatabaseManager(filename, database_name)
Bases:
objectDatabase manager for measurements results and metadata
Methods Summary
add_autocal_measurement(experiment_name, ...)Add autocalibration measurement metadata and data path
add_calibration_run(calibration_tree, ...)Add autocalibration metadata.
add_cooldown(cooldown, fridge[, date])Add cooldown to metadata
add_experiment(job_id, experiment_name, ...)Add queued experiment metadata and data path
add_measurement(experiment_name, ...[, ...])Add measurement metadata and data path
add_results(experiment_name, results, loops)Add measurement metadata, data path and results from a finished experiment.
add_sample(sample_name, manufacturer, wafer, ...)Add sample metadata
add_sequence_run(sequence_name, ...[, cooldown])Add sequence of experiments metadata.
get_calibration(measurement_id)Get Calibration of a measurement by its measurement_id.
get_dc_offsets(measurement_id)Get DC offsets of a measurement by its measurement_id.
get_debug(measurement_id)Get Debug of a measurement by its measurement_id.
get_platform(measurement_id)Get Platform of a measurement by its measurement_id.
get_qprogram(measurement_id)Get QProgram of a measurement by its measurement_id.
head([exp_name, current_sample, ...])Add an index at the beginning of the database.
load_by_id(id)Load measurements by their measurement_id.
Load autocalibration measurement by its measurement_id.
Load QaaS measurement by its measurement_id.
Load measurement by its measurement_id.
set_sample_and_cooldown(sample[, cooldown])Set sample and cooldown of the database
tail([exp_name, current_sample, ...])Add an index at the end of the database.
update_platform(platform)Update calibration platform after fitting
Methods Documentation
- add_autocal_measurement(experiment_name, qubit_idx, calibration, platform=None, qprogram=None, parameters=None, data_shape=None)
Add autocalibration measurement metadata and data path
- Parameters:
experiment_name (
str) – Experiment name.qubit_idx (
int) – Number of qubit index.calibration (
Calibration) – Experiment calibration parameters.platform (
Platform, optional) – Platform used on the experiment. Defaults to None.qprogram (
QProgram | None, optional) – Qprogram used on the experiment. Defaults to None.parameters (
list[str] | None, optional) – Parameters used on the experiment. Defaults to None.data_shape (
np.ndarray | None, optional) – Shape of the results array. Defaults to None.
- add_calibration_run(calibration_tree, sample_name, cooldown)
Add autocalibration metadata.
- Parameters:
calibration_tree (
dict) – Full calibration tree of the run.
- add_cooldown(cooldown, fridge, date=datetime.date(2026, 6, 4))
Add cooldown to metadata
- Parameters:
cooldown (
str) – Cooldown reference.fridge (
str) – Cooldown fridge.date (
datetime.date, optional) – Date of cooldown. Defaults to datetime.date.today().
- add_experiment(job_id, experiment_name, result_path, sample_name, cooldown)
Add queued experiment metadata and data path
- Parameters:
job_id (
int) – Queue job ID.experiment_name (
str) – Experiment name.result_path (
str) – Result path for data location.cooldown (
str) – Cooldown id.sample_name (
str) – Sample id.
- add_measurement(experiment_name, experiment_completed, cooldown=None, sample_name=None, optional_identifier=None, end_time=None, run_length=None, platform=None, experiment=None, qprogram=None, calibration=None, debug_file=None, parameters=None, data_shape=None, dc_offsets=None, target=None, secondary_source=None)
Add measurement metadata and data path
- Parameters:
experiment_name (
str) – Experiment name.experiment_completed (
bool) – Status of the experiment.base_path (
str) – Base path for data location.cooldown (
str | None, optional) – Cooldown id. Defaults to None.sample_name (
str | None, optional) – Sample id. Defaults to None.optional_identifier (
str | None, optional) – Optional additional information. Defaults to None.end_time (
datetime.datetime | None, optional) – Finishing time of the experiment. Defaults to None.run_length (
float | None, optional) – Time length of the experiment. Defaults to None.platform (
Platform, optional) – Platform used on the experiment. Defaults to None.experiment (
Experiment | None, optional) – Experiment class used on the experiment. Defaults to None.qprogram (
QProgram | None, optional) – Qprogram used on the experiment. Defaults to None.calibration (
Calibration | None, optional) – Calibration used on the experiment. Defaults to None.parameters (
list[str] | None, optional) – Parameters used on the experiment. Defaults to None.data_shape (
np.ndarray | None, optional) – Shape of the results array. Defaults to None.dc_offsets (
np.ndarray | None, optional) – Instruments offsets. Defaults to None.target (
np.ndarray | None, optional) – Target qubits list. Defaults to None.secondary_source (
np.ndarray | None, optional) – Secondary source buses list. Defaults to None.
- add_results(experiment_name, results, loops, cooldown=None, sample_name=None, optional_identifier=None, platform=None, experiment=None, qprogram=None, calibration=None, parameters=None)
Add measurement metadata, data path and results from a finished experiment.
- Parameters:
experiment_name (
str) – Experiment name.results (
np.ndarray) – Results array of a completed measurement.loops (
dict[str,np.ndarray]) – Dictionary of loops used in the experiment.cooldown (
str | None, optional) – Cooldown id. Defaults to None.sample_name (
str | None, optional) – Sample id. Defaults to None.optional_identifier (
str | None, optional) – Optional additional information. Defaults to None.platform (
Platform, optional) – Platform used on the experiment. Defaults to None.experiment (
Experiment | None, optional) – Experiment class used on the experiment. Defaults to None.qprogram (
QProgram | None, optional) – Qprogram used on the experiment. Defaults to None.calibration (
Calibration | None, optional) – Calibration used on the experiment. Defaults to None.parameters (
list[str] | None, optional) – Parameters used on the experiment. Defaults to None.
- add_sample(sample_name, manufacturer, wafer, sample, fab_run, device_design, n_qubits_per_device, additional_info=None)
Add sample metadata
- Parameters:
sample_name (
str) – Sample id.manufacturer (
str) – Sample manufacturer.wafer (
str) – Wafer id.sample (
str) – Sample id.fab_run (
str) – Fabrication information.device_design (
str) – Design information.n_qubits_per_device (
list[int]) – Number of Qbits inside the sample.additional_info (
str | None, optional) – Optional additional information. Defaults to None.
- add_sequence_run(sequence_name, sequence_tree, sample_name, cooldown=None)
Add sequence of experiments metadata.
- Parameters:
sequence_name (
str) – Experiment sequence name.sequence_tree (
dict) – Full experiment sequence tree of the run.sample_name (
str) – Sample id.cooldown (
str | None, optional) – Cooldown id. Defaults to None.
- get_calibration(measurement_id)
Get Calibration of a measurement by its measurement_id. To be used when you have light loaded measurements
- Parameters:
measurement_id (
int) – measurement_id value given by the database.
- get_dc_offsets(measurement_id)
Get DC offsets of a measurement by its measurement_id. To be used when you have light loaded measurements
- Parameters:
measurement_id (
int) – measurement_id value given by the database.
- get_debug(measurement_id)
Get Debug of a measurement by its measurement_id. To be used when you have light loaded measurements
- Parameters:
measurement_id (
int) – measurement_id value given by the database.
- get_platform(measurement_id)
Get Platform of a measurement by its measurement_id. To be used when you have light loaded measurements
- Parameters:
measurement_id (
int) – measurement_id value given by the database.
- get_qprogram(measurement_id)
Get QProgram of a measurement by its measurement_id. To be used when you have light loaded measurements
- Parameters:
measurement_id (
int) – measurement_id value given by the database.
- head(exp_name=None, current_sample=True, order_limit=5, pandas_output=False, light_read=False, before_id=None)
Add an index at the beginning of the database.
- Parameters:
exp_name (
str | None, optional) – Experiment name. Defaults to None.current_sample (
bool, optional) – Conditional to define if the sample is currently on use. Defaults to True.order_limit (
int | None, optional) – Limit of the order by query. Defaults to 5.pandas_output (
bool, optional) – If True, read database table into a DataFrame. Defaults to False.light_read (
bool, optional) – If True, load only a subset of the columns. Replace heavy columns Platform and Qprogram by True or False. Defaults to False.before_id (
int | None, optional) – If provided, only load measurements with measurement_id lower than since_id. Defaults to None.
- load_by_id(id)
Load measurements by their measurement_id.
- Parameters:
id (
int | list[int]) – measurement_id value given by the database.
- load_calibration_by_id(id)
Load autocalibration measurement by its measurement_id.
- Parameters:
id (
int) – measurement_id value given by the database.
- load_experiment_by_id(id)
Load QaaS measurement by its measurement_id.
- Parameters:
id (
int) – measurement_id value given by the database.
- load_sequence_by_id(id)
Load measurement by its measurement_id.
- Parameters:
id (
int | list[int]) – measurement_id value given by the database.- Returns:
returns the list of measurements or None if no sequence could be found.
- Return type:
list[Measurement] | None
- set_sample_and_cooldown(sample, cooldown=None)
Set sample and cooldown of the database
- Parameters:
sample (
str) – Sample name, mandatory parameter as allways needed unlike cooldowncooldown (
str | None, optional) – Cooldown name, contains multiple sample instances. Defaults to None.
- tail(exp_name=None, current_sample=True, order_limit=5, pandas_output=False, light_read=False, since_id=None)
Add an index at the end of the database.
- Parameters:
exp_name (
str | None, optional) – Experiment name. Defaults to None.current_sample (
bool, optional) – Conditional to define if the sample is currently on use. Defaults to True.order_limit (
int | None, optional) – Limit of the order by query. Defaults to 5.pandas_output (
bool, optional) – If True, read database table into a DataFrame. Defaults to False.light_read (
bool, optional) – If True, load only a subset of the columns. Replace heavy columns Platform and Qprogram by True or False. Defaults to False.since_id (
int | None, optional) – If provided, only load measurements with measurement_id greater than since_id. Defaults to None.
- update_platform(platform)
Update calibration platform after fitting
- Parameters:
platform (
Platform) – New platform to be set at platform_before column from AutocalMeasurement.