hpcflow.sdk.core.command_files.InputFileGenerator#
- class hpcflow.sdk.core.command_files.InputFileGenerator(input_file, inputs, script=None, environment=None, script_pass_env_spec=False, abortable=False, rules=<factory>)#
Bases:
JSONLike
Represents a script that is run to generate input files for an action.
- Parameters:
input_file (FileSpec) – The file to generate.
inputs (list[Parameter]) – The input parameters to the generator.
script (str | None) – The script that generates the input.
environment (Environment | None) – The environment in which to run the generator.
script_pass_env_spec (bool) – Whether to pass in the environment.
abortable (bool) – Whether the generator can be stopped early. Quick-running scripts tend to not need this.
rules (list[ActionRule]) – User-specified rules for whether to run the generator.
Methods
Generate the file contents of this input file generator source.
Make an instance of this class from JSON (or YAML) data.
Get the rules that allow testing if this input file generator must be run or not for a given element.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Write the script if it is specified as a snippet script, otherwise we assume the script already exists in the working directory.
Attributes
Whether the generator can be stopped early.
The environment in which to run the generator.
The script that generates the inputs.
Whether to pass in the environment.
The file to generate.
The input parameters to the generator.
User-specified rules for whether to run the generator.
- abortable: bool = False#
Whether the generator can be stopped early. Quick-running scripts tend to not need this.
- compose_source(snip_path)#
Generate the file contents of this input file generator source.
- environment: Environment | None = None#
The environment in which to run the generator.
- 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.
- get_action_rules()#
Get the rules that allow testing if this input file generator must be run or not for a given element.
- Return type:
- rules: list[ActionRule]#
User-specified rules for whether to run the generator.
- 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.