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,4 +1,5 @@
1
- import re
1
+ from __future__ import annotations
2
+ from pathlib import Path
2
3
  import numpy as np
3
4
  import pytest
4
5
  from hpcflow.app import app as hf
@@ -9,7 +10,7 @@ from hpcflow.sdk.core.test_utils import (
9
10
  )
10
11
 
11
12
 
12
- def test_get_command_line(null_config, tmp_path):
13
+ def test_get_command_line(null_config, tmp_path: Path):
13
14
  s1 = hf.TaskSchema(
14
15
  objective="t1",
15
16
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"))],
@@ -40,7 +41,9 @@ def test_get_command_line(null_config, tmp_path):
40
41
 
41
42
 
42
43
  @pytest.mark.parametrize("shell_args", [("powershell", "nt"), ("bash", "posix")])
43
- def test_get_command_line_with_stdout(null_config, tmp_path, shell_args):
44
+ def test_get_command_line_with_stdout(
45
+ null_config, tmp_path: Path, shell_args: tuple[str, str]
46
+ ):
44
47
  s1 = hf.TaskSchema(
45
48
  objective="t1",
46
49
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"))],
@@ -76,7 +79,7 @@ def test_get_command_line_with_stdout(null_config, tmp_path, shell_args):
76
79
  assert cmd_str == f"parameter_p2=`Write-Output ({p1_value} + 100)`"
77
80
 
78
81
 
79
- def test_get_command_line_single_labelled_input(null_config, tmp_path):
82
+ def test_get_command_line_single_labelled_input(null_config, tmp_path: Path):
80
83
  s1 = hf.TaskSchema(
81
84
  objective="t1",
82
85
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"), labels={"one": {}})],
@@ -108,7 +111,7 @@ def test_get_command_line_single_labelled_input(null_config, tmp_path):
108
111
  assert cmd_str == f"Write-Output ({p1_value} + 100)"
109
112
 
110
113
 
111
- def test_get_command_line_multiple_labelled_input(null_config, tmp_path):
114
+ def test_get_command_line_multiple_labelled_input(null_config, tmp_path: Path):
112
115
  s1 = hf.TaskSchema(
113
116
  objective="t1",
114
117
  inputs=[
@@ -151,7 +154,7 @@ def test_get_command_line_multiple_labelled_input(null_config, tmp_path):
151
154
  assert cmd_str == f"Write-Output ({p1_one_value} + {p1_two_value} + 100)"
152
155
 
153
156
 
154
- def test_get_command_line_sub_parameter(null_config, tmp_path):
157
+ def test_get_command_line_sub_parameter(null_config, tmp_path: Path):
155
158
  s1 = hf.TaskSchema(
156
159
  objective="t1",
157
160
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"))],
@@ -181,7 +184,7 @@ def test_get_command_line_sub_parameter(null_config, tmp_path):
181
184
  assert cmd_str == f"Write-Output ({p1_value['a']} + 100)"
182
185
 
183
186
 
184
- def test_get_command_line_sum(null_config, tmp_path):
187
+ def test_get_command_line_sum(null_config, tmp_path: Path):
185
188
  s1 = hf.TaskSchema(
186
189
  objective="t1",
187
190
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"))],
@@ -208,7 +211,7 @@ def test_get_command_line_sum(null_config, tmp_path):
208
211
  assert cmd_str == f"Write-Output ({sum(p1_value)} + 100)"
209
212
 
210
213
 
211
- def test_get_command_line_join(null_config, tmp_path):
214
+ def test_get_command_line_join(null_config, tmp_path: Path):
212
215
  delim = ","
213
216
  s1 = hf.TaskSchema(
214
217
  objective="t1",
@@ -238,7 +241,7 @@ def test_get_command_line_join(null_config, tmp_path):
238
241
  assert cmd_str == f"Write-Output ({delim.join(str(i) for i in p1_value)} + 100)"
239
242
 
240
243
 
241
- def test_get_command_line_sum_sub_data(null_config, tmp_path):
244
+ def test_get_command_line_sum_sub_data(null_config, tmp_path: Path):
242
245
  s1 = hf.TaskSchema(
243
246
  objective="t1",
244
247
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1"))],
@@ -295,7 +298,7 @@ def test_get_command_line_join_sub_data(null_config, tmp_path):
295
298
  assert cmd_str == f"Write-Output ({delim.join(str(i) for i in p1_value['a'])} + 100)"
296
299
 
297
300
 
298
- def test_get_command_line_parameter_value(null_config, tmp_path):
301
+ def test_get_command_line_parameter_value(null_config, tmp_path: Path):
299
302
  s1 = hf.TaskSchema(
300
303
  objective="t1",
301
304
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1c"))],
@@ -325,7 +328,7 @@ def test_get_command_line_parameter_value(null_config, tmp_path):
325
328
  assert cmd_str == f"Write-Output ({p1_value.a} + 100)"
326
329
 
327
330
 
328
- def test_get_command_line_parameter_value_join(null_config, tmp_path):
331
+ def test_get_command_line_parameter_value_join(null_config, tmp_path: Path):
329
332
  delim = ","
330
333
  cmd = (
331
334
  f"Write-Output "
@@ -349,14 +352,16 @@ def test_get_command_line_parameter_value_join(null_config, tmp_path):
349
352
  path=tmp_path,
350
353
  template_name="wk0",
351
354
  )
352
- run = wk.tasks.t1.elements[0].iterations[0].action_runs[0]
353
- cmd = run.action.commands[0]
355
+ t1 = wk.tasks.t1
356
+ assert isinstance(t1, hf.WorkflowTask)
357
+ run = t1.elements[0].iterations[0].action_runs[0]
358
+ command = run.action.commands[0]
354
359
  shell = ALL_SHELLS["powershell"]["nt"]()
355
- cmd_str, _ = cmd.get_command_line(EAR=run, shell=shell, env=run.get_environment())
360
+ cmd_str, _ = command.get_command_line(EAR=run, shell=shell, env=run.get_environment())
356
361
  assert cmd_str == f"Write-Output 4,4,4,4"
357
362
 
358
363
 
359
- def test_get_command_line_parameter_value_custom_method(null_config, tmp_path):
364
+ def test_get_command_line_parameter_value_custom_method(null_config, tmp_path: Path):
360
365
  s1 = hf.TaskSchema(
361
366
  objective="t1",
362
367
  inputs=[hf.SchemaInput(parameter=hf.Parameter("p1c"))],
@@ -386,7 +391,9 @@ def test_get_command_line_parameter_value_custom_method(null_config, tmp_path):
386
391
  assert cmd_str == f"Write-Output ({p1_value.a + 4} + 100)"
387
392
 
388
393
 
389
- def test_get_command_line_parameter_value_custom_method_with_args(null_config, tmp_path):
394
+ def test_get_command_line_parameter_value_custom_method_with_args(
395
+ null_config, tmp_path: Path
396
+ ):
390
397
  add_val = 35
391
398
  s1 = hf.TaskSchema(
392
399
  objective="t1",
@@ -409,7 +416,9 @@ def test_get_command_line_parameter_value_custom_method_with_args(null_config, t
409
416
  template_name="wk0",
410
417
  overwrite=True,
411
418
  )
412
- run = wk.tasks.t1.elements[0].iterations[0].action_runs[0]
419
+ t1 = wk.tasks.t1
420
+ assert isinstance(t1, hf.WorkflowTask)
421
+ run = t1.elements[0].iterations[0].action_runs[0]
413
422
  cmd = run.action.commands[0]
414
423
  shell = ALL_SHELLS["powershell"]["nt"]()
415
424
  cmd_str, _ = cmd.get_command_line(EAR=run, shell=shell, env=run.get_environment())
@@ -418,7 +427,7 @@ def test_get_command_line_parameter_value_custom_method_with_args(null_config, t
418
427
 
419
428
 
420
429
  def test_get_command_line_parameter_value_custom_method_with_two_args(
421
- null_config, tmp_path
430
+ null_config, tmp_path: Path
422
431
  ):
423
432
  add_val = 35
424
433
  sub_val = 10
@@ -439,15 +448,17 @@ def test_get_command_line_parameter_value_custom_method_with_two_args(
439
448
  template_name="wk0",
440
449
  overwrite=True,
441
450
  )
442
- run = wk.tasks.t1.elements[0].iterations[0].action_runs[0]
443
- cmd = run.action.commands[0]
451
+ t1 = wk.tasks.t1
452
+ assert isinstance(t1, hf.WorkflowTask)
453
+ run = t1.elements[0].iterations[0].action_runs[0]
454
+ command = run.action.commands[0]
444
455
  shell = ALL_SHELLS["powershell"]["nt"]()
445
- cmd_str, _ = cmd.get_command_line(EAR=run, shell=shell, env=run.get_environment())
456
+ cmd_str, _ = command.get_command_line(EAR=run, shell=shell, env=run.get_environment())
446
457
 
447
458
  assert cmd_str == f"Write-Output ({p1_value.a + add_val - sub_val} + 100)"
448
459
 
449
460
 
450
- def test_get_command_line_parameter_value_sub_object(null_config, tmp_path):
461
+ def test_get_command_line_parameter_value_sub_object(null_config, tmp_path: Path):
451
462
  cmd = f"Write-Output (<<parameter:p1c.sub_param>> + 100)"
452
463
  s1 = hf.TaskSchema(
453
464
  objective="t1",
@@ -462,15 +473,18 @@ def test_get_command_line_parameter_value_sub_object(null_config, tmp_path):
462
473
  template_name="wk0",
463
474
  overwrite=True,
464
475
  )
465
- run = wk.tasks.t1.elements[0].iterations[0].action_runs[0]
466
- cmd = run.action.commands[0]
476
+ t1 = wk.tasks.t1
477
+ assert isinstance(t1, hf.WorkflowTask)
478
+ run = t1.elements[0].iterations[0].action_runs[0]
479
+ command = run.action.commands[0]
467
480
  shell = ALL_SHELLS["powershell"]["nt"]()
468
- cmd_str, _ = cmd.get_command_line(EAR=run, shell=shell, env=run.get_environment())
481
+ cmd_str, _ = command.get_command_line(EAR=run, shell=shell, env=run.get_environment())
469
482
 
483
+ assert p1_value.sub_param is not None
470
484
  assert cmd_str == f"Write-Output ({p1_value.sub_param.e} + 100)"
471
485
 
472
486
 
473
- def test_get_command_line_parameter_value_sub_object_attr(null_config, tmp_path):
487
+ def test_get_command_line_parameter_value_sub_object_attr(null_config, tmp_path: Path):
474
488
  cmd = f"Write-Output (" f"<<parameter:p1c.sub_param.e>> + 100)"
475
489
  s1 = hf.TaskSchema(
476
490
  objective="t1",
@@ -485,49 +499,52 @@ def test_get_command_line_parameter_value_sub_object_attr(null_config, tmp_path)
485
499
  template_name="wk0",
486
500
  overwrite=True,
487
501
  )
488
- run = wk.tasks.t1.elements[0].iterations[0].action_runs[0]
489
- cmd = run.action.commands[0]
502
+ t1 = wk.tasks.t1
503
+ assert isinstance(t1, hf.WorkflowTask)
504
+ run = t1.elements[0].iterations[0].action_runs[0]
505
+ command = run.action.commands[0]
490
506
  shell = ALL_SHELLS["powershell"]["nt"]()
491
- cmd_str, _ = cmd.get_command_line(EAR=run, shell=shell, env=run.get_environment())
507
+ cmd_str, _ = command.get_command_line(EAR=run, shell=shell, env=run.get_environment())
492
508
 
509
+ assert p1_value.sub_param is not None
493
510
  assert cmd_str == f"Write-Output ({p1_value.sub_param.e} + 100)"
494
511
 
495
512
 
496
- def test_process_std_stream_int(null_config):
513
+ def test_process_std_stream_int(null_config) -> None:
497
514
  cmd = hf.Command(command="", stdout="<<int(parameter:p2)>>")
498
515
  assert cmd.process_std_stream(name="p2", value="101", stderr=False) == 101
499
516
 
500
517
 
501
- def test_process_std_stream_stderr_int(null_config):
518
+ def test_process_std_stream_stderr_int(null_config) -> None:
502
519
  cmd = hf.Command(command="", stderr="<<int(parameter:p2)>>")
503
520
  assert cmd.process_std_stream(name="p2", value="101", stderr=True) == 101
504
521
 
505
522
 
506
- def test_process_std_stream_float(null_config):
523
+ def test_process_std_stream_float(null_config) -> None:
507
524
  cmd = hf.Command(command="", stdout="<<float(parameter:p2)>>")
508
525
  assert cmd.process_std_stream(name="p2", value="3.1415", stderr=False) == 3.1415
509
526
 
510
527
 
511
- def test_process_std_stream_bool_true(null_config):
528
+ def test_process_std_stream_bool_true(null_config) -> None:
512
529
  cmd = hf.Command(command="", stdout="<<bool(parameter:p2)>>")
513
530
  for value in ("true", "True", "1"):
514
531
  assert cmd.process_std_stream(name="p2", value=value, stderr=False) == True
515
532
 
516
533
 
517
- def test_process_std_stream_bool_false(null_config):
534
+ def test_process_std_stream_bool_false(null_config) -> None:
518
535
  cmd = hf.Command(command="", stdout="<<bool(parameter:p2)>>")
519
536
  for value in ("false", "False", "0"):
520
537
  assert cmd.process_std_stream(name="p2", value=value, stderr=False) == False
521
538
 
522
539
 
523
- def test_process_std_stream_bool_raise(null_config):
540
+ def test_process_std_stream_bool_raise(null_config) -> None:
524
541
  cmd = hf.Command(command="", stdout="<<bool(parameter:p2)>>")
525
542
  for value in ("hi", "120", "-1"):
526
543
  with pytest.raises(ValueError):
527
544
  cmd.process_std_stream(name="p2", value=value, stderr=False)
528
545
 
529
546
 
530
- def test_process_std_stream_list(null_config):
547
+ def test_process_std_stream_list(null_config) -> None:
531
548
  cmd = hf.Command(command="", stdout="<<list(parameter:p2)>>")
532
549
  assert cmd.process_std_stream(name="p2", value="1 2 3", stderr=False) == [
533
550
  "1",
@@ -536,12 +553,12 @@ def test_process_std_stream_list(null_config):
536
553
  ]
537
554
 
538
555
 
539
- def test_process_std_stream_list_int(null_config):
556
+ def test_process_std_stream_list_int(null_config) -> None:
540
557
  cmd = hf.Command(command="", stdout="<<list[item_type=int](parameter:p2)>>")
541
558
  assert cmd.process_std_stream(name="p2", value="1 2 3", stderr=False) == [1, 2, 3]
542
559
 
543
560
 
544
- def test_process_std_stream_list_delim(null_config):
561
+ def test_process_std_stream_list_delim(null_config) -> None:
545
562
  cmd = hf.Command(command="", stdout='<<list[delim=","](parameter:p2)>>')
546
563
  assert cmd.process_std_stream(name="p2", value="1,2,3", stderr=False) == [
547
564
  "1",
@@ -550,14 +567,14 @@ def test_process_std_stream_list_delim(null_config):
550
567
  ]
551
568
 
552
569
 
553
- def test_process_std_stream_list_int_delim(null_config):
570
+ def test_process_std_stream_list_int_delim(null_config) -> None:
554
571
  cmd = hf.Command(
555
572
  command="", stdout='<<list[item_type=int, delim=","](parameter:p2)>>'
556
573
  )
557
574
  assert cmd.process_std_stream(name="p2", value="1,2,3", stderr=False) == [1, 2, 3]
558
575
 
559
576
 
560
- def test_process_std_stream_list_float_delim_colon(null_config):
577
+ def test_process_std_stream_list_float_delim_colon(null_config) -> None:
561
578
  cmd = hf.Command(
562
579
  command="", stdout='<<list[item_type=float, delim=":"](parameter:p2)>>'
563
580
  )
@@ -568,7 +585,7 @@ def test_process_std_stream_list_float_delim_colon(null_config):
568
585
  ]
569
586
 
570
587
 
571
- def test_process_std_stream_array(null_config):
588
+ def test_process_std_stream_array(null_config) -> None:
572
589
  cmd = hf.Command(command="", stdout="<<array(parameter:p2)>>")
573
590
  assert np.allclose(
574
591
  cmd.process_std_stream(name="p2", value="1 2 3", stderr=False),
@@ -576,7 +593,7 @@ def test_process_std_stream_array(null_config):
576
593
  )
577
594
 
578
595
 
579
- def test_process_std_stream_array_delim(null_config):
596
+ def test_process_std_stream_array_delim(null_config) -> None:
580
597
  cmd = hf.Command(command="", stdout='<<array[delim=","](parameter:p2)>>')
581
598
  assert np.allclose(
582
599
  cmd.process_std_stream(name="p2", value="1,2,3", stderr=False),
@@ -584,19 +601,19 @@ def test_process_std_stream_array_delim(null_config):
584
601
  )
585
602
 
586
603
 
587
- def test_process_std_stream_array_dtype_int(null_config):
604
+ def test_process_std_stream_array_dtype_int(null_config) -> None:
588
605
  cmd = hf.Command(command="", stdout="<<array[item_type=int](parameter:p2)>>")
589
606
  arr = cmd.process_std_stream(name="p2", value="1 2 3", stderr=False)
590
607
  assert arr.dtype == np.dtype("int")
591
608
 
592
609
 
593
- def test_process_std_stream_array_dtype_float(null_config):
610
+ def test_process_std_stream_array_dtype_float(null_config) -> None:
594
611
  cmd = hf.Command(command="", stdout="<<array[item_type=float](parameter:p2)>>")
595
612
  arr = cmd.process_std_stream(name="p2", value="1 2 3", stderr=False)
596
613
  assert arr.dtype == np.dtype("float")
597
614
 
598
615
 
599
- def test_process_std_stream_object(null_config):
616
+ def test_process_std_stream_object(null_config) -> None:
600
617
  cmd = hf.Command(command="", stdout="<<parameter:p1c>>")
601
618
  a_val = 12
602
619
  assert cmd.process_std_stream(name="p1c", value=str(a_val), stderr=False) == P1(
@@ -604,7 +621,7 @@ def test_process_std_stream_object(null_config):
604
621
  )
605
622
 
606
623
 
607
- def test_process_std_stream_object_kwargs(null_config):
624
+ def test_process_std_stream_object_kwargs(null_config) -> None:
608
625
  cmd = hf.Command(command="", stdout="<<parameter:p1c.CLI_parse(double=true)>>")
609
626
  a_val = 12
610
627
  expected = 2 * a_val
@@ -613,48 +630,48 @@ def test_process_std_stream_object_kwargs(null_config):
613
630
  )
614
631
 
615
632
 
616
- def test_get_output_types(null_config):
633
+ def test_get_output_types(null_config) -> None:
617
634
  cmd = hf.Command(command="", stdout="<<parameter:p1_test_123>>")
618
635
  assert cmd.get_output_types() == {"stdout": "p1_test_123", "stderr": None}
619
636
 
620
637
 
621
- def test_get_output_types_int(null_config):
638
+ def test_get_output_types_int(null_config) -> None:
622
639
  cmd = hf.Command(command="", stdout="<<int(parameter:p1_test_123)>>")
623
640
  assert cmd.get_output_types() == {"stdout": "p1_test_123", "stderr": None}
624
641
 
625
642
 
626
- def test_get_output_types_object_with_args(null_config):
643
+ def test_get_output_types_object_with_args(null_config) -> None:
627
644
  cmd = hf.Command(
628
645
  command="", stdout="<<parameter:p1_test_123.CLI_parse(double=true)>>"
629
646
  )
630
647
  assert cmd.get_output_types() == {"stdout": "p1_test_123", "stderr": None}
631
648
 
632
649
 
633
- def test_get_output_types_list(null_config):
650
+ def test_get_output_types_list(null_config) -> None:
634
651
  cmd = hf.Command(
635
652
  command="", stdout="<<list[item_type=int, delim=" "](parameter:p1_test_123)>>"
636
653
  )
637
654
  assert cmd.get_output_types() == {"stdout": "p1_test_123", "stderr": None}
638
655
 
639
656
 
640
- def test_get_output_types_no_match(null_config):
657
+ def test_get_output_types_no_match(null_config) -> None:
641
658
  cmd = hf.Command(command="", stdout="parameter:p1_test_123")
642
659
  assert cmd.get_output_types() == {"stdout": None, "stderr": None}
643
660
 
644
661
 
645
- def test_get_output_types_raise_with_extra_substring_start(null_config):
662
+ def test_get_output_types_raise_with_extra_substring_start(null_config) -> None:
646
663
  cmd = hf.Command(command="", stdout="hello: <<parameter:p1_test_123>>")
647
664
  with pytest.raises(ValueError):
648
665
  cmd.get_output_types()
649
666
 
650
667
 
651
- def test_get_output_types_raise_with_extra_substring_end(null_config):
668
+ def test_get_output_types_raise_with_extra_substring_end(null_config) -> None:
652
669
  cmd = hf.Command(command="", stdout="<<parameter:p1_test_123>> hello")
653
670
  with pytest.raises(ValueError):
654
671
  cmd.get_output_types()
655
672
 
656
673
 
657
- def test_extract_executable_labels(null_config):
674
+ def test_extract_executable_labels(null_config) -> None:
658
675
  tests = {
659
676
  "<<executable:m1>> and <<executable:12>>": ["m1", "12"],
660
677
  "<<executable:m1>> hi": ["m1"],
@@ -1,3 +1,4 @@
1
+ from __future__ import annotations
1
2
  import os
2
3
  import pytest
3
4
 
@@ -5,55 +6,59 @@ from hpcflow.app import app as hf
5
6
  from hpcflow.sdk.config.errors import ConfigFileValidationError, ConfigItemCallbackError
6
7
 
7
8
 
8
- def test_reset_config(new_null_config):
9
- cfg_dir = hf.config.get("config_directory")
10
- machine_name = hf.config.get("machine")
9
+ def test_reset_config(new_null_config) -> None:
10
+ cfg_dir = hf.config.config_directory
11
+ machine_name = hf.config.machine
11
12
  new_machine_name = machine_name + "123"
12
- hf.config._set("machine", new_machine_name)
13
- assert hf.config.get("machine") == new_machine_name
13
+ hf.config.machine = new_machine_name
14
+ assert hf.config.machine == new_machine_name
14
15
  hf.reset_config(config_dir=cfg_dir)
15
- assert hf.config.get("machine") == machine_name
16
+ assert hf.config.machine == machine_name
16
17
 
17
18
 
18
- def test_raise_on_invalid_config_file(new_null_config):
19
+ def test_raise_on_invalid_config_file(new_null_config) -> None:
19
20
  # make an invalid config file:
20
- cfg_path = hf.config.get("config_file_path")
21
+ cfg_path = hf.config.config_file_path
21
22
  with cfg_path.open("at+") as f:
22
23
  f.write("something_invalid: 1\n")
23
24
 
24
25
  # try to load the invalid file:
25
- cfg_dir = hf.config.get("config_directory")
26
+ cfg_dir = hf.config.config_directory
26
27
  with pytest.raises(ConfigFileValidationError):
27
28
  hf.reload_config(config_dir=cfg_dir, warn=False)
28
29
  hf.reset_config(config_dir=cfg_dir, warn=False)
29
30
  hf.unload_config()
30
31
 
31
32
 
32
- def test_reset_invalid_config(new_null_config):
33
+ def test_reset_invalid_config(new_null_config) -> None:
33
34
  # make an invalid config file:
34
- cfg_path = hf.config.get("config_file_path")
35
+ cfg_path = hf.config.config_file_path
35
36
  with cfg_path.open("at+") as f:
36
37
  f.write("something_invalid: 1\n")
37
38
 
38
39
  # check we can reset the invalid file:
39
- cfg_dir = hf.config.get("config_directory")
40
+ cfg_dir = hf.config.config_directory
40
41
  hf.reset_config(config_dir=cfg_dir, warn=False)
41
42
  hf.unload_config()
42
43
 
43
44
 
44
- def test_raise_on_set_default_scheduler_not_in_schedulers_list_invalid_name(null_config):
45
+ def test_raise_on_set_default_scheduler_not_in_schedulers_list_invalid_name(
46
+ null_config,
47
+ ) -> None:
45
48
  new_default = "invalid-scheduler"
46
49
  with pytest.raises(ConfigItemCallbackError):
47
50
  hf.config.default_scheduler = new_default
48
51
 
49
52
 
50
- def test_raise_on_set_default_scheduler_not_in_schedulers_list_valid_name(null_config):
53
+ def test_raise_on_set_default_scheduler_not_in_schedulers_list_valid_name(
54
+ null_config,
55
+ ) -> None:
51
56
  new_default = "slurm" # valid but unsupported (by default) scheduler
52
57
  with pytest.raises(ConfigItemCallbackError):
53
58
  hf.config.default_scheduler = new_default
54
59
 
55
60
 
56
- def test_without_callbacks_ctx_manager(null_config):
61
+ def test_without_callbacks_ctx_manager(null_config) -> None:
57
62
  # set a new shell that would raise an error in the `callback_supported_shells`:
58
63
  new_default = "bash" if os.name == "nt" else "powershell"
59
64
 
@@ -1,10 +1,12 @@
1
+ from __future__ import annotations
2
+ from typing import Any
1
3
  import pytest
2
4
  from hpcflow.sdk.config.config_file import ConfigFile
3
5
  from hpcflow.sdk.config.errors import ConfigFileInvocationIncompatibleError
4
6
 
5
7
 
6
- def test_select_invocation_default_no_specified_matches():
7
- configs = {
8
+ def test_select_invocation_default_no_specified_matches() -> None:
9
+ configs: dict[str, Any] = {
8
10
  "default": {
9
11
  "invocation": {
10
12
  "environment_setup": None,
@@ -12,17 +14,16 @@ def test_select_invocation_default_no_specified_matches():
12
14
  }
13
15
  }
14
16
  }
15
- run_time_info = {}
16
17
  matched = ConfigFile.select_invocation(
17
18
  configs=configs,
18
- run_time_info=run_time_info,
19
+ run_time_info={},
19
20
  path="/path/to/config.yaml",
20
21
  )
21
22
  assert matched == "default"
22
23
 
23
24
 
24
- def test_select_invocation_default_no_specified_matches_with_run_time_info():
25
- configs = {
25
+ def test_select_invocation_default_no_specified_matches_with_run_time_info() -> None:
26
+ configs: dict[str, Any] = {
26
27
  "default": {
27
28
  "invocation": {
28
29
  "environment_setup": None,
@@ -39,8 +40,8 @@ def test_select_invocation_default_no_specified_matches_with_run_time_info():
39
40
  assert matched == "default"
40
41
 
41
42
 
42
- def test_select_invocation_single_specified_match():
43
- configs = {
43
+ def test_select_invocation_single_specified_match() -> None:
44
+ configs: dict[str, Any] = {
44
45
  "default": {
45
46
  "invocation": {
46
47
  "environment_setup": None,
@@ -57,8 +58,8 @@ def test_select_invocation_single_specified_match():
57
58
  assert matched == "default"
58
59
 
59
60
 
60
- def test_select_invocation_single_specified_match_list_match_first():
61
- configs = {
61
+ def test_select_invocation_single_specified_match_list_match_first() -> None:
62
+ configs: dict[str, Any] = {
62
63
  "default": {
63
64
  "invocation": {
64
65
  "environment_setup": None,
@@ -75,8 +76,8 @@ def test_select_invocation_single_specified_match_list_match_first():
75
76
  assert matched == "default"
76
77
 
77
78
 
78
- def test_select_invocation_single_specified_match_list_match_second():
79
- configs = {
79
+ def test_select_invocation_single_specified_match_list_match_second() -> None:
80
+ configs: dict[str, Any] = {
80
81
  "default": {
81
82
  "invocation": {
82
83
  "environment_setup": None,
@@ -93,8 +94,8 @@ def test_select_invocation_single_specified_match_list_match_second():
93
94
  assert matched == "default"
94
95
 
95
96
 
96
- def test_select_invocation_raise_on_no_match():
97
- configs = {
97
+ def test_select_invocation_raise_on_no_match() -> None:
98
+ configs: dict[str, Any] = {
98
99
  "default": {
99
100
  "invocation": {
100
101
  "environment_setup": None,
@@ -111,8 +112,8 @@ def test_select_invocation_raise_on_no_match():
111
112
  )
112
113
 
113
114
 
114
- def test_select_invocation_multiple_specified_higher_specificity_selected_first():
115
- configs = {
115
+ def test_select_invocation_multiple_specified_higher_specificity_selected_first() -> None:
116
+ configs: dict[str, Any] = {
116
117
  "specific": {
117
118
  "invocation": {
118
119
  "environment_setup": None,
@@ -135,8 +136,10 @@ def test_select_invocation_multiple_specified_higher_specificity_selected_first(
135
136
  assert matched == "specific"
136
137
 
137
138
 
138
- def test_select_invocation_multiple_specified_higher_specificity_selected_second():
139
- configs = {
139
+ def test_select_invocation_multiple_specified_higher_specificity_selected_second() -> (
140
+ None
141
+ ):
142
+ configs: dict[str, Any] = {
140
143
  "default": {
141
144
  "invocation": {
142
145
  "environment_setup": None,