hpcflow 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. hpcflow/__init__.py +3 -0
  2. hpcflow/__pyinstaller/__init__.py +5 -0
  3. hpcflow/__pyinstaller/hook-hpcflow.py +41 -0
  4. hpcflow/_version.py +1 -0
  5. hpcflow/app.py +43 -0
  6. hpcflow/cli.py +4 -0
  7. hpcflow/data/data_manifests/__init__.py +3 -0
  8. hpcflow/data/data_manifests/data.json +15 -0
  9. hpcflow/data/data_manifests/programs.json +25 -0
  10. hpcflow/data/jinja_templates/__init__.py +0 -0
  11. hpcflow/data/jinja_templates/test/test_template.txt +8 -0
  12. hpcflow/data/scripts/__init__.py +1 -0
  13. hpcflow/data/scripts/bad_script.py +2 -0
  14. hpcflow/data/scripts/demo_task_1_generate_t1_infile_1.py +8 -0
  15. hpcflow/data/scripts/demo_task_1_generate_t1_infile_2.py +8 -0
  16. hpcflow/data/scripts/demo_task_1_parse_p3.py +7 -0
  17. hpcflow/data/scripts/do_nothing.py +2 -0
  18. hpcflow/data/scripts/env_specifier_test/input_file_generator_pass_env_spec.py +4 -0
  19. hpcflow/data/scripts/env_specifier_test/main_script_test_pass_env_spec.py +8 -0
  20. hpcflow/data/scripts/env_specifier_test/output_file_parser_pass_env_spec.py +4 -0
  21. hpcflow/data/scripts/env_specifier_test/v1/input_file_generator_basic.py +4 -0
  22. hpcflow/data/scripts/env_specifier_test/v1/main_script_test_direct_in_direct_out.py +7 -0
  23. hpcflow/data/scripts/env_specifier_test/v1/output_file_parser_basic.py +4 -0
  24. hpcflow/data/scripts/env_specifier_test/v2/main_script_test_direct_in_direct_out.py +7 -0
  25. hpcflow/data/scripts/generate_t1_file_01.py +7 -0
  26. hpcflow/data/scripts/import_future_script.py +7 -0
  27. hpcflow/data/scripts/input_file_generator_basic.py +3 -0
  28. hpcflow/data/scripts/input_file_generator_basic_FAIL.py +3 -0
  29. hpcflow/data/scripts/input_file_generator_test_stdout_stderr.py +8 -0
  30. hpcflow/data/scripts/main_script_test_direct_in.py +3 -0
  31. hpcflow/data/scripts/main_script_test_direct_in_direct_out.py +6 -0
  32. hpcflow/data/scripts/main_script_test_direct_in_direct_out_2.py +6 -0
  33. hpcflow/data/scripts/main_script_test_direct_in_direct_out_2_fail_allowed.py +6 -0
  34. hpcflow/data/scripts/main_script_test_direct_in_direct_out_2_fail_allowed_group.py +7 -0
  35. hpcflow/data/scripts/main_script_test_direct_in_direct_out_3.py +6 -0
  36. hpcflow/data/scripts/main_script_test_direct_in_direct_out_all_iters_test.py +15 -0
  37. hpcflow/data/scripts/main_script_test_direct_in_direct_out_env_spec.py +7 -0
  38. hpcflow/data/scripts/main_script_test_direct_in_direct_out_labels.py +8 -0
  39. hpcflow/data/scripts/main_script_test_direct_in_group_direct_out_3.py +6 -0
  40. hpcflow/data/scripts/main_script_test_direct_in_group_one_fail_direct_out_3.py +6 -0
  41. hpcflow/data/scripts/main_script_test_direct_sub_param_in_direct_out.py +6 -0
  42. hpcflow/data/scripts/main_script_test_hdf5_in_obj.py +12 -0
  43. hpcflow/data/scripts/main_script_test_hdf5_in_obj_2.py +12 -0
  44. hpcflow/data/scripts/main_script_test_hdf5_in_obj_group.py +12 -0
  45. hpcflow/data/scripts/main_script_test_hdf5_out_obj.py +11 -0
  46. hpcflow/data/scripts/main_script_test_json_and_direct_in_json_out.py +14 -0
  47. hpcflow/data/scripts/main_script_test_json_in_json_and_direct_out.py +17 -0
  48. hpcflow/data/scripts/main_script_test_json_in_json_out.py +14 -0
  49. hpcflow/data/scripts/main_script_test_json_in_json_out_labels.py +16 -0
  50. hpcflow/data/scripts/main_script_test_json_in_obj.py +12 -0
  51. hpcflow/data/scripts/main_script_test_json_out_FAIL.py +3 -0
  52. hpcflow/data/scripts/main_script_test_json_out_obj.py +10 -0
  53. hpcflow/data/scripts/main_script_test_json_sub_param_in_json_out_labels.py +16 -0
  54. hpcflow/data/scripts/main_script_test_random_seed.py +5 -0
  55. hpcflow/data/scripts/main_script_test_shell_env_vars.py +12 -0
  56. hpcflow/data/scripts/main_script_test_std_out_std_err.py +6 -0
  57. hpcflow/data/scripts/output_file_parser_basic.py +3 -0
  58. hpcflow/data/scripts/output_file_parser_basic_FAIL.py +7 -0
  59. hpcflow/data/scripts/output_file_parser_test_stdout_stderr.py +8 -0
  60. hpcflow/data/scripts/parse_t1_file_01.py +4 -0
  61. hpcflow/data/scripts/script_exit_test.py +5 -0
  62. hpcflow/data/template_components/__init__.py +1 -0
  63. hpcflow/data/template_components/command_files.yaml +26 -0
  64. hpcflow/data/template_components/environments.yaml +20 -0
  65. hpcflow/data/template_components/parameters.yaml +14 -0
  66. hpcflow/data/template_components/task_schemas.yaml +139 -0
  67. hpcflow/data/workflows/__init__.py +0 -0
  68. hpcflow/data/workflows/workflow_1.yaml +5 -0
  69. hpcflow/examples.ipynb +1037 -0
  70. hpcflow/pytest_plugin.py +81 -0
  71. hpcflow/sdk/__init__.py +153 -0
  72. hpcflow/sdk/app.py +5858 -0
  73. hpcflow/sdk/cli.py +1989 -0
  74. hpcflow/sdk/cli_common.py +499 -0
  75. hpcflow/sdk/compact_errors.py +433 -0
  76. hpcflow/sdk/config/__init__.py +5 -0
  77. hpcflow/sdk/config/callbacks.py +282 -0
  78. hpcflow/sdk/config/cli.py +404 -0
  79. hpcflow/sdk/config/config.py +1469 -0
  80. hpcflow/sdk/config/config_file.py +498 -0
  81. hpcflow/sdk/config/errors.py +272 -0
  82. hpcflow/sdk/config/types.py +154 -0
  83. hpcflow/sdk/core/__init__.py +39 -0
  84. hpcflow/sdk/core/actions.py +3868 -0
  85. hpcflow/sdk/core/app_aware.py +25 -0
  86. hpcflow/sdk/core/cache.py +224 -0
  87. hpcflow/sdk/core/command_files.py +814 -0
  88. hpcflow/sdk/core/commands.py +423 -0
  89. hpcflow/sdk/core/element.py +2088 -0
  90. hpcflow/sdk/core/enums.py +225 -0
  91. hpcflow/sdk/core/environment.py +384 -0
  92. hpcflow/sdk/core/errors.py +1183 -0
  93. hpcflow/sdk/core/execute.py +209 -0
  94. hpcflow/sdk/core/imports.py +284 -0
  95. hpcflow/sdk/core/input_sources.py +297 -0
  96. hpcflow/sdk/core/json_like.py +806 -0
  97. hpcflow/sdk/core/loop.py +1320 -0
  98. hpcflow/sdk/core/loop_cache.py +282 -0
  99. hpcflow/sdk/core/object_list.py +986 -0
  100. hpcflow/sdk/core/parameters.py +3442 -0
  101. hpcflow/sdk/core/rule.py +196 -0
  102. hpcflow/sdk/core/run_dir_files.py +57 -0
  103. hpcflow/sdk/core/skip_reason.py +7 -0
  104. hpcflow/sdk/core/task.py +3638 -0
  105. hpcflow/sdk/core/task_schema.py +1023 -0
  106. hpcflow/sdk/core/test_utils.py +557 -0
  107. hpcflow/sdk/core/types.py +457 -0
  108. hpcflow/sdk/core/utils.py +1198 -0
  109. hpcflow/sdk/core/validation.py +87 -0
  110. hpcflow/sdk/core/values.py +517 -0
  111. hpcflow/sdk/core/warnings.py +144 -0
  112. hpcflow/sdk/core/workflow.py +5163 -0
  113. hpcflow/sdk/core/zarr_io.py +206 -0
  114. hpcflow/sdk/data/__init__.py +13 -0
  115. hpcflow/sdk/data/config_file_schema.yaml +34 -0
  116. hpcflow/sdk/data/config_schema.yaml +307 -0
  117. hpcflow/sdk/data/environments_spec_schema.yaml +27 -0
  118. hpcflow/sdk/data/files_spec_schema.yaml +5 -0
  119. hpcflow/sdk/data/parameters_spec_schema.yaml +7 -0
  120. hpcflow/sdk/data/task_schema_spec_schema.yaml +3 -0
  121. hpcflow/sdk/data/workflow_spec_schema.yaml +23 -0
  122. hpcflow/sdk/demo/__init__.py +3 -0
  123. hpcflow/sdk/demo/cli.py +278 -0
  124. hpcflow/sdk/helper/__init__.py +3 -0
  125. hpcflow/sdk/helper/cli.py +137 -0
  126. hpcflow/sdk/helper/helper.py +300 -0
  127. hpcflow/sdk/helper/watcher.py +192 -0
  128. hpcflow/sdk/log.py +287 -0
  129. hpcflow/sdk/persistence/__init__.py +18 -0
  130. hpcflow/sdk/persistence/base.py +2878 -0
  131. hpcflow/sdk/persistence/defaults.py +6 -0
  132. hpcflow/sdk/persistence/discovery.py +39 -0
  133. hpcflow/sdk/persistence/json.py +955 -0
  134. hpcflow/sdk/persistence/pending.py +947 -0
  135. hpcflow/sdk/persistence/store_resource.py +203 -0
  136. hpcflow/sdk/persistence/types.py +309 -0
  137. hpcflow/sdk/persistence/utils.py +73 -0
  138. hpcflow/sdk/persistence/zarr.py +2403 -0
  139. hpcflow/sdk/runtime.py +323 -0
  140. hpcflow/sdk/submission/__init__.py +3 -0
  141. hpcflow/sdk/submission/enums.py +70 -0
  142. hpcflow/sdk/submission/jobscript.py +2489 -0
  143. hpcflow/sdk/submission/schedulers/__init__.py +279 -0
  144. hpcflow/sdk/submission/schedulers/direct.py +238 -0
  145. hpcflow/sdk/submission/schedulers/sge.py +403 -0
  146. hpcflow/sdk/submission/schedulers/slurm.py +628 -0
  147. hpcflow/sdk/submission/schedulers/utils.py +25 -0
  148. hpcflow/sdk/submission/shells/__init__.py +53 -0
  149. hpcflow/sdk/submission/shells/base.py +229 -0
  150. hpcflow/sdk/submission/shells/bash.py +508 -0
  151. hpcflow/sdk/submission/shells/os_version.py +115 -0
  152. hpcflow/sdk/submission/shells/powershell.py +363 -0
  153. hpcflow/sdk/submission/submission.py +1406 -0
  154. hpcflow/sdk/submission/types.py +140 -0
  155. hpcflow/sdk/typing.py +212 -0
  156. hpcflow/sdk/utils/arrays.py +69 -0
  157. hpcflow/sdk/utils/deferred_file.py +59 -0
  158. hpcflow/sdk/utils/envs.py +27 -0
  159. hpcflow/sdk/utils/errors.py +23 -0
  160. hpcflow/sdk/utils/files.py +114 -0
  161. hpcflow/sdk/utils/hashing.py +16 -0
  162. hpcflow/sdk/utils/patches.py +31 -0
  163. hpcflow/sdk/utils/strings.py +86 -0
  164. hpcflow/sdk/utils/web_docs.py +38 -0
  165. hpcflow/tests/api/test_api.py +32 -0
  166. hpcflow/tests/conftest.py +144 -0
  167. hpcflow/tests/data/__init__.py +0 -0
  168. hpcflow/tests/data/benchmark_N_elements.yaml +6 -0
  169. hpcflow/tests/data/benchmark_script_runner.yaml +26 -0
  170. hpcflow/tests/data/multi_path_sequences.yaml +29 -0
  171. hpcflow/tests/data/workflow_1.json +15 -0
  172. hpcflow/tests/data/workflow_1.yaml +8 -0
  173. hpcflow/tests/data/workflow_1_slurm.yaml +8 -0
  174. hpcflow/tests/data/workflow_1_wsl.yaml +8 -0
  175. hpcflow/tests/data/workflow_test_run_abort.yaml +42 -0
  176. hpcflow/tests/jinja_templates/test_jinja_templates.py +159 -0
  177. hpcflow/tests/programs/test_programs.py +175 -0
  178. hpcflow/tests/schedulers/direct_linux/test_direct_linux_submission.py +12 -0
  179. hpcflow/tests/schedulers/sge/test_sge_submission.py +36 -0
  180. hpcflow/tests/schedulers/slurm/test_slurm_submission.py +14 -0
  181. hpcflow/tests/scripts/test_input_file_generators.py +249 -0
  182. hpcflow/tests/scripts/test_main_scripts.py +1265 -0
  183. hpcflow/tests/scripts/test_non_snippet_script.py +46 -0
  184. hpcflow/tests/scripts/test_output_file_parsers.py +318 -0
  185. hpcflow/tests/shells/wsl/test_wsl_submission.py +15 -0
  186. hpcflow/tests/unit/test_action.py +1058 -0
  187. hpcflow/tests/unit/test_action_rule.py +24 -0
  188. hpcflow/tests/unit/test_app.py +136 -0
  189. hpcflow/tests/unit/test_cache.py +46 -0
  190. hpcflow/tests/unit/test_cli.py +189 -0
  191. hpcflow/tests/unit/test_command.py +371 -0
  192. hpcflow/tests/unit/test_compact_formatter.py +76 -0
  193. hpcflow/tests/unit/test_config.py +203 -0
  194. hpcflow/tests/unit/test_config_file.py +162 -0
  195. hpcflow/tests/unit/test_element.py +668 -0
  196. hpcflow/tests/unit/test_element_iteration.py +88 -0
  197. hpcflow/tests/unit/test_element_set.py +152 -0
  198. hpcflow/tests/unit/test_group.py +115 -0
  199. hpcflow/tests/unit/test_imports.py +182 -0
  200. hpcflow/tests/unit/test_input_source.py +1471 -0
  201. hpcflow/tests/unit/test_input_value.py +384 -0
  202. hpcflow/tests/unit/test_jobscript_unit.py +826 -0
  203. hpcflow/tests/unit/test_json_like.py +1235 -0
  204. hpcflow/tests/unit/test_loop.py +2656 -0
  205. hpcflow/tests/unit/test_meta_task.py +325 -0
  206. hpcflow/tests/unit/test_multi_path_sequences.py +259 -0
  207. hpcflow/tests/unit/test_object_list.py +109 -0
  208. hpcflow/tests/unit/test_parameter.py +221 -0
  209. hpcflow/tests/unit/test_persistence.py +664 -0
  210. hpcflow/tests/unit/test_resources.py +366 -0
  211. hpcflow/tests/unit/test_run.py +286 -0
  212. hpcflow/tests/unit/test_run_directories.py +29 -0
  213. hpcflow/tests/unit/test_runtime.py +9 -0
  214. hpcflow/tests/unit/test_schema_input.py +358 -0
  215. hpcflow/tests/unit/test_secrets.py +105 -0
  216. hpcflow/tests/unit/test_shell.py +137 -0
  217. hpcflow/tests/unit/test_slurm.py +39 -0
  218. hpcflow/tests/unit/test_submission.py +490 -0
  219. hpcflow/tests/unit/test_task.py +2530 -0
  220. hpcflow/tests/unit/test_task_schema.py +200 -0
  221. hpcflow/tests/unit/test_utils.py +616 -0
  222. hpcflow/tests/unit/test_value_sequence.py +530 -0
  223. hpcflow/tests/unit/test_values.py +95 -0
  224. hpcflow/tests/unit/test_workflow.py +779 -0
  225. hpcflow/tests/unit/test_workflow_template.py +212 -0
  226. hpcflow/tests/unit/utils/test_arrays.py +40 -0
  227. hpcflow/tests/unit/utils/test_deferred_file_writer.py +34 -0
  228. hpcflow/tests/unit/utils/test_hashing.py +65 -0
  229. hpcflow/tests/unit/utils/test_patches.py +5 -0
  230. hpcflow/tests/unit/utils/test_redirect_std.py +50 -0
  231. hpcflow/tests/unit/utils/test_strings.py +97 -0
  232. hpcflow/tests/workflows/__init__.py +0 -0
  233. hpcflow/tests/workflows/test_directory_structure.py +31 -0
  234. hpcflow/tests/workflows/test_jobscript.py +353 -0
  235. hpcflow/tests/workflows/test_run_status.py +194 -0
  236. hpcflow/tests/workflows/test_skip_downstream.py +696 -0
  237. hpcflow/tests/workflows/test_submission.py +140 -0
  238. hpcflow/tests/workflows/test_workflows.py +583 -0
  239. hpcflow/tests/workflows/test_zip.py +18 -0
  240. hpcflow/viz_demo.ipynb +6794 -0
  241. hpcflow-0.1.0.dist-info/LICENSE +375 -0
  242. hpcflow-0.1.0.dist-info/METADATA +65 -0
  243. hpcflow-0.1.0.dist-info/RECORD +245 -0
  244. hpcflow-0.1.0.dist-info/WHEEL +4 -0
  245. hpcflow-0.1.0.dist-info/entry_points.txt +6 -0
hpcflow/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from hpcflow._version import __version__
2
+
3
+ _app_name = "hpcFlow"
@@ -0,0 +1,5 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def get_hook_dirs():
5
+ return [str(Path(__file__).parent.resolve())]
@@ -0,0 +1,41 @@
1
+ from PyInstaller.utils.hooks import collect_data_files
2
+
3
+ from hpcflow.sdk import sdk_classes
4
+
5
+
6
+ # most of the modules in `sdk_classes` are imported on-demand via the app object:
7
+ hiddenimports = [
8
+ *sdk_classes.values(),
9
+ "hpcflow.sdk.data",
10
+ "hpcflow.data.data_manifests",
11
+ "hpcflow.data.scripts",
12
+ "hpcflow.data.jinja_templates",
13
+ "hpcflow.data.template_components",
14
+ "hpcflow.data.workflows",
15
+ "hpcflow.tests.data",
16
+ "hpcflow.sdk.core.test_utils",
17
+ "hpcflow.sdk.utils.patches",
18
+ "click.testing",
19
+ "requests", # for GitHub fsspec file system
20
+ "fsspec.implementations.github", # for GitHub fsspec file system
21
+ "hpcflow.pytest_plugin",
22
+ ]
23
+
24
+ datas = (
25
+ collect_data_files("hpcflow.sdk.data")
26
+ + collect_data_files("hpcflow.data.data_manifests")
27
+ + collect_data_files(
28
+ "hpcflow.data.scripts", include_py_files=True, excludes=("**/__pycache__",)
29
+ )
30
+ + collect_data_files(
31
+ "hpcflow.data.jinja_templates",
32
+ include_py_files=True,
33
+ excludes=("**/__pycache__",),
34
+ )
35
+ + collect_data_files("hpcflow.data.template_components")
36
+ + collect_data_files("hpcflow.data.workflows")
37
+ + collect_data_files(
38
+ "hpcflow.tests", include_py_files=True, excludes=("**/__pycache__",)
39
+ )
40
+ + collect_data_files("hpcflow.tests.data")
41
+ )
hpcflow/_version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
hpcflow/app.py ADDED
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+ from hpcflow import __version__, _app_name
3
+ from hpcflow.sdk import app as sdk_app
4
+ from hpcflow.sdk.config import ConfigOptions
5
+
6
+
7
+ # provide access to app attributes:
8
+ __getattr__ = sdk_app.get_app_attribute
9
+
10
+ # ensure docs/help can see dynamically loaded attributes:
11
+ __all__ = sdk_app.get_app_module_all()
12
+ __dir__ = sdk_app.get_app_module_dir()
13
+
14
+ # set app-level config options:
15
+ config_options = ConfigOptions(
16
+ directory_env_var="HPCFLOW_CONFIG_DIR",
17
+ default_directory="~/.hpcflow",
18
+ )
19
+
20
+ # load built in template components (in this case, for demonstration purposes):
21
+ template_components = sdk_app.BaseApp.load_builtin_template_component_data(
22
+ "hpcflow.data.template_components"
23
+ )
24
+
25
+ # initialise the App object:
26
+ app: sdk_app.BaseApp = sdk_app.BaseApp(
27
+ name=_app_name,
28
+ version=__version__,
29
+ module=__name__,
30
+ docs_import_conv="hf",
31
+ description="Computational workflow management",
32
+ gh_org="hpcflow",
33
+ gh_repo="hpcflow",
34
+ config_options=config_options,
35
+ template_components=template_components,
36
+ scripts_dir="data.scripts", # relative to root package
37
+ jinja_templates_dir="data.jinja_templates", # relative to root package
38
+ workflows_dir="data.workflows", # relative to root package
39
+ data_manifest_dir="hpcflow.data.data_manifests",
40
+ data_dir="github://hpcflow:hpcflow-data@main/data",
41
+ program_dir="github://hpcflow:hpcflow-data@main/programs",
42
+ docs_url="https://hpcflow.github.io/docs/stable",
43
+ ) #: |app|
hpcflow/cli.py ADDED
@@ -0,0 +1,4 @@
1
+ from hpcflow.app import cli
2
+
3
+ if __name__ == "__main__":
4
+ cli()
@@ -0,0 +1,3 @@
1
+ """
2
+ Manifest for demonstration data and builtin programs.
3
+ """
@@ -0,0 +1,15 @@
1
+ {
2
+ "text_file_1.txt": {
3
+ "zip_file": "text_file_1.zip"
4
+ },
5
+ "text_file_2": {
6
+ "zip_contents": "text_file_2.zip"
7
+ },
8
+ "zip_file.zip": {},
9
+ "test_dataset_1": {
10
+ "zip_file": "test_dataset_1.zip"
11
+ },
12
+ "test_dataset_2": {
13
+ "zip_contents": "test_dataset_2.zip"
14
+ }
15
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "hello_world/linux_x86_64": {
3
+ "zip_contents": "hello_world/linux_x86_64/hello_world.zip",
4
+ "executable": "hello_world",
5
+ "set_executable": [
6
+ "hello_world"
7
+ ]
8
+ },
9
+ "hello_world/macos_x86_64": {
10
+ "executable": "hello_world",
11
+ "set_executable": [
12
+ "hello_world"
13
+ ]
14
+ },
15
+ "hello_world/macos_arm64": {
16
+ "zip_file": "hello_world/macos_arm64/hello_world.zip",
17
+ "executable": "hello_world",
18
+ "set_executable": [
19
+ "hello_world"
20
+ ]
21
+ },
22
+ "hello_world/win_AMD64": {
23
+ "executable": "hello_world.exe"
24
+ }
25
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ Hola, {{ name }}!
2
+
3
+ This is a template, with a loop. Here are your specified fruits:
4
+
5
+ {%- for fruit_i in fruits %}
6
+ - {{ fruit_i -}}
7
+ {% endfor %}
8
+
@@ -0,0 +1 @@
1
+ """This is required to allow the frozen app to find the scripts resources..."""
@@ -0,0 +1,2 @@
1
+ def bad_script():
2
+ raise SyntaxError("oh no!")
@@ -0,0 +1,8 @@
1
+ from random import randint
2
+ from pathlib import Path
3
+
4
+
5
+ def demo_task_1_generate_t1_infile_1(path, p1):
6
+ with Path(path).open("w") as fp:
7
+ fp.write(f"{randint(0, 1e6)}\n")
8
+ fp.write(f"p1: {p1}\n")
@@ -0,0 +1,8 @@
1
+ from random import randint
2
+ from pathlib import Path
3
+
4
+
5
+ def demo_task_1_generate_t1_infile_2(path, p2):
6
+ with Path(path).open("w") as fp:
7
+ fp.write(f"{randint(0, 1e6)}\n")
8
+ fp.write(f"p2: {p2}\n")
@@ -0,0 +1,7 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def demo_task_1_parse_p3(t1_outfile_1):
5
+ with Path(t1_outfile_1).open("r") as fp:
6
+ p3 = int(fp.readline().strip())
7
+ return p3
@@ -0,0 +1,2 @@
1
+ def do_nothing():
2
+ pass
@@ -0,0 +1,4 @@
1
+ def input_file_generator_pass_env_spec(path, p1, env_spec):
2
+ print(env_spec)
3
+ with path.open("w") as fp:
4
+ fp.write(f"{p1}\n")
@@ -0,0 +1,8 @@
1
+ def main_script_test_pass_env_spec(p1, env_spec):
2
+ # process
3
+ p2 = p1 + 100
4
+
5
+ print(env_spec)
6
+
7
+ # return outputs
8
+ return {"p2": p2}
@@ -0,0 +1,4 @@
1
+ def output_file_parser_pass_env_spec(my_output_file, env_spec):
2
+ print(env_spec)
3
+ with my_output_file.open("r") as fp:
4
+ return int(fp.read().strip())
@@ -0,0 +1,4 @@
1
+ # version: v1
2
+ def input_file_generator_basic(path, p1):
3
+ with path.open("w") as fp:
4
+ fp.write(f"{p1}\n")
@@ -0,0 +1,7 @@
1
+ # version: v1
2
+ def main_script_test_direct_in_direct_out(p1):
3
+ # process
4
+ p2 = p1 + 100
5
+
6
+ # return outputs
7
+ return {"p2": p2}
@@ -0,0 +1,4 @@
1
+ # version: v1
2
+ def output_file_parser_basic(my_output_file):
3
+ with my_output_file.open("r") as fp:
4
+ return int(fp.read().strip())
@@ -0,0 +1,7 @@
1
+ # version: v2
2
+ def main_script_test_direct_in_direct_out(p1):
3
+ # process
4
+ p2 = p1 + 200
5
+
6
+ # return outputs
7
+ return {"p2": p2}
@@ -0,0 +1,7 @@
1
+ from random import randint
2
+
3
+
4
+ def generate_t1_file_01(path, p1):
5
+ with path.open("w") as fp:
6
+ fp.write(f"{randint(0, 1e6)}\n")
7
+ fp.write(f"p1: {p1}\n")
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+
4
+ def import_future_script():
5
+ """Used to test the `__future__` import is moved to the top of the file in the
6
+ generated script in the case of `resources.combine_scripts == True`"""
7
+ pass
@@ -0,0 +1,3 @@
1
+ def input_file_generator_basic(path, p1):
2
+ with path.open("w") as fp:
3
+ fp.write(f"{p1}\n")
@@ -0,0 +1,3 @@
1
+ def input_file_generator_basic_FAIL(path, p1):
2
+ # silently fail to generate the input file!
3
+ pass
@@ -0,0 +1,8 @@
1
+ import sys
2
+
3
+
4
+ def input_file_generator_test_stdout_stderr(path, p1):
5
+ print(p1)
6
+ print(p1, file=sys.stderr)
7
+ with path.open("w") as fp:
8
+ fp.write(f"{p1}\n")
@@ -0,0 +1,3 @@
1
+ def main_script_test_direct_in(p1):
2
+ # process
3
+ print(p1 + 100)
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_direct_out(p1):
2
+ # process
3
+ p2 = p1 + 100
4
+
5
+ # return outputs
6
+ return {"p2": p2}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_direct_out_2(p2):
2
+ # process
3
+ p3 = p2 + 100
4
+
5
+ # return outputs
6
+ return {"p3": p3}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_direct_out_2_fail_allowed(p2):
2
+ # process, accounting for possible unset data:
3
+ p3 = (p2 if p2 is not None else 0) + 100
4
+
5
+ # return outputs
6
+ return {"p3": p3}
@@ -0,0 +1,7 @@
1
+ def main_script_test_direct_in_direct_out_2_fail_allowed_group(p2):
2
+ # process, accounting for possible unset data:
3
+ p2_sum = sum(i for i in p2 if i is not None)
4
+ p3 = p2_sum + 100
5
+
6
+ # return outputs
7
+ return {"p3": p3}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_direct_out_3(p3):
2
+ # process
3
+ p4 = p3 + 100
4
+
5
+ # return outputs
6
+ return {"p4": p4}
@@ -0,0 +1,15 @@
1
+ def main_script_test_direct_in_direct_out_all_iters_test(p1):
2
+ """Used for a simple loop test, where we pass all iterations to the script."""
3
+
4
+ # sum over all iterations:
5
+ all_p1_vals = []
6
+ for key, val in p1.items():
7
+ print(f"\nkey: {key}")
8
+ print(f"loop_idx: {val['loop_idx']}")
9
+ print(f"value: {val['value']}")
10
+ all_p1_vals.append(val["value"])
11
+
12
+ p1 = sum(all_p1_vals) + 1
13
+
14
+ # return outputs
15
+ return {"p1": p1}
@@ -0,0 +1,7 @@
1
+ def main_script_test_direct_in_direct_out_env_spec(p1, env_spec):
2
+
3
+ # process
4
+ p2 = p1 + 100
5
+
6
+ # return outputs
7
+ return {"p2": env_spec}
@@ -0,0 +1,8 @@
1
+ def main_script_test_direct_in_direct_out_labels(p1):
2
+ # process
3
+ p1_1 = p1["one"]
4
+ p1_2 = p1["two"]
5
+ p2 = p1_1 + p1_2
6
+
7
+ # return outputs
8
+ return {"p2": p2}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_group_direct_out_3(p3):
2
+ # process
3
+ p4 = sum(p3) + 100
4
+
5
+ # return outputs
6
+ return {"p4": p4}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_in_group_one_fail_direct_out_3(p3):
2
+ # process, ignore some un-set inputs:
3
+ p4 = sum([i for i in p3 if i is not None]) + 100
4
+
5
+ # return outputs
6
+ return {"p4": p4}
@@ -0,0 +1,6 @@
1
+ def main_script_test_direct_sub_param_in_direct_out(a):
2
+ # process
3
+ p2 = a + 100
4
+
5
+ # return outputs
6
+ return {"p2": p2}
@@ -0,0 +1,12 @@
1
+ import h5py # type: ignore[import-untyped]
2
+
3
+
4
+ def main_script_test_hdf5_in_obj(_input_files):
5
+ # read inputs
6
+ with h5py.File(_input_files["hdf5"], mode="r") as fh:
7
+ a = fh["p1c"].attrs["a"].item()
8
+
9
+ # process
10
+ p2 = a + 100
11
+
12
+ return {"p2": p2}
@@ -0,0 +1,12 @@
1
+ import h5py # type: ignore
2
+
3
+
4
+ def main_script_test_hdf5_in_obj_2(p2, _input_files):
5
+ # read inputs
6
+ with h5py.File(_input_files["hdf5"], mode="r") as fh:
7
+ a = fh["p1c"].attrs["a"].item()
8
+
9
+ # process
10
+ p3 = a + 100
11
+
12
+ return {"p3": p3}
@@ -0,0 +1,12 @@
1
+ import h5py # type: ignore[import-untyped]
2
+
3
+
4
+ def main_script_test_hdf5_in_obj_group(_input_files):
5
+ # read inputs
6
+ with h5py.File(_input_files["hdf5"], mode="r") as fh:
7
+ all_a = [p1c_dat.attrs["a"].item() for p1c_dat in fh["p1c"].values()]
8
+
9
+ # process
10
+ p2 = sum(all_a) + 100
11
+
12
+ return {"p2": p2}
@@ -0,0 +1,11 @@
1
+ import h5py # type: ignore[import-untyped]
2
+
3
+
4
+ def main_script_test_hdf5_out_obj(p1, _output_files):
5
+ # process
6
+ p1c = {"a": p1 + 100}
7
+
8
+ # write outputs
9
+ with h5py.File(_output_files["hdf5"], mode="w") as fh:
10
+ p1c_grp = fh.create_group("p1c")
11
+ p1c_grp.attrs["a"] = p1c["a"]
@@ -0,0 +1,14 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_and_direct_in_json_out(p2, _input_files, _output_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ p1 = int(json.load(fh)["p1"])
8
+
9
+ # process
10
+ p3 = p1 + p2
11
+
12
+ # save outputs
13
+ with _output_files["json"].open("wt") as fh:
14
+ json.dump({"p3": p3}, fh)
@@ -0,0 +1,17 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_in_json_and_direct_out(_input_files, _output_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ p1 = int(json.load(fh)["p1"])
8
+
9
+ # process
10
+ p2 = p1 + 100
11
+ p3 = p1 + 200
12
+
13
+ # save outputs
14
+ with _output_files["json"].open("wt") as fh:
15
+ json.dump({"p2": p2}, fh)
16
+
17
+ return {"p3": p3}
@@ -0,0 +1,14 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_in_json_out(_input_files, _output_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ p1 = int(json.load(fh)["p1"])
8
+
9
+ # process
10
+ p2 = p1 + 100
11
+
12
+ # save outputs
13
+ with _output_files["json"].open("wt") as fh:
14
+ json.dump({"p2": p2}, fh)
@@ -0,0 +1,16 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_in_json_out_labels(_input_files, _output_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ inp_dat = json.load(fh)
8
+ p1_1 = int(inp_dat["p1[one]"])
9
+ p1_2 = int(inp_dat["p1[two]"])
10
+
11
+ # process
12
+ p2 = p1_1 + p1_2
13
+
14
+ # save outputs
15
+ with _output_files["json"].open("wt") as fh:
16
+ json.dump({"p2": p2}, fh)
@@ -0,0 +1,12 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_in_obj(_input_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ p1c = json.load(fh)["p1c"]
8
+
9
+ # process
10
+ p2 = p1c["a"] + 100
11
+
12
+ return {"p2": p2}
@@ -0,0 +1,3 @@
1
+ def main_script_test_json_out_FAIL(_output_files):
2
+ pass
3
+ # don't generate a JSON output file!
@@ -0,0 +1,10 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_out_obj(p1, _output_files):
5
+ # process
6
+ p1c = {"a": p1 + 100}
7
+
8
+ # write outputs
9
+ with _output_files["json"].open("wt") as fh:
10
+ json.dump({"p1c": p1c}, fh)
@@ -0,0 +1,16 @@
1
+ import json
2
+
3
+
4
+ def main_script_test_json_sub_param_in_json_out_labels(_input_files, _output_files):
5
+ # read inputs
6
+ with _input_files["json"].open("rt") as fh:
7
+ inp_dat = json.load(fh)
8
+ a = int(inp_dat["a"])
9
+ p1_2 = int(inp_dat["p1[two]"])
10
+
11
+ # process
12
+ p2 = a + p1_2
13
+
14
+ # save outputs
15
+ with _output_files["json"].open("wt") as fh:
16
+ json.dump({"p2": p2}, fh)
@@ -0,0 +1,5 @@
1
+ import os
2
+
3
+
4
+ def main_script_test_random_seed():
5
+ return {"p2": int(os.environ["HPCFLOW_RUN_RANDOM_SEED"])}
@@ -0,0 +1,12 @@
1
+ import json
2
+ import os
3
+
4
+
5
+ def main_script_test_shell_env_vars(p1):
6
+ with open("env_vars.json", "wt") as fp:
7
+ json.dump(
8
+ {k: v for k, v in os.environ.items() if k.startswith("HPCFLOW")},
9
+ fp,
10
+ indent=4,
11
+ )
12
+ return {"p1": p1 + 1}
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+
4
+ def main_script_test_std_out_std_err(stdout_msg, stderr_msg):
5
+ print(stdout_msg)
6
+ print(stderr_msg, file=sys.stderr)
@@ -0,0 +1,3 @@
1
+ def output_file_parser_basic(my_output_file):
2
+ with my_output_file.open("r") as fp:
3
+ return int(fp.read().strip())
@@ -0,0 +1,7 @@
1
+ def output_file_parser_basic_FAIL(my_output_file):
2
+ # parse the output file, but then delete it, so it cannot be saved (when run with
3
+ # `OFP.save_files=True`):
4
+ with my_output_file.open("r") as fp:
5
+ out = int(fp.read().strip())
6
+ my_output_file.unlink()
7
+ return out
@@ -0,0 +1,8 @@
1
+ import sys
2
+
3
+
4
+ def output_file_parser_test_stdout_stderr(my_output_file, p1):
5
+ print(p1)
6
+ print(p1, file=sys.stderr)
7
+ with my_output_file.open("r") as fp:
8
+ return int(fp.read().strip())
@@ -0,0 +1,4 @@
1
+ def parse_t1_file_01(t1_file_01):
2
+ with t1_file_01.open("r") as fp:
3
+ p4 = int(fp.readline().strip())
4
+ return p4
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+
4
+ def script_exit_test(exit_code):
5
+ sys.exit(exit_code)
@@ -0,0 +1 @@
1
+ """YAML files containing built-in template components, used for demonstrations."""