create_full_measurement

specatalog.helpers.full_entry.create_full_measurement(data, raw_data_path, fmt, progress=None)[source]

Create a complete measurement entry with atomic database and file operations.

Performs all measurement creation steps in a transaction-safe manner:

  1. Creates the database entry.

  2. Sets up a temporary directory.

  3. Creates the temporary measurement directory.

  4. Copies the raw data files.

  5. Converts the raw data to HDF5 format.

  6. Copies the completed measurement to the final archive location.

  7. Commits the database transaction.

Parameters:
  • data (cr.measurement_model_pyd) – Measurement metadata used to create the database entry.

  • raw_data_path (list[str]) – List of paths to the raw data files that should be copied and processed.

  • fmt (str) – Identifier of the raw data format.

  • progress (ProgressCallback, optional) –

    Optional callback used to report the progress of the operation. The callback is called with two arguments:

    • fractionfloat

      Progress value between 0.0 and 1.0.

    • messagestr

      Human-readable description of the current processing step.

    The callback is independent of the GUI and may, for example, be connected to a graphical progress bar by the caller.

Returns:

Result object containing the status of the operation.

If the operation succeeds, success is True and measurement_id contains the ID of the created measurement.

If the operation fails, success is False and error contains the exception that caused the failure.

Return type:

CreateMeasurementResult

Notes

A temporary directory is used to ensure that incomplete files are not written directly to the final archive location.

If an error occurs, database and file operations are rolled back where possible, and partially created archive data is removed.

The progress callback is optional. If it is None, no progress information is reported.

The function does not depend on Qt or any other GUI framework.