HDF5 I/O#

The datalab.gui.h5io module provides the HDF5 file open/save into/from DataLab data model/main window.

class datalab.gui.h5io.H5InputOutput(mainwindow: DLMainWindow)[source]#

Object handling HDF5 file open/save into/from DataLab data model/main window

Parameters:

mainwindow – Main window

append_informed#

True when the user was already told, for the current opening, that the provenance of appended workspaces is not imported (no repeat).

cancelled_files: list[str]#

Files whose appending the user cancelled (see __confirm_append())

save_file(filename: str) → None[source]#

Save all signals and images from DataLab model into a HDF5 file

The file is replaced only once completely written: if saving fails, the previous file (if any) is left untouched.

open_file_headless(filename: str, reset_all: bool) → bool[source]#

Open native DataLab HDF5 file without any GUI elements.

This method can be safely called from any thread (e.g., the console thread) as it does not create any Qt widgets or dialogs. When a file holding provenance is appended (reset_all False), its provenance is not imported and the notice datalab_capsule.recorder.APPEND_NOTICE is added to mainwindow.provenance.notices (and logged).

Parameters:
  • filename – HDF5 filename

  • reset_all – Reset all application data before importing

Returns:

True if file was successfully opened as a native DataLab file, False if the file format is not compatible (KeyError was raised)

Raises:

ProvenanceFormatError – If the provenance block is invalid (raised before the workspace is replaced).

open_file(filename: str, import_all: bool, reset_all: bool) → None[source]#

Open HDF5 file

When the file holds provenance and is appended to the current workspace, the user is warned before anything changes (see __confirm_append()) and may cancel. A file that is not a DataLab workspace is imported as a generic HDF5 file.

open_workspace_file(filename: str) → None[source]#

Open a DataLab workspace file, replacing the workspace.

Unlike open_file(), a file that is not a DataLab workspace is never imported as a generic HDF5 file.

Raises:
  • ValueError – If the file is not a DataLab workspace.

  • ProvenanceFormatError – If the provenance block is invalid.

import_files(filenames: list[str], import_all: bool, reset_all: bool) → None[source]#

Import HDF5 files

import_dataset_from_file(filename: str, dsetname: str) → None[source]#

Import dataset from HDF5 file