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=None)#
Bases:
JSONLike
Represents a script that is run to generate input files for an action.
- Parameters:
input_file (hpcflow.app.FileSpec) – The file to generate.
inputs (list[Parameter]) – The input parameters to the generator.
script (str) – The script that generates the input.
environment (hpcflow.app.Environment) – The environment in which to run the generator.
script_pass_env_spec (bool | None) – Whether to pass in the environment.
abortable (bool | None) – 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.
User-specified rules for whether 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.
- abortable: bool | None = 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.
- Return type:
- environment: Environment = 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 (Union[Dict, List]) – The data to deserialise.
shared_data (Optional[Dict[str, ObjectList]]) – 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.
- rules: List[ActionRule] | None = None#
User-specified rules for whether to run the generator.
- to_dict()#
Serialize this object as a dictionary.
- to_json_like(dct=None, shared_data=None, exclude=None, 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.