5. Working with metadata
Note
This section is Work in Progress.
5.1. Automatically collecting metadata
When doing measurements, QuMADA automatically collects metadata during setup and run of the measurement.
Here is an overview of collected metadata and where it is collected:
The measurements datetime and a reference to the measured data is collected after calling
qumada.measurement.measurement.MeasurementScript.run()
To turn off the collection, use argumentsadd_datetime_to_metadata
andadd_data_to_metadata
.The instrument mapping is added during
qumada.instrument.mapping.base.map_gates_to_instruments()
.Script and settings are added during
qumada.measurement.measurement.MeasurementScript.setup()
. Use argumentsadd_script_to_metadata
andadd_parameters_to_metadata
respectively to turn this off.
# ...
# Don't add script or parameters to metadata automatically
script.setup(
parameters,
metadata,
add_script_to_metadata=False,
add_parameters_to_metadata=False,
)
# Don't add datetime or data metadata automatically
script.run(add_datetime_to_metadata=False, add_data_to_metadata=False)
5.2. Save to database
Before measurement, the created metadata is automatically saved to the database, if the measurement was setup with it.
This happens after calling qumada.measurement.measurement.MeasurementScript.run()
.
To deactivate this feature, use the argument insert_metadata_into_db
.
script: MeasurementScript = ...
# Automatically save metadata to the database
script.run() # default
script.run(insert_metadata_into_db=True) # explicit
# Don't save metadata to the database
script.run(insert_metadata_into_db=False)
Metadata or any domain object can be saved by qumada.metadata.Savable.save()
or updated by qumada.metadata.Savable.update()
. This only works for metadata implementations, that are savable.