hpcflow-new2 0.2.0a189__py3-none-any.whl → 0.2.0a190__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 (115) hide show
  1. hpcflow/__pyinstaller/hook-hpcflow.py +8 -6
  2. hpcflow/_version.py +1 -1
  3. hpcflow/app.py +1 -0
  4. hpcflow/data/scripts/main_script_test_hdf5_in_obj.py +1 -1
  5. hpcflow/data/scripts/main_script_test_hdf5_out_obj.py +1 -1
  6. hpcflow/sdk/__init__.py +21 -15
  7. hpcflow/sdk/app.py +2133 -770
  8. hpcflow/sdk/cli.py +281 -250
  9. hpcflow/sdk/cli_common.py +6 -2
  10. hpcflow/sdk/config/__init__.py +1 -1
  11. hpcflow/sdk/config/callbacks.py +77 -42
  12. hpcflow/sdk/config/cli.py +126 -103
  13. hpcflow/sdk/config/config.py +578 -311
  14. hpcflow/sdk/config/config_file.py +131 -95
  15. hpcflow/sdk/config/errors.py +112 -85
  16. hpcflow/sdk/config/types.py +145 -0
  17. hpcflow/sdk/core/actions.py +1054 -994
  18. hpcflow/sdk/core/app_aware.py +24 -0
  19. hpcflow/sdk/core/cache.py +81 -63
  20. hpcflow/sdk/core/command_files.py +275 -185
  21. hpcflow/sdk/core/commands.py +111 -107
  22. hpcflow/sdk/core/element.py +724 -503
  23. hpcflow/sdk/core/enums.py +192 -0
  24. hpcflow/sdk/core/environment.py +74 -93
  25. hpcflow/sdk/core/errors.py +398 -51
  26. hpcflow/sdk/core/json_like.py +540 -272
  27. hpcflow/sdk/core/loop.py +380 -334
  28. hpcflow/sdk/core/loop_cache.py +160 -43
  29. hpcflow/sdk/core/object_list.py +370 -207
  30. hpcflow/sdk/core/parameters.py +728 -600
  31. hpcflow/sdk/core/rule.py +59 -41
  32. hpcflow/sdk/core/run_dir_files.py +33 -22
  33. hpcflow/sdk/core/task.py +1546 -1325
  34. hpcflow/sdk/core/task_schema.py +240 -196
  35. hpcflow/sdk/core/test_utils.py +126 -88
  36. hpcflow/sdk/core/types.py +387 -0
  37. hpcflow/sdk/core/utils.py +410 -305
  38. hpcflow/sdk/core/validation.py +82 -9
  39. hpcflow/sdk/core/workflow.py +1192 -1028
  40. hpcflow/sdk/core/zarr_io.py +98 -137
  41. hpcflow/sdk/demo/cli.py +46 -33
  42. hpcflow/sdk/helper/cli.py +18 -16
  43. hpcflow/sdk/helper/helper.py +75 -63
  44. hpcflow/sdk/helper/watcher.py +61 -28
  45. hpcflow/sdk/log.py +83 -59
  46. hpcflow/sdk/persistence/__init__.py +8 -31
  47. hpcflow/sdk/persistence/base.py +988 -586
  48. hpcflow/sdk/persistence/defaults.py +6 -0
  49. hpcflow/sdk/persistence/discovery.py +38 -0
  50. hpcflow/sdk/persistence/json.py +408 -153
  51. hpcflow/sdk/persistence/pending.py +158 -123
  52. hpcflow/sdk/persistence/store_resource.py +37 -22
  53. hpcflow/sdk/persistence/types.py +307 -0
  54. hpcflow/sdk/persistence/utils.py +14 -11
  55. hpcflow/sdk/persistence/zarr.py +477 -420
  56. hpcflow/sdk/runtime.py +44 -41
  57. hpcflow/sdk/submission/{jobscript_info.py → enums.py} +39 -12
  58. hpcflow/sdk/submission/jobscript.py +444 -404
  59. hpcflow/sdk/submission/schedulers/__init__.py +133 -40
  60. hpcflow/sdk/submission/schedulers/direct.py +97 -71
  61. hpcflow/sdk/submission/schedulers/sge.py +132 -126
  62. hpcflow/sdk/submission/schedulers/slurm.py +263 -268
  63. hpcflow/sdk/submission/schedulers/utils.py +7 -2
  64. hpcflow/sdk/submission/shells/__init__.py +14 -15
  65. hpcflow/sdk/submission/shells/base.py +102 -29
  66. hpcflow/sdk/submission/shells/bash.py +72 -55
  67. hpcflow/sdk/submission/shells/os_version.py +31 -30
  68. hpcflow/sdk/submission/shells/powershell.py +37 -29
  69. hpcflow/sdk/submission/submission.py +203 -257
  70. hpcflow/sdk/submission/types.py +143 -0
  71. hpcflow/sdk/typing.py +163 -12
  72. hpcflow/tests/conftest.py +8 -6
  73. hpcflow/tests/schedulers/slurm/test_slurm_submission.py +5 -2
  74. hpcflow/tests/scripts/test_main_scripts.py +60 -30
  75. hpcflow/tests/shells/wsl/test_wsl_submission.py +6 -4
  76. hpcflow/tests/unit/test_action.py +86 -75
  77. hpcflow/tests/unit/test_action_rule.py +9 -4
  78. hpcflow/tests/unit/test_app.py +13 -6
  79. hpcflow/tests/unit/test_cli.py +1 -1
  80. hpcflow/tests/unit/test_command.py +71 -54
  81. hpcflow/tests/unit/test_config.py +20 -15
  82. hpcflow/tests/unit/test_config_file.py +21 -18
  83. hpcflow/tests/unit/test_element.py +58 -62
  84. hpcflow/tests/unit/test_element_iteration.py +3 -1
  85. hpcflow/tests/unit/test_element_set.py +29 -19
  86. hpcflow/tests/unit/test_group.py +4 -2
  87. hpcflow/tests/unit/test_input_source.py +116 -93
  88. hpcflow/tests/unit/test_input_value.py +29 -24
  89. hpcflow/tests/unit/test_json_like.py +44 -35
  90. hpcflow/tests/unit/test_loop.py +65 -58
  91. hpcflow/tests/unit/test_object_list.py +17 -12
  92. hpcflow/tests/unit/test_parameter.py +16 -7
  93. hpcflow/tests/unit/test_persistence.py +48 -35
  94. hpcflow/tests/unit/test_resources.py +20 -18
  95. hpcflow/tests/unit/test_run.py +8 -3
  96. hpcflow/tests/unit/test_runtime.py +2 -1
  97. hpcflow/tests/unit/test_schema_input.py +23 -15
  98. hpcflow/tests/unit/test_shell.py +3 -2
  99. hpcflow/tests/unit/test_slurm.py +8 -7
  100. hpcflow/tests/unit/test_submission.py +39 -19
  101. hpcflow/tests/unit/test_task.py +352 -247
  102. hpcflow/tests/unit/test_task_schema.py +33 -20
  103. hpcflow/tests/unit/test_utils.py +9 -11
  104. hpcflow/tests/unit/test_value_sequence.py +15 -12
  105. hpcflow/tests/unit/test_workflow.py +114 -83
  106. hpcflow/tests/unit/test_workflow_template.py +0 -1
  107. hpcflow/tests/workflows/test_jobscript.py +2 -1
  108. hpcflow/tests/workflows/test_workflows.py +18 -13
  109. {hpcflow_new2-0.2.0a189.dist-info → hpcflow_new2-0.2.0a190.dist-info}/METADATA +2 -1
  110. hpcflow_new2-0.2.0a190.dist-info/RECORD +165 -0
  111. hpcflow/sdk/core/parallel.py +0 -21
  112. hpcflow_new2-0.2.0a189.dist-info/RECORD +0 -158
  113. {hpcflow_new2-0.2.0a189.dist-info → hpcflow_new2-0.2.0a190.dist-info}/LICENSE +0 -0
  114. {hpcflow_new2-0.2.0a189.dist-info → hpcflow_new2-0.2.0a190.dist-info}/WHEEL +0 -0
  115. {hpcflow_new2-0.2.0a189.dist-info → hpcflow_new2-0.2.0a190.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,8 @@
1
+ from __future__ import annotations
2
+ from collections.abc import Mapping
1
3
  from pathlib import Path
2
4
  import pytest
5
+ from typing import Any
3
6
 
4
7
  from hpcflow.app import app as hf
5
8
  from hpcflow.sdk.core.errors import (
@@ -24,137 +27,138 @@ def dummy_action_kwargs_pre_proc():
24
27
  return act_kwargs
25
28
 
26
29
 
27
- def test_action_equality(null_config):
30
+ def test_action_equality(null_config) -> None:
28
31
  a1 = hf.Action(commands=[hf.Command("ls")], environments=[])
29
32
  a2 = hf.Action(commands=[hf.Command("ls")], environments=[])
30
33
  assert a1 == a2
31
34
 
32
35
 
33
- def test_action_scope_to_string_any():
36
+ def test_action_scope_to_string_any() -> None:
34
37
  assert hf.ActionScope.any().to_string() == "any"
35
38
 
36
39
 
37
- def test_action_scope_to_string_main():
40
+ def test_action_scope_to_string_main() -> None:
38
41
  assert hf.ActionScope.main().to_string() == "main"
39
42
 
40
43
 
41
- def test_action_scope_to_string_processing():
44
+ def test_action_scope_to_string_processing() -> None:
42
45
  assert hf.ActionScope.processing().to_string() == "processing"
43
46
 
44
47
 
45
- def test_action_scope_to_string_input_file_generator_no_kwargs():
48
+ def test_action_scope_to_string_input_file_generator_no_kwargs() -> None:
46
49
  assert hf.ActionScope.input_file_generator().to_string() == "input_file_generator"
47
50
 
48
51
 
49
- def test_action_scope_to_string_output_file_parser_no_kwargs():
52
+ def test_action_scope_to_string_output_file_parser_no_kwargs() -> None:
50
53
  assert hf.ActionScope.output_file_parser().to_string() == "output_file_parser"
51
54
 
52
55
 
53
- def test_action_scope_to_string_input_file_generator_with_kwargs():
56
+ def test_action_scope_to_string_input_file_generator_with_kwargs() -> None:
54
57
  assert (
55
58
  hf.ActionScope.input_file_generator(file="file1").to_string()
56
59
  == "input_file_generator[file=file1]"
57
60
  )
58
61
 
59
62
 
60
- def test_action_scope_to_string_output_file_parser_with_kwargs():
63
+ def test_action_scope_to_string_output_file_parser_with_kwargs() -> None:
61
64
  assert (
62
65
  hf.ActionScope.output_file_parser(output="out1").to_string()
63
66
  == "output_file_parser[output=out1]"
64
67
  )
65
68
 
66
69
 
67
- def test_action_scope_class_method_init_scope_any():
70
+ def test_action_scope_class_method_init_scope_any() -> None:
68
71
  assert hf.ActionScope(typ=hf.ActionScopeType.ANY) == hf.ActionScope.any()
69
72
 
70
73
 
71
- def test_action_scope_class_method_init_scope_main():
74
+ def test_action_scope_class_method_init_scope_main() -> None:
72
75
  assert hf.ActionScope(typ=hf.ActionScopeType.MAIN) == hf.ActionScope.main()
73
76
 
74
77
 
75
- def test_action_scope_class_method_init_scope_processing():
78
+ def test_action_scope_class_method_init_scope_processing() -> None:
76
79
  assert (
77
80
  hf.ActionScope(typ=hf.ActionScopeType.PROCESSING) == hf.ActionScope.processing()
78
81
  )
79
82
 
80
83
 
81
- def test_action_scope_class_method_init_scope_input_file_generator_no_kwargs():
84
+ def test_action_scope_class_method_init_scope_input_file_generator_no_kwargs() -> None:
82
85
  assert (
83
86
  hf.ActionScope(typ=hf.ActionScopeType.INPUT_FILE_GENERATOR)
84
87
  == hf.ActionScope.input_file_generator()
85
88
  )
86
89
 
87
90
 
88
- def test_action_scope_class_method_init_scope_output_file_parser_no_kwargs():
91
+ def test_action_scope_class_method_init_scope_output_file_parser_no_kwargs() -> None:
89
92
  assert (
90
93
  hf.ActionScope(typ=hf.ActionScopeType.OUTPUT_FILE_PARSER)
91
94
  == hf.ActionScope.output_file_parser()
92
95
  )
93
96
 
94
97
 
95
- def test_action_scope_class_method_init_scope_input_file_generator_with_kwargs():
98
+ def test_action_scope_class_method_init_scope_input_file_generator_with_kwargs() -> None:
96
99
  assert hf.ActionScope(
97
100
  typ=hf.ActionScopeType.INPUT_FILE_GENERATOR, file="file1"
98
101
  ) == hf.ActionScope.input_file_generator(file="file1")
99
102
 
100
103
 
101
- def test_action_scope_class_method_init_scope_output_file_parser_with_kwargs():
104
+ def test_action_scope_class_method_init_scope_output_file_parser_with_kwargs() -> None:
102
105
  assert hf.ActionScope(
103
106
  typ=hf.ActionScopeType.OUTPUT_FILE_PARSER, output="out1"
104
107
  ) == hf.ActionScope.output_file_parser(output="out1")
105
108
 
106
109
 
107
- def test_action_scope_raise_on_unknown_kwargs_type_any():
110
+ def test_action_scope_raise_on_unknown_kwargs_type_any() -> None:
108
111
  with pytest.raises(TypeError):
109
112
  hf.ActionScope(typ=hf.ActionScopeType.ANY, bad="arg")
110
113
 
111
114
 
112
- def test_action_scope_raise_on_unknown_kwargs_type_main():
115
+ def test_action_scope_raise_on_unknown_kwargs_type_main() -> None:
113
116
  with pytest.raises(TypeError):
114
117
  hf.ActionScope(typ=hf.ActionScopeType.MAIN, bad="arg")
115
118
 
116
119
 
117
- def test_action_scope_raise_on_unknown_kwargs_type_processing():
120
+ def test_action_scope_raise_on_unknown_kwargs_type_processing() -> None:
118
121
  with pytest.raises(TypeError):
119
122
  hf.ActionScope(typ=hf.ActionScopeType.PROCESSING, bad="arg")
120
123
 
121
124
 
122
- def test_action_scope_raise_on_unknown_kwargs_type_input_file_generator():
125
+ def test_action_scope_raise_on_unknown_kwargs_type_input_file_generator() -> None:
123
126
  with pytest.raises(TypeError):
124
127
  hf.ActionScope(typ=hf.ActionScopeType.INPUT_FILE_GENERATOR, bad="arg")
125
128
 
126
129
 
127
- def test_action_scope_raise_on_unknown_kwargs_type_output_file_parser():
130
+ def test_action_scope_raise_on_unknown_kwargs_type_output_file_parser() -> None:
128
131
  with pytest.raises(TypeError):
129
132
  hf.ActionScope(typ=hf.ActionScopeType.OUTPUT_FILE_PARSER, bad="arg")
130
133
 
131
134
 
132
- def test_action_scope_no_raise_on_good_kwargs_type_input_file_generator():
135
+ def test_action_scope_no_raise_on_good_kwargs_type_input_file_generator() -> None:
133
136
  hf.ActionScope(typ=hf.ActionScopeType.INPUT_FILE_GENERATOR, file="file1")
134
137
 
135
138
 
136
- def test_action_scope_no_raise_on_good_kwargs_type_output_file_parser():
139
+ def test_action_scope_no_raise_on_good_kwargs_type_output_file_parser() -> None:
137
140
  hf.ActionScope(typ=hf.ActionScopeType.OUTPUT_FILE_PARSER, output="out1")
138
141
 
139
142
 
140
- def test_action_scope_no_raise_on_no_kwargs_type_input_file_generator():
143
+ def test_action_scope_no_raise_on_no_kwargs_type_input_file_generator() -> None:
141
144
  hf.ActionScope(typ=hf.ActionScopeType.INPUT_FILE_GENERATOR)
142
145
 
143
146
 
144
- def test_action_scope_no_raise_on_no_kwargs_type_output_file_parser():
147
+ def test_action_scope_no_raise_on_no_kwargs_type_output_file_parser() -> None:
145
148
  hf.ActionScope(typ=hf.ActionScopeType.OUTPUT_FILE_PARSER)
146
149
 
147
150
 
148
- def test_action_scope_json_like_round_trip():
151
+ def test_action_scope_json_like_round_trip() -> None:
149
152
  as1 = hf.ActionScope.input_file_generator(file="file1")
150
153
  js, _ = as1.to_json_like()
154
+ assert isinstance(js, Mapping)
151
155
  as1_rl = hf.ActionScope.from_json_like(js)
152
156
  assert as1 == as1_rl
153
157
 
154
158
 
155
- def test_action_scope_from_json_like_string_and_dict_equality():
159
+ def test_action_scope_from_json_like_string_and_dict_equality() -> None:
156
160
  as1_js = "input_file_generator[file=file1]"
157
- as2_js = {
161
+ as2_js: Mapping[str, Any] = {
158
162
  "type": "input_file_generator",
159
163
  "kwargs": {
160
164
  "file": "file1",
@@ -163,67 +167,67 @@ def test_action_scope_from_json_like_string_and_dict_equality():
163
167
  assert hf.ActionScope.from_json_like(as1_js) == hf.ActionScope.from_json_like(as2_js)
164
168
 
165
169
 
166
- def test_get_command_input_types_sub_parameters_true_no_sub_parameter():
170
+ def test_get_command_input_types_sub_parameters_true_no_sub_parameter() -> None:
167
171
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1>> + 100)")])
168
172
  assert act.get_command_input_types(sub_parameters=True) == ("p1",)
169
173
 
170
174
 
171
- def test_get_command_input_types_sub_parameters_true_with_sub_parameter():
175
+ def test_get_command_input_types_sub_parameters_true_with_sub_parameter() -> None:
172
176
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1.a>> + 100)")])
173
177
  assert act.get_command_input_types(sub_parameters=True) == ("p1.a",)
174
178
 
175
179
 
176
- def test_get_command_input_types_sub_parameters_false_no_sub_parameter():
180
+ def test_get_command_input_types_sub_parameters_false_no_sub_parameter() -> None:
177
181
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1>> + 100)")])
178
182
  assert act.get_command_input_types(sub_parameters=False) == ("p1",)
179
183
 
180
184
 
181
- def test_get_command_input_types_sub_parameters_false_with_sub_parameter():
185
+ def test_get_command_input_types_sub_parameters_false_with_sub_parameter() -> None:
182
186
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1.a>> + 100)")])
183
187
  assert act.get_command_input_types(sub_parameters=False) == ("p1",)
184
188
 
185
189
 
186
- def test_get_command_input_types_sum_sub_parameters_true_no_sub_param():
190
+ def test_get_command_input_types_sum_sub_parameters_true_no_sub_param() -> None:
187
191
  act = hf.Action(commands=[hf.Command("Write-Output <<sum(parameter:p1)>>")])
188
192
  assert act.get_command_input_types(sub_parameters=True) == ("p1",)
189
193
 
190
194
 
191
- def test_get_command_input_types_sum_sub_parameters_true_with_sub_parameter():
195
+ def test_get_command_input_types_sum_sub_parameters_true_with_sub_parameter() -> None:
192
196
  act = hf.Action(commands=[hf.Command("Write-Output <<sum(parameter:p1.a)>>")])
193
197
  assert act.get_command_input_types(sub_parameters=True) == ("p1.a",)
194
198
 
195
199
 
196
- def test_get_command_input_types_sum_sub_parameters_false_no_sub_param():
200
+ def test_get_command_input_types_sum_sub_parameters_false_no_sub_param() -> None:
197
201
  act = hf.Action(commands=[hf.Command("Write-Output <<sum(parameter:p1)>>")])
198
202
  assert act.get_command_input_types(sub_parameters=False) == ("p1",)
199
203
 
200
204
 
201
- def test_get_command_input_types_sum_sub_parameters_false_with_sub_parameter():
205
+ def test_get_command_input_types_sum_sub_parameters_false_with_sub_parameter() -> None:
202
206
  act = hf.Action(commands=[hf.Command("Write-Output <<sum(parameter:p1.a)>>")])
203
207
  assert act.get_command_input_types(sub_parameters=False) == ("p1",)
204
208
 
205
209
 
206
- def test_get_command_input_types_label_sub_parameters_true_no_sub_param():
210
+ def test_get_command_input_types_label_sub_parameters_true_no_sub_param() -> None:
207
211
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1[one]>> + 100)")])
208
212
  assert act.get_command_input_types(sub_parameters=True) == ("p1[one]",)
209
213
 
210
214
 
211
- def test_get_command_input_types_label_sub_parameters_true_with_sub_parameter():
215
+ def test_get_command_input_types_label_sub_parameters_true_with_sub_parameter() -> None:
212
216
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1[one].a>> + 100)")])
213
217
  assert act.get_command_input_types(sub_parameters=True) == ("p1[one].a",)
214
218
 
215
219
 
216
- def test_get_command_input_types_label_sub_parameters_false_no_sub_param():
220
+ def test_get_command_input_types_label_sub_parameters_false_no_sub_param() -> None:
217
221
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1[one]>> + 100)")])
218
222
  assert act.get_command_input_types(sub_parameters=False) == ("p1[one]",)
219
223
 
220
224
 
221
- def test_get_command_input_types_label_sub_parameters_false_with_sub_parameter():
225
+ def test_get_command_input_types_label_sub_parameters_false_with_sub_parameter() -> None:
222
226
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1[one].a>> + 100)")])
223
227
  assert act.get_command_input_types(sub_parameters=False) == ("p1[one]",)
224
228
 
225
229
 
226
- def test_get_script_name(null_config):
230
+ def test_get_script_name(null_config) -> None:
227
231
  expected = {
228
232
  "<<script:/software/hello.py>>": "hello.py",
229
233
  "<<script:software/hello.py>>": "hello.py",
@@ -234,7 +238,7 @@ def test_get_script_name(null_config):
234
238
  assert hf.Action.get_script_name(k) == v
235
239
 
236
240
 
237
- def test_is_snippet_script(null_config):
241
+ def test_is_snippet_script(null_config) -> None:
238
242
  expected = {
239
243
  "<<script:/software/hello.py>>": True,
240
244
  "<<script:software/hello.py>>": True,
@@ -245,7 +249,7 @@ def test_is_snippet_script(null_config):
245
249
  assert hf.Action.is_snippet_script(k) == v
246
250
 
247
251
 
248
- def test_get_snippet_script_path(null_config):
252
+ def test_get_snippet_script_path(null_config) -> None:
249
253
  expected = {
250
254
  "<<script:/software/hello.py>>": Path("/software/hello.py"),
251
255
  "<<script:software/hello.py>>": Path("software/hello.py"),
@@ -255,17 +259,17 @@ def test_get_snippet_script_path(null_config):
255
259
  assert hf.Action.get_snippet_script_path(k) == v
256
260
 
257
261
 
258
- def test_get_snippet_script_path_False(null_config):
262
+ def test_get_snippet_script_path_False(null_config) -> None:
259
263
  assert not hf.Action.get_snippet_script_path("/path/to/script.py")
260
264
 
261
265
 
262
- def test_process_script_data_in_str(null_config):
266
+ def test_process_script_data_in_str(null_config) -> None:
263
267
  act = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
264
268
  ts = hf.TaskSchema(objective="ts1", inputs=[hf.SchemaInput("p1")], actions=[act])
265
269
  assert ts.actions[0].script_data_in == {"p1": {"format": "json"}}
266
270
 
267
271
 
268
- def test_process_script_data_in_str_dict_equivalence(null_config):
272
+ def test_process_script_data_in_str_dict_equivalence(null_config) -> None:
269
273
  act_1 = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
270
274
  act_2 = hf.Action(
271
275
  script="<<script:path/to/some/script>>", script_data_in={"p1": "json"}
@@ -277,7 +281,7 @@ def test_process_script_data_in_str_dict_equivalence(null_config):
277
281
  assert ts_1.actions[0].script_data_in == ts_2.actions[0].script_data_in
278
282
 
279
283
 
280
- def test_process_script_data_in_str_multi(null_config):
284
+ def test_process_script_data_in_str_multi(null_config) -> None:
281
285
  act = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
282
286
  ts = hf.TaskSchema(
283
287
  objective="ts1",
@@ -290,7 +294,7 @@ def test_process_script_data_in_str_multi(null_config):
290
294
  }
291
295
 
292
296
 
293
- def test_process_script_data_in_str_labelled_single(null_config):
297
+ def test_process_script_data_in_str_labelled_single(null_config) -> None:
294
298
  act = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
295
299
  ts = hf.TaskSchema(
296
300
  objective="ts1",
@@ -300,7 +304,7 @@ def test_process_script_data_in_str_labelled_single(null_config):
300
304
  assert ts.actions[0].script_data_in == {"p1": {"format": "json"}}
301
305
 
302
306
 
303
- def test_process_script_data_in_str_labelled_multiple(null_config):
307
+ def test_process_script_data_in_str_labelled_multiple(null_config) -> None:
304
308
  act = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
305
309
  ts = hf.TaskSchema(
306
310
  objective="ts1",
@@ -310,7 +314,7 @@ def test_process_script_data_in_str_labelled_multiple(null_config):
310
314
  assert ts.actions[0].script_data_in == {"p1[one]": {"format": "json"}}
311
315
 
312
316
 
313
- def test_process_script_data_in_dict_all_str_equivalence(null_config):
317
+ def test_process_script_data_in_dict_all_str_equivalence(null_config) -> None:
314
318
  act_1 = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
315
319
  act_2 = hf.Action(
316
320
  script="<<script:path/to/some/script>>", script_data_in={"*": "json"}
@@ -322,7 +326,7 @@ def test_process_script_data_in_dict_all_str_equivalence(null_config):
322
326
  assert ts_1.actions[0].script_data_in == ts_2.actions[0].script_data_in
323
327
 
324
328
 
325
- def test_process_script_data_in_dict_all_str_equivalence_multi(null_config):
329
+ def test_process_script_data_in_dict_all_str_equivalence_multi(null_config) -> None:
326
330
  act_1 = hf.Action(script="<<script:path/to/some/script>>", script_data_in="json")
327
331
  act_2 = hf.Action(
328
332
  script="<<script:path/to/some/script>>", script_data_in={"*": "json"}
@@ -342,7 +346,7 @@ def test_process_script_data_in_dict_all_str_equivalence_multi(null_config):
342
346
  assert ts_1.actions[0].script_data_in == ts_2.actions[0].script_data_in
343
347
 
344
348
 
345
- def test_process_script_data_in_dict_mixed(null_config):
349
+ def test_process_script_data_in_dict_mixed(null_config) -> None:
346
350
  act = hf.Action(
347
351
  script="<<script:path/to/some/script>>",
348
352
  script_data_in={"p1": "json", "p2": "hdf5"},
@@ -358,7 +362,7 @@ def test_process_script_data_in_dict_mixed(null_config):
358
362
  }
359
363
 
360
364
 
361
- def test_process_script_data_in_dict_mixed_all(null_config):
365
+ def test_process_script_data_in_dict_mixed_all(null_config) -> None:
362
366
  act = hf.Action(
363
367
  script="<<script:path/to/some/script>>",
364
368
  script_data_in={"p1": "json", "*": "hdf5"},
@@ -379,7 +383,7 @@ def test_process_script_data_in_dict_mixed_all(null_config):
379
383
  }
380
384
 
381
385
 
382
- def test_process_script_data_in_dict_labels_multiple(null_config):
386
+ def test_process_script_data_in_dict_labels_multiple(null_config) -> None:
383
387
  act = hf.Action(
384
388
  script="<<script:path/to/some/script>>",
385
389
  script_data_in={"p1[one]": "json"},
@@ -394,7 +398,7 @@ def test_process_script_data_in_dict_labels_multiple(null_config):
394
398
  assert ts.actions[0].script_data_in == {"p1[one]": {"format": "json"}}
395
399
 
396
400
 
397
- def test_process_script_data_in_dict_labels_multiple_two(null_config):
401
+ def test_process_script_data_in_dict_labels_multiple_two(null_config) -> None:
398
402
  act = hf.Action(
399
403
  script="<<script:path/to/some/script>>",
400
404
  script_data_in={"p1[one]": "json", "p1[two]": "hdf5"},
@@ -412,7 +416,7 @@ def test_process_script_data_in_dict_labels_multiple_two(null_config):
412
416
  }
413
417
 
414
418
 
415
- def test_process_script_data_in_dict_labels_multiple_two_catch_all(null_config):
419
+ def test_process_script_data_in_dict_labels_multiple_two_catch_all(null_config) -> None:
416
420
  act = hf.Action(
417
421
  script="<<script:path/to/some/script>>",
418
422
  script_data_in={"p1[one]": "json", "*": "hdf5"},
@@ -430,7 +434,7 @@ def test_process_script_data_in_dict_labels_multiple_two_catch_all(null_config):
430
434
  }
431
435
 
432
436
 
433
- def test_process_script_data_in_dict_excluded(null_config):
437
+ def test_process_script_data_in_dict_excluded(null_config) -> None:
434
438
  act = hf.Action(
435
439
  script="<<script:path/to/some/script>>",
436
440
  script_data_in={"p1": "json"},
@@ -446,7 +450,7 @@ def test_process_script_data_in_dict_excluded(null_config):
446
450
  assert ts.actions[0].script_data_in == {"p1": {"format": "json"}}
447
451
 
448
452
 
449
- def test_process_script_data_in_dict_unlabelled_to_labelled(null_config):
453
+ def test_process_script_data_in_dict_unlabelled_to_labelled(null_config) -> None:
450
454
  act = hf.Action(
451
455
  script="<<script:path/to/some/script>>",
452
456
  script_data_in={"p1": "json"},
@@ -464,7 +468,9 @@ def test_process_script_data_in_dict_unlabelled_to_labelled(null_config):
464
468
  }
465
469
 
466
470
 
467
- def test_process_script_data_in_dict_unlabelled_to_labelled_with_mixed_label(null_config):
471
+ def test_process_script_data_in_dict_unlabelled_to_labelled_with_mixed_label(
472
+ null_config,
473
+ ) -> None:
468
474
  act = hf.Action(
469
475
  script="<<script:path/to/some/script>>",
470
476
  script_data_in={"p1": "json", "p1[two]": "hdf5"},
@@ -482,7 +488,7 @@ def test_process_script_data_in_dict_unlabelled_to_labelled_with_mixed_label(nul
482
488
  }
483
489
 
484
490
 
485
- def test_process_script_data_in_dict_labelled_mixed_catch_all(null_config):
491
+ def test_process_script_data_in_dict_labelled_mixed_catch_all(null_config) -> None:
486
492
  act = hf.Action(
487
493
  script="<<script:path/to/some/script>>",
488
494
  script_data_in={"p1[one]": "json", "*": "hdf5"},
@@ -500,7 +506,9 @@ def test_process_script_data_in_dict_labelled_mixed_catch_all(null_config):
500
506
  }
501
507
 
502
508
 
503
- def test_process_script_data_in_dict_unlabelled_to_labelled_mixed_catch_all(null_config):
509
+ def test_process_script_data_in_dict_unlabelled_to_labelled_mixed_catch_all(
510
+ null_config,
511
+ ) -> None:
504
512
  act = hf.Action(
505
513
  script="<<script:path/to/some/script>>",
506
514
  script_data_in={"p1": "json", "*": "hdf5"},
@@ -520,7 +528,7 @@ def test_process_script_data_in_dict_unlabelled_to_labelled_mixed_catch_all(null
520
528
  }
521
529
 
522
530
 
523
- def test_process_script_data_in_str_raise_invalid_format(null_config):
531
+ def test_process_script_data_in_str_raise_invalid_format(null_config) -> None:
524
532
  act = hf.Action(
525
533
  script="<<script:path/to/some/script>>", script_data_in="some_weird_format"
526
534
  )
@@ -532,7 +540,7 @@ def test_process_script_data_in_str_raise_invalid_format(null_config):
532
540
  )
533
541
 
534
542
 
535
- def test_process_script_data_in_dict_raise_invalid_parameter(null_config):
543
+ def test_process_script_data_in_dict_raise_invalid_parameter(null_config) -> None:
536
544
  act = hf.Action(
537
545
  script="<<script:path/to/some/script>>",
538
546
  script_data_in={"p2": "json"},
@@ -545,7 +553,9 @@ def test_process_script_data_in_dict_raise_invalid_parameter(null_config):
545
553
  )
546
554
 
547
555
 
548
- def test_process_script_data_in_dict_raise_invalid_parameter_unknown_label(null_config):
556
+ def test_process_script_data_in_dict_raise_invalid_parameter_unknown_label(
557
+ null_config,
558
+ ) -> None:
549
559
  act = hf.Action(
550
560
  script="<<script:path/to/some/script>>",
551
561
  script_data_in={"p1[two]": "json"},
@@ -558,10 +568,11 @@ def test_process_script_data_in_dict_raise_invalid_parameter_unknown_label(null_
558
568
  )
559
569
 
560
570
 
561
- def test_process_script_data_in_dict_raise_invalid_script_key(null_config):
571
+ def test_process_script_data_in_dict_raise_invalid_script_key(null_config) -> None:
572
+ bad_script_data: Any = {"p1": {"format": "json", "BAD_KEY": 1}}
562
573
  act = hf.Action(
563
574
  script="<<script:path/to/some/script>>",
564
- script_data_in={"p1": {"format": "json", "BAD_KEY": 1}},
575
+ script_data_in=bad_script_data,
565
576
  )
566
577
  with pytest.raises(UnknownScriptDataKey):
567
578
  hf.TaskSchema(
@@ -571,7 +582,7 @@ def test_process_script_data_in_dict_raise_invalid_script_key(null_config):
571
582
  )
572
583
 
573
584
 
574
- def test_process_script_data_out_mixed(null_config):
585
+ def test_process_script_data_out_mixed(null_config) -> None:
575
586
  act = hf.Action(
576
587
  script="<<script:path/to/some/script>>",
577
588
  script_data_in="json",
@@ -589,7 +600,7 @@ def test_process_script_data_out_mixed(null_config):
589
600
  }
590
601
 
591
602
 
592
- def test_process_script_data_in_fmt_dict_mixed(null_config):
603
+ def test_process_script_data_in_fmt_dict_mixed(null_config) -> None:
593
604
  act = hf.Action(
594
605
  script="<<script:path/to/some/script>>",
595
606
  script_data_in={"p1": {"format": "json"}, "p2": "hdf5"},
@@ -605,22 +616,22 @@ def test_process_script_data_in_fmt_dict_mixed(null_config):
605
616
  }
606
617
 
607
618
 
608
- def test_ActionEnvironment_env_str(null_config):
619
+ def test_ActionEnvironment_env_str(null_config) -> None:
609
620
  act_env = hf.ActionEnvironment(environment="my_env")
610
621
  assert act_env.environment == {"name": "my_env"}
611
622
 
612
623
 
613
- def test_ActionEnvironment_env_dict(null_config):
624
+ def test_ActionEnvironment_env_dict(null_config) -> None:
614
625
  act_env = hf.ActionEnvironment(environment={"name": "my_env", "key": "value"})
615
626
  assert act_env.environment == {"name": "my_env", "key": "value"}
616
627
 
617
628
 
618
- def test_ActionEnvironment_raises_on_missing_name(null_config):
629
+ def test_ActionEnvironment_raises_on_missing_name(null_config) -> None:
619
630
  with pytest.raises(ActionEnvironmentMissingNameError):
620
631
  hf.ActionEnvironment(environment={"key": "value"})
621
632
 
622
633
 
623
- def test_rules_allow_runs_initialised(null_config, tmp_path):
634
+ def test_rules_allow_runs_initialised(null_config, tmp_path: Path):
624
635
  """Test rules that do not depend on execution allow for runs to be initialised."""
625
636
  act = hf.Action(
626
637
  script="<<script:path/to/some/script>>",
@@ -645,7 +656,7 @@ def test_rules_allow_runs_initialised(null_config, tmp_path):
645
656
  assert len(wk.tasks[0].elements[1].actions) == 0
646
657
 
647
658
 
648
- def test_rules_prevent_runs_initialised(null_config, tmp_path):
659
+ def test_rules_prevent_runs_initialised(null_config, tmp_path: Path):
649
660
  """Test rules that depend on execution prevent initialising runs."""
650
661
  act1 = hf.Action(script="<<script:path/to/some/script>>")
651
662
  act2 = hf.Action(
@@ -674,7 +685,7 @@ def test_rules_prevent_runs_initialised(null_config, tmp_path):
674
685
  assert not wk.tasks[1].elements[0].iterations[0].EARs_initialised
675
686
 
676
687
 
677
- def test_command_rules_allow_runs_initialised(null_config, tmp_path):
688
+ def test_command_rules_allow_runs_initialised(null_config, tmp_path: Path):
678
689
  """Test command rules that do not depend on execution allow for runs to be
679
690
  initialised."""
680
691
  act = hf.Action(
@@ -706,7 +717,7 @@ def test_command_rules_allow_runs_initialised(null_config, tmp_path):
706
717
  assert len(wk.tasks[0].elements[1].action_runs[0].commands_idx) == 0
707
718
 
708
719
 
709
- def test_command_rules_prevent_runs_initialised(null_config, tmp_path):
720
+ def test_command_rules_prevent_runs_initialised(null_config, tmp_path: Path):
710
721
  """Test command rules that do depend on execution prevent runs being initialised."""
711
722
  act1 = hf.Action(
712
723
  commands=[
@@ -745,7 +756,7 @@ def test_command_rules_prevent_runs_initialised(null_config, tmp_path):
745
756
 
746
757
 
747
758
  def test_command_rules_prevent_runs_initialised_with_valid_action_rules(
748
- null_config, tmp_path
759
+ null_config, tmp_path: Path
749
760
  ):
750
761
  """Test command rules that do depend on execution prevent runs being initialised, even
751
762
  when the parent action rules can be tested and are valid."""
@@ -1,16 +1,21 @@
1
+ from __future__ import annotations
2
+ from typing import cast, TYPE_CHECKING
1
3
  from hpcflow.app import app as hf
2
4
 
5
+ if TYPE_CHECKING:
6
+ from hpcflow.sdk.core.types import RuleArgs
3
7
 
4
- def test_equivalent_init_with_rule_args():
5
- rule_args = {
8
+
9
+ def test_equivalent_init_with_rule_args() -> None:
10
+ rule_args: RuleArgs = {
6
11
  "path": "resources.os_name",
7
12
  "condition": {"value.equal_to": "posix"},
8
13
  }
9
14
  assert hf.ActionRule(rule=hf.Rule(**rule_args)) == hf.ActionRule(**rule_args)
10
15
 
11
16
 
12
- def test_equivalent_init_json_like_with_rule_args():
13
- rule_args = {
17
+ def test_equivalent_init_json_like_with_rule_args() -> None:
18
+ rule_args: dict = {
14
19
  "path": "resources.os_name",
15
20
  "condition": {"value.equal_to": "posix"},
16
21
  }
@@ -1,37 +1,44 @@
1
+ from __future__ import annotations
1
2
  import sys
3
+ from typing import TYPE_CHECKING
2
4
  import pytest
3
5
  import requests
4
6
 
5
7
  from hpcflow.app import app as hf
6
8
 
9
+ if TYPE_CHECKING:
10
+ from hpcflow.sdk.core.actions import Action, ActionEnvironment
11
+
7
12
 
8
13
  @pytest.fixture
9
- def act_env_1():
14
+ def act_env_1() -> ActionEnvironment:
10
15
  return hf.ActionEnvironment(environment="env_1")
11
16
 
12
17
 
13
18
  @pytest.fixture
14
- def act_1(act_env_1):
19
+ def act_1(act_env_1) -> Action:
15
20
  return hf.Action(
16
21
  commands=[hf.Command("<<parameter:p1>>")],
17
22
  environments=[act_env_1],
18
23
  )
19
24
 
20
25
 
21
- def test_shared_data_from_json_like_with_shared_data_dependency(act_1):
26
+ def test_shared_data_from_json_like_with_shared_data_dependency(act_1: Action):
22
27
  """Check we can generate some shared data objects where one depends on another."""
23
28
 
24
29
  p1 = hf.Parameter("p1")
25
30
  p1._set_hash()
26
31
  p1_hash = p1._hash_value
32
+ assert p1_hash is not None
27
33
 
28
34
  ts1 = hf.TaskSchema(objective="ts1", actions=[act_1], inputs=[p1])
29
35
  ts1._set_hash()
30
36
  ts1_hash = ts1._hash_value
37
+ assert ts1_hash is not None
31
38
 
32
39
  env_label = ts1.actions[0].environments[0].environment
33
40
 
34
- shared_data_json = {
41
+ shared_data_json: dict[str, dict] = {
35
42
  "parameters": {
36
43
  p1_hash: {
37
44
  "is_file": p1.is_file,
@@ -85,7 +92,7 @@ def test_shared_data_from_json_like_with_shared_data_dependency(act_1):
85
92
  ] == hf.TaskSchemasList([ts1])
86
93
 
87
94
 
88
- def test_get_demo_data_manifest(null_config):
95
+ def test_get_demo_data_manifest(null_config) -> None:
89
96
  hf.get_demo_data_files_manifest()
90
97
 
91
98
 
@@ -97,7 +104,7 @@ def test_get_demo_data_manifest(null_config):
97
104
  "retrieving demo data from GitHub."
98
105
  ),
99
106
  )
100
- def test_get_demo_data_cache(null_config):
107
+ def test_get_demo_data_cache(null_config) -> None:
101
108
  hf.clear_demo_data_cache_dir()
102
109
  hf.cache_demo_data_file("text_file.txt")
103
110
  with hf.demo_data_cache_dir.joinpath("text_file.txt").open("rt") as fh:
@@ -6,7 +6,7 @@ from hpcflow import __version__
6
6
  from hpcflow.app import app as hf
7
7
 
8
8
 
9
- def test_version():
9
+ def test_version() -> None:
10
10
  runner = CliRunner()
11
11
  result = runner.invoke(hf.cli, args="--version")
12
12
  assert result.output.strip() == f"hpcFlow, version {__version__}"