qdk_chemistry.ui.io module
File I/O utilities for QDK Chemistry data objects.
- qdk_chemistry.ui.io.current_project_dir()
Return the absolute project directory validated for this execution context.
- qdk_chemistry.ui.io.resolve_project_file(filename, *, allow_nested=False, allow_absolute=False)
Resolve a client-provided filename inside the current project sandbox.
Absolute paths, traversal components, Windows drive or UNC paths, and symlinks that resolve outside the project are rejected.
- Parameters:
- Return type:
- Returns:
An absolute path contained by the current project directory.
- Raises:
RuntimeError – If called outside a validated project context.
ValueError – If the filename is invalid or escapes the project.
- qdk_chemistry.ui.io.check_output_path_exists(filename, data_class=None)[source]
Check whether an exact output path already exists with valid content.
- qdk_chemistry.ui.io.check_output_exists(filename, data_class=None)[source]
Check if an output file already exists with valid content.
- Parameters:
- Returns:
A message if the file exists with valid content, None otherwise
- Return type:
- qdk_chemistry.ui.io.load_data_object(filename, data_class)[source]
Load a data object from either json or hdf5 file based on extension.
- Parameters:
- Returns:
The loaded data object
- Raises:
ValueError – If file extension is not supported
- qdk_chemistry.ui.io.save_data_object(data_obj, filename)[source]
Save a data object to either json or hdf5 file based on extension.
- Parameters:
- Returns:
The filename where data was saved
- Return type:
- Raises:
ValueError – If file extension is not supported