Qcodes icon indicating copy to clipboard operation
Qcodes copied to clipboard

Bug: load_from_netcdf fails if a dataset does is not completed

Open astafan8 opened this issue 7 months ago • 0 comments

When trying load a non-completed qcodes dataset from a netcdf file, to which it was successfully exported, the following exception happens:

    netcdf_dataset = load_from_netcdf(
        netcdf_export_path, path_to_db=target_conn.path_to_dbfile
    )
  File "C:\Users\miastafe\repos\Qcodes\src\qcodes\dataset\data_set_in_memory.py", line 906, in load_from_netcdf
    return DataSetInMem._load_from_netcdf(path=path, path_to_db=path_to_db)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\miastafe\repos\Qcodes\src\qcodes\dataset\data_set_in_memory.py", line 294, in _load_from_netcdf
    completed_timestamp_raw=float(loaded_data.completed_timestamp_raw),
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\miastafe\repos\Qcodes\.venv\Lib\site-packages\xarray\core\common.py", line 306, in __getattr__
    raise AttributeError(
        f"{type(self).__name__!r} object has no attribute {name!r}"
    )
AttributeError: 'Dataset' object has no attribute 'completed_timestamp_raw'. Did you mean: 'completed_timestamp'?

Likely load_from_netcdf function and its underlying implementation does not handle a case of loading non-complete datasets (which can be successfully exported to netcdf files). So this likely needs to be fixed correctly by handling this case and making sure that loaded dataset object is in a correct state in terms of it's complete-ness. Refer to qcodes documentation and dataset implementation for info. A test needs to be added to cover this case, it can be added to the same module where the rest of load_from_netcdf function is being tested.

astafan8 avatar Jun 11 '25 12:06 astafan8