workflow.processing_tree_io#

The pydidas.workflow.processing_tree_io package includes importers/exporters for the WorkflowTree in different formats as well as a registry metaclass to handle actual imports/exports.

class pydidas.workflow.processing_tree_io.ProcessingTreeIoBase#

Base class for WorkflowTree exporters.

This class defines the format_name and extensions attributes for all ProcessingTreeIo classes.

static export_to_file(filename: Path | str, tree: ProcessingTree, **kwargs: Any) None#

Write the content to a file.

This method needs to be implemented by the concrete subclass.

Parameters:
  • filename (Path or str) – The filename of the file to be written.

  • tree (ProcessingTree) – The workflow tree instance.

  • **kwargs (Any) – Additional keyword arguments.

static import_from_file(filename: Path | str, **kwargs: Any) ProcessingTree#

Restore the content from a file.

This method needs to be implemented by the concrete subclass.

Parameters:
  • filename (Path or str) – The filename of the file to be read.

  • **kwargs (Any) – Additional keyword arguments.

Returns:

The restored ProcessingTree.

Return type:

ProcessingTree

class pydidas.workflow.processing_tree_io.ProcessingTreeIoMeta(clsname: str, bases: tuple[type], attrs: dict[str, Any])#

Metaclass for ProcessingTree exporters and importers which holds the registry with all associated file extensions for exporting ProcessingTrees.

classmethod export_to_file(filename: Path | str, tree: ProcessingTree, **kwargs: Any) None#

Call the export_to_file method associated with extension of the filename.

Parameters:
  • filename (Path or str) – The full filename and path.

  • tree (ProcessingTree) – The instance of the ProcessingTree.

  • **kwargs (Any) – Any kwargs which should be passed to the underlying exporter.

classmethod import_from_file(filename: Path | str) ProcessingTree#

Call the concrete import_from_file method in the subclass registered to the extension of the filename.

Parameters:

filename (Path or str) – The full filename and path.

Returns:

The new ProcessingTree instance.

Return type:

ProcessingTree