hpcflow.app.InputFileGeneratorSource#

class hpcflow.app.InputFileGeneratorSource(generator, path=None, contents=None, extension='')#

Bases: InputFileGeneratorSource

The source of code for use in an input file generator.

Parameters:
  • generator (InputFileGenerator) – How to generate the file.

  • path (Path | str | None) – Path to the file to generate.

  • contents (str | None) – Contents of the file. Only used when recreating this object.

  • extension (str) – File name extension.

Methods

from_json_like

Make an instance of this class from JSON (or YAML) data.

make_persistent

Save to a persistent workflow.

read_contents

Get the actual contents of the file.

to_dict

Serialize this object as a dictionary.

to_json_like

Serialize this object as an object structure that can be trivially converted to JSON.

Attributes

contents

The contents of the file.

extension

The extension of the file.

normalised_path

Full workflow value path to the file.

path

The path to the file.

store_contents

Whether the file's contents are stored in the workflow's persistent store.

workflow

The owning workflow.

generator

How to generate the file.

file

What file is this? Only if known.

property contents: str#

The contents of the file.

property extension: str#

The extension of the file.

file: FileSpec#

What file is this? Only if known.

classmethod from_json_like(json_like, shared_data=None)#

Make an instance of this class from JSON (or YAML) data.

Parameters:
  • json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.

  • shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.

Return type:

The deserialised object.

generator#

How to generate the file.

make_persistent(workflow, source)#

Save to a persistent workflow.

Returns:

  • String is the data path for this task input and integer list

  • contains the indices of the parameter data Zarr groups where the data is

  • stored.

Parameters:
Return type:

tuple[str, list[int], bool]

property normalised_path: str#

Full workflow value path to the file.

Note

This is not the same as the path in the filesystem, but is closely related.

property path: Path | None#

The path to the file.

read_contents()#

Get the actual contents of the file.

Return type:

str

property store_contents: Any#

Whether the file’s contents are stored in the workflow’s persistent store.

to_dict()#

Serialize this object as a dictionary.

Return type:

dict[str, Any]

to_json_like(dct=None, shared_data=None, exclude=(), path=None)#

Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.

Parameters:
  • dct (dict[str, JSONable] | None) –

  • shared_data (_JSONDeserState) –

  • exclude (Container[str | None]) –

  • path (list | None) –

Return type:

tuple[JSONDocument, _JSONDeserState]

property workflow: Workflow#

The owning workflow.