hpcflow.sdk.app.BaseApp#
- class hpcflow.sdk.app.BaseApp(*args, **kwargs)#
Bases:
object
Class to generate the hpcflow application.
- Parameters:
name – The name of the application.
version – The version of the application.
module – The module name in which the app object is defined.
description – Description of the application.
gh_org – Name of Github organisation responsible for the application.
gh_repo – Github repository containing the application source.
config_options – Configuration options.
scripts_dir – Directory for scripts.
workflows_dir – Directory for workflows.
demo_data_dir – Directory for demonstration data.
data_data_manifest_dir – Directory for demonstration data manifests.
template_components – Template components.
pytest_args – Arguments for pytest.
package_name – Name of package if not the application name.
docs_import_conv – The convention for the app alias used in import statements in the documentation. E.g. for the hpcflow base app, this is hf. This is combined with module to form the complete import statement. E.g. for the hpcflow base app, the complete import statement is: import hpcflow.app as hf, where hpcflow.app is the module argument and hf is the docs_import_conv argument.
docs_url – URL to documentation.
- Return type:
T
Methods
Get the name of all cached demo data file.
Get the name of a cached demo data file.
Delete the contents of the example data files cache directory.
Clear the known-submissions file of all submissions.
Delete the contents of the cache directory.
Delete the contents of the hostname-scoped cache directory.
Delete the contents of the user runtime directory.
Configure an execution environment.
Copy a builtin demo data file to the specified location.
Copy a builtin demo workflow to the specified location.
Retrieve a list of schedulers that are supported in principle by this operating system.
Return the full path to the config file, without loading the config.
Get the full path to an example data file in the app cache directory.
Get a dict whose keys are example data file names and whose values are the source files if the source file required unzipping or None otherwise.
Context manager to get a (temporary) file path to an included demo workflow template.
Get miscellaneous runtime system information.
Get a dict mapping parameter types to task schemas that input/output each parameter.
Get an arbitrary scheduler object.
List available example data files.
Return a list of demo workflow templates included in the app.
Load the template component data built into the package.
Load the user's configuration.
Load a WorkflowTemplate object from a builtin demo template file.
Load all template component data, warning by default if already loaded.
Return a decorator for retrying functions on permission and OS errors that might be associated with cloud-storage desktop sync.
Retrieve existing workflows that might be running.
Reload the configuration.
Reload all template component data, warning by default if not already loaded.
Reset the config file to defaults, and reload the config.
Print the contents of a builtin demo workflow template file.
Get template components from a (simply parsed) JSON document.
Discard any loaded configuration.
Update submission records in the known-submission file.
Attributes
The logger for API messages.
Action
The
Action
class.ActionEnvironment
The
ActionEnvironment
class.ActionRule
The
ActionRule
class.ActionScope
The
ActionScope
class.ActionScopeType
The
ActionScopeType
class.The logger for CLI messages.
Command
The
Command
class.CommandFilesList
The
CommandFilesList
class.DirectPosix
The
DirectPosix
class.DirectWindows
The
DirectWindows
class.Element
The
Element
class.ElementAction
The
ElementAction
class.ElementActionRun
The
ElementActionRun
class.ElementFilter
The
ElementFilter
class.ElementGroup
The
ElementGroup
class.ElementInputFiles
The
ElementInputFiles
class.ElementInputs
The
ElementInputs
class.ElementIteration
The
ElementIteration
class.ElementOutputFiles
The
ElementOutputFiles
class.ElementOutputs
The
ElementOutputs
class.ElementParameter
The
ElementParameter
class.ElementPropagation
The
ElementPropagation
class.ElementResources
The
ElementResources
class.ElementSet
The
ElementSet
class.Environment
The
Environment
class.EnvironmentsList
The
EnvironmentsList
class.Executable
The
Executable
class.ExecutableInstance
The
ExecutableInstance
class.ExecutablesList
The
ExecutablesList
class.FileNameExt
The
FileNameExt
class.FileNameSpec
The
FileNameSpec
class.FileNameStem
The
FileNameStem
class.FileSpec
The
FileSpec
class.GroupList
The
GroupList
class.InputFileGenerator
The
InputFileGenerator
class.InputSource
The
InputSource
class.InputSourceType
The
InputSourceType
class.InputValue
The
InputValue
class.Jobscript
The
Jobscript
class.Loop
The
Loop
class.NumCores
The
NumCores
class.OutputFileParser
The
OutputFileParser
class.Parameter
The
Parameter
class.ParameterValue
The
ParameterValue
class.Parameters
The
Parameters
class.ParametersList
The
ParametersList
class.QueuedScheduler
The
QueuedScheduler
class.ResourceList
The
ResourceList
class.ResourceSpec
The
ResourceSpec
class.Rule
The
Rule
class.RunDirAppFiles
The
RunDirAppFiles
class.SGEPosix
The
SGEPosix
class.SchemaInput
The
SchemaInput
class.SchemaOutput
The
SchemaOutput
class.SchemaParameter
The
SchemaParameter
class.SlurmPosix
The
SlurmPosix
class.Submission
The
Submission
class.Task
The
Task
class.TaskInputParameters
The
TaskInputParameters
class.TaskList
The
TaskList
class.TaskObjective
The
TaskObjective
class.TaskOutputParameters
The
TaskOutputParameters
class.TaskSchema
The
TaskSchema
class.TaskSchemasList
The
TaskSchemasList
class.TaskSourceType
The
TaskSourceType
class.TaskTemplateList
The
TaskTemplateList
class.ValueSequence
The
ValueSequence
class.Workflow
The
Workflow
class.WorkflowLoop
The
WorkflowLoop
class.WorkflowLoopList
The
WorkflowLoopList
class.WorkflowTask
The
WorkflowTask
class.WorkflowTaskList
The
WorkflowTaskList
class.WorkflowTemplate
The
WorkflowTemplate
class.Cancel the execution of a workflow submission.
The known template command files.
The configuration.
The logger for configuration messages.
A directory for example data caching.
The known template execution environments.
Get information about the operating system.
Retrieve information about active and recently inactive finished workflows.
Get information about a given shell and the operating system.
Whether the configuration is loaded.
Whether any template component (e.g.
The path to the file describing known submissions.
The application log.
The main underlying logger.
Generate and submit a new demo workflow from a file or string containing a workflow template parametrisation.
Generate and submit a new workflow from a file or string containing a workflow template parametrisation.
Generate a new workflow from a builtin demo workflow template.
Generate a new workflow from a file or string containing a workflow template parametrisation.
The known template parameters.
The logger for persistence engine messages.
Run hpcflow test suite.
Run the test suite.
Information about the runtime.
The logger for runtime messages.
The scheduler mapping.
The known template scripts.
Show information about running workflows.
Output a legend for the jobscript-element and EAR states that are displayed by the show command.
The logger for job submission messages.
Submit an existing workflow.
The known template task schemas.
The template component data.
Whether the timing analysis system is active.
The user's cache directory.
The hostname-scoped app cache directory.
The user's data directory.
The directory for holding user data.
The user's temporary runtime directory.
The name of the application.
Name of package.
The version of the application.
The module name in which the app object is defined.
Description of the application.
Name of Github organisation responsible for the application.
Github repository containing the application source.
Configuration options.
Arguments for pytest.
Directory for scripts.
Directory for workflows.
Directory for demonstration data.
Directory for demonstration data manifests.
The convention for the app alias used in import statements in the documentation.
URL to documentation.
Command line interface subsystem.
- property API_logger: Logger#
The logger for API messages.
- property CLI_logger: Logger#
The logger for CLI messages.
- cache_all_demo_data_files()#
Get the name of all cached demo data file.
- Return type:
- cache_demo_data_file(file_name)#
Get the name of a cached demo data file.
- property cancel: _Cancel#
Cancel the execution of a workflow submission.
- clear_demo_data_cache_dir()#
Delete the contents of the example data files cache directory.
- Return type:
None
- clear_known_submissions_file()#
Clear the known-submissions file of all submissions. This shouldn’t be needed normally.
- Return type:
None
- clear_user_cache_dir()#
Delete the contents of the cache directory.
- Return type:
None
- clear_user_cache_hostname_dir()#
Delete the contents of the hostname-scoped cache directory.
- Return type:
None
- clear_user_runtime_dir()#
Delete the contents of the user runtime directory.
- Return type:
None
- cli#
Command line interface subsystem.
- property command_files: _CommandFilesList#
The known template command files.
- property config_logger: Logger#
The logger for configuration messages.
- config_options#
Configuration options.
- configure_env(name, setup=None, executables=None, use_current_env=False, env_source_file=None)#
Configure an execution environment.
- copy_demo_data(file_name, dst=None, doc=True)#
Copy a builtin demo data file to the specified location.
- copy_demo_workflow(name, dst=None, doc=True)#
Copy a builtin demo workflow to the specified location.
- Parameters:
name (str) – The name of the demo workflow to copy
dst (PathLike | None) – Directory or full file path to copy the demo workflow to. If not specified, the current working directory will be used.
doc (bool) – If False, the copied workflow template file will not include the doc attribute (if originally present).
- Return type:
- demo_data_dir#
Directory for demonstration data.
- demo_data_manifest_dir#
Directory for demonstration data manifests.
- description#
Description of the application.
- docs_import_conv#
The convention for the app alias used in import statements in the documentation.
- docs_url#
URL to documentation.
- property envs: _EnvironmentsList#
The known template execution environments.
- get_OS_supported_schedulers()#
Retrieve a list of schedulers that are supported in principle by this operating system.
This does not necessarily mean all the returned schedulers are available on this system.
- Return type:
Iterator[str]
- get_config_path(config_dir=None)#
Return the full path to the config file, without loading the config.
- Parameters:
config_dir (PathLike) –
- Return type:
Path
- get_demo_data_file_path(file_name)#
Get the full path to an example data file in the app cache directory.
If the file does not already exist in the app cache directory, it will be added (and unzipped if required). The file may first be downloaded from a remote file system such as GitHub (see _get_demo_data_file_source_path for details).
- get_demo_data_files_manifest()#
Get a dict whose keys are example data file names and whose values are the source files if the source file required unzipping or None otherwise.
If the config item demo_data_manifest_file is set, this is used as the manifest file path. Otherwise, the app attribute demo_data_manifest_dir is used, and is expected to be the package/directory in the source code within which a file demo_data_manifest.json is expected.
- get_demo_workflow_template_file(name, doc=True, delete=True)#
Context manager to get a (temporary) file path to an included demo workflow template.
- Parameters:
- Return type:
Iterator[Path]
- property get_known_submissions: _GetKnownSubmissions#
Retrieve information about active and recently inactive finished workflows.
This method removes workflows from the known-submissions file that are found to be inactive on this machine (according to the scheduler/process ID).
- Parameters:
- Returns:
List of descriptions of known items.
- Return type:
- get_parameter_task_schema_map()#
Get a dict mapping parameter types to task schemas that input/output each parameter.
- get_scheduler(scheduler_name, os_name, scheduler_args=None)#
Get an arbitrary scheduler object.
- property get_shell_info: Callable[[str, bool], VersionInfo]#
Get information about a given shell and the operating system.
- gh_org#
Name of Github organisation responsible for the application.
- gh_repo#
Github repository containing the application source.
- property is_template_components_loaded: bool#
Whether any template component (e.g. parameters) has been loaded.
- list_demo_workflows()#
Return a list of demo workflow templates included in the app.
- classmethod load_builtin_template_component_data(package)#
Load the template component data built into the package. This is as opposed to the template components defined by users.
- Parameters:
package (ModuleType | str) –
- Return type:
BasicTemplateComponents
- load_config(config_dir=None, config_key=None, warn=True, **overrides)#
Load the user’s configuration.
- load_demo_workflow(name)#
Load a WorkflowTemplate object from a builtin demo template file.
- Parameters:
name (str) –
- Return type:
_WorkflowTemplate
- load_template_components(warn=True)#
Load all template component data, warning by default if already loaded.
- Parameters:
warn (bool) –
- Return type:
None
- property logger: Logger#
The main underlying logger.
- property make_and_submit_demo_workflow: _MakeAndSubmitDemoWorkflow#
Generate and submit a new demo workflow from a file or string containing a workflow template parametrisation.
- Parameters:
workflow_name (str) – Name of the demo workflow to make. Required.
template_format (str) – If specified, one of “json” or “yaml”. This forces parsing from a particular format.
path (str | Path) – The directory in which the workflow will be generated. The current directory if not specified.
name (str) – The name of the workflow. If specified, the workflow directory will be path joined with name. If not specified the WorkflowTemplate name will be used, in combination with a date-timestamp.
overwrite (bool) – If True and the workflow directory (path + name) already exists, the existing directory will be overwritten.
store (str) – The persistent store to use for this workflow.
ts_fmt (str) – The datetime format to use for storing datetimes. Datetimes are always stored in UTC (because Numpy does not store time zone info), so this should not include a time zone name.
ts_name_fmt (str) – The datetime format to use when generating the workflow name, where it includes a timestamp.
store_kwargs (dict[str, object]) – Keyword arguments to pass to the store’s write_empty_workflow method.
variables (dict[str, str]) – String variables to substitute in the demo workflow template file.
JS_parallelism (bool) – If True, allow multiple jobscripts to execute simultaneously. Raises if set to True but the store type does not support the jobscript_parallelism feature. If not set, jobscript parallelism will be used if the store type supports it.
wait (bool) – If True, this command will block until the workflow execution is complete.
add_to_known (bool) – If True, add the new submission to the known-submissions file, which is used by the show command to monitor current and recent submissions.
return_idx (bool) – If True, return a dict representing the jobscript indices submitted for each submission.
tasks (list[int]) – List of task indices to include in this submission. By default all tasks are included.
cancel (bool) – Immediately cancel the submission. Useful for testing and benchmarking.
status (bool) – If True, display a live status to track submission progress.
- Returns:
Workflow – The created workflow.
dict[int, list[int]] – Mapping of submission handles. If requested by
return_idx
parameter.
- property make_and_submit_workflow: _MakeAndSubmitWorkflow#
Generate and submit a new workflow from a file or string containing a workflow template parametrisation.
- Parameters:
template_path_or_str (str) – Either a path to a template file in YAML or JSON format, or a YAML/JSON string.
is_string (str) – Determines whether template_path_or_str is a string or a file.
template_format (str) – If specified, one of “json” or “yaml”. This forces parsing from a particular format.
path (str | Path) – The directory in which the workflow will be generated. The current directory if not specified.
name (str) – The name of the workflow. If specified, the workflow directory will be path joined with name. If not specified the WorkflowTemplate name will be used, in combination with a date-timestamp.
overwrite (bool) – If True and the workflow directory (path + name) already exists, the existing directory will be overwritten.
store (str) – The persistent store to use for this workflow.
ts_fmt (str) – The datetime format to use for storing datetimes. Datetimes are always stored in UTC (because Numpy does not store time zone info), so this should not include a time zone name.
ts_name_fmt (str) – The datetime format to use when generating the workflow name, where it includes a timestamp.
store_kwargs (dict[str, object]) – Keyword arguments to pass to the store’s write_empty_workflow method.
variables (dict[str, str]) – String variables to substitute in template_file_or_str.
JS_parallelism (bool) – If True, allow multiple jobscripts to execute simultaneously. Raises if set to True but the store type does not support the jobscript_parallelism feature. If not set, jobscript parallelism will be used if the store type supports it.
wait (bool) – If True, this command will block until the workflow execution is complete.
add_to_known (bool) – If True, add the new submission to the known-submissions file, which is used by the show command to monitor current and recent submissions.
return_idx (bool) – If True, return a dict representing the jobscript indices submitted for each submission.
tasks (list[int]) – List of task indices to include in this submission. By default all tasks are included.
cancel (bool) – Immediately cancel the submission. Useful for testing and benchmarking.
status (bool) – If True, display a live status to track workflow creation and submission progress.
- Returns:
Workflow – The created workflow.
dict[int, list[int]] – Mapping of submission handles. If requested by
return_idx
parameter.
- property make_demo_workflow: _MakeDemoWorkflow#
Generate a new workflow from a builtin demo workflow template.
- Parameters:
workflow_name (str) – Name of the demo workflow to make.
template_format (str) – If specified, one of “json” or “yaml”. This forces parsing from a particular format.
path (str | Path) – The directory in which the workflow will be generated. The current directory if not specified.
name (str) – The name of the workflow. If specified, the workflow directory will be path joined with name. If not specified the workflow template name will be used, in combination with a date-timestamp.
overwrite (bool) – If True and the workflow directory (path + name) already exists, the existing directory will be overwritten.
store (str) – The persistent store type to use.
ts_fmt (str) – The datetime format to use for storing datetimes. Datetimes are always stored in UTC (because Numpy does not store time zone info), so this should not include a time zone name.
ts_name_fmt (str) – The datetime format to use when generating the workflow name, where it includes a timestamp.
store_kwargs (dict[str, object]) – Keyword arguments to pass to the store’s write_empty_workflow method.
variables (dict[str, str]) – String variables to substitute in the demo workflow template file.
status (bool) – If True, display a live status to track workflow creation progress.
- Returns:
The created workflow.
- Return type:
- property make_workflow: _MakeWorkflow#
Generate a new workflow from a file or string containing a workflow template parametrisation.
- Parameters:
template_path_or_str (str) – Either a path to a template file in YAML or JSON format, or a YAML/JSON string.
is_string (bool) – Determines if passing a file path or a string.
template_format (str) – If specified, one of “json” or “yaml”. This forces parsing from a particular format.
path (str | Path) – The directory in which the workflow will be generated. The current directory if not specified.
name (str) – The name of the workflow. If specified, the workflow directory will be path joined with name. If not specified the workflow template name will be used, in combination with a date-timestamp.
overwrite (bool) – If True and the workflow directory (path + name) already exists, the existing directory will be overwritten.
store (str) – The persistent store type to use.
ts_fmt (str) – The datetime format to use for storing datetimes. Datetimes are always stored in UTC (because Numpy does not store time zone info), so this should not include a time zone name.
ts_name_fmt (str) – The datetime format to use when generating the workflow name, where it includes a timestamp.
store_kwargs (dict[str, object]) – Keyword arguments to pass to the store’s write_empty_workflow method.
variables (dict[str, str]) – String variables to substitute in template_file_or_str.
status (bool) – If True, display a live status to track workflow creation progress.
- Returns:
The created workflow.
- Return type:
- module#
The module name in which the app object is defined.
- name#
The name of the application.
- package_name#
Name of package.
- property parameters: _ParametersList#
The known template parameters.
- perm_error_retry()#
Return a decorator for retrying functions on permission and OS errors that might be associated with cloud-storage desktop sync. engine operations.
- property persistence_logger: Logger#
The logger for persistence engine messages.
- pytest_args#
Arguments for pytest.
- read_known_submissions_file()#
Retrieve existing workflows that might be running.
- Return type:
- reload_config(config_dir=None, config_key=None, warn=True, **overrides)#
Reload the configuration. Use if a user has updated the configuration file outside the scope of this application.
- reload_template_components(warn=True)#
Reload all template component data, warning by default if not already loaded.
- Parameters:
warn (bool) –
- Return type:
None
- reset_config(config_dir=None, config_key=None, warn=True, **overrides)#
Reset the config file to defaults, and reload the config.
- property run_hpcflow_tests: _RunTests#
Run hpcflow test suite. This function is only available from derived apps.
- property run_tests: _RunTests#
Run the test suite.
- property run_time_info: RunTimeInfo#
Information about the runtime.
- property runtime_info_logger: Logger#
The logger for runtime messages.
- property scripts: dict[str, pathlib.Path]#
The known template scripts.
- scripts_dir#
Directory for scripts.
- property show: _Show#
Show information about running workflows.
- Parameters:
- show_demo_workflow(name, syntax=True, doc=False)#
Print the contents of a builtin demo workflow template file.
- property show_legend: Callable[[], None]#
Output a legend for the jobscript-element and EAR states that are displayed by the show command.
- property submission_logger: Logger#
The logger for job submission messages.
- property submit_workflow: _SubmitWorkflow#
Submit an existing workflow.
- Parameters:
workflow_path (str) – Path to an existing workflow
JS_parallelism (bool) – If True, allow multiple jobscripts to execute simultaneously. Raises if set to True but the store type does not support the jobscript_parallelism feature. If not set, jobscript parallelism will be used if the store type supports it.
tasks (list[int]) – List of task indices to include in this submission. By default all tasks are included.
- Returns:
Mapping of submission handles. If requested by
return_idx
parameter.- Return type:
- property task_schemas: _TaskSchemasList#
The known template task schemas.
- property template_components: TemplateComponents#
The template component data.
- template_components_from_json_like(json_like)#
Get template components from a (simply parsed) JSON document.
- Parameters:
- Return type:
- unload_config()#
Discard any loaded configuration.
- Return type:
None
- update_known_subs_file(inactive_IDs, start_times, end_times)#
Update submission records in the known-submission file.
Note
We aim for atomicity to help with the scenario where a new workflow submission is adding itself to the file at the same time as we have decided an existing workflow should no longer be part of this file. Ideally, such a scenario should not arise because both operations should only ever be interactively initiated by the single user (Workflow.submit and App.get_known_submissions). If this operation is atomic, then at least the known-submissions file should be left in a usable (but inaccurate) state.
- property user_data_hostname_dir: Path#
The directory for holding user data.
We segregate by hostname to account for the case where multiple machines might use the same shared file system.
- version#
The version of the application.
- workflows_dir#
Directory for workflows.