hpcflow-new2 0.2.0a175__py3-none-any.whl → 0.2.0a177__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.
@@ -1159,3 +1159,130 @@ def test_multi_nested_loops(null_config, tmp_path):
1159
1159
  (0, {"inner": 0, "middle_1": 2, "middle_2": 1, "outer": 1}, (22,)),
1160
1160
  (0, {"inner": 1, "middle_1": 2, "middle_2": 1, "outer": 1}, (23,)),
1161
1161
  ]
1162
+
1163
+
1164
+ def test_nested_loop_input_from_parent_loop_task(null_config, tmp_path):
1165
+ """Test that an input in a nested-loop task is correctly sourced from latest
1166
+ iteration of the parent loop."""
1167
+ wk = make_workflow(
1168
+ schemas_spec=[
1169
+ [{"p1": None}, ("p2", "p3")],
1170
+ [{"p2": None}, ("p4",)],
1171
+ [{"p4": None, "p3": None}, ("p2", "p1")], # testing p3 source
1172
+ ],
1173
+ path=tmp_path,
1174
+ local_inputs={0: {"p1": 101}},
1175
+ loops=[
1176
+ hf.Loop(name="inner", tasks=[1, 2], num_iterations=3),
1177
+ hf.Loop(name="outer", tasks=[0, 1, 2], num_iterations=2),
1178
+ ],
1179
+ )
1180
+ pathway = wk.get_iteration_task_pathway(ret_data_idx=True)
1181
+ assert len(pathway) == 14
1182
+ p3_out_idx = [i[2][0]["outputs.p3"] for i in pathway if i[0] == 0]
1183
+ p3_inp_idx = [i[2][0]["inputs.p3"] for i in pathway if i[0] == 2]
1184
+ assert len(p3_out_idx) == 2 # 2 outer iterations
1185
+ assert len(p3_inp_idx) == 6 # 2 * 3 iterations
1186
+ assert p3_inp_idx == [p3_out_idx[0]] * 3 + [p3_out_idx[1]] * 3
1187
+
1188
+
1189
+ def test_doubly_nested_loop_input_from_parent_loop_task(null_config, tmp_path):
1190
+ """Test that an input in a doubly-nested-loop task is correctly sourced from latest
1191
+ iteration of the parent loop."""
1192
+ # test source of p6 in final task:
1193
+ wk = make_workflow(
1194
+ schemas_spec=[
1195
+ [{"p5": None}, ("p6", "p1")],
1196
+ [{"p1": None}, ("p2", "p3")],
1197
+ [{"p2": None}, ("p4",)],
1198
+ [{"p4": None, "p3": None, "p6": None}, ("p2", "p1", "p5")],
1199
+ ],
1200
+ path=tmp_path,
1201
+ local_inputs={0: {"p5": 101}},
1202
+ loops=[
1203
+ hf.Loop(name="inner", tasks=[2, 3], num_iterations=3),
1204
+ hf.Loop(name="middle", tasks=[1, 2, 3], num_iterations=3),
1205
+ hf.Loop(name="outer", tasks=[0, 1, 2, 3], num_iterations=3),
1206
+ ],
1207
+ overwrite=True,
1208
+ )
1209
+ pathway = wk.get_iteration_task_pathway(ret_data_idx=True)
1210
+ assert len(pathway) == 66
1211
+
1212
+ p6_out_idx = [i[2][0]["outputs.p6"] for i in pathway if i[0] == 0]
1213
+ p6_inp_idx = [i[2][0]["inputs.p6"] for i in pathway if i[0] == 3]
1214
+ assert len(p6_out_idx) == 3 # 2 outer iterations
1215
+ assert len(p6_inp_idx) == 27 # 3 * 3 * 3 iterations
1216
+ assert p6_inp_idx == [p6_out_idx[0]] * 9 + [p6_out_idx[1]] * 9 + [p6_out_idx[2]] * 9
1217
+
1218
+
1219
+ def test_loop_non_input_task_input_from_element_group(null_config, tmp_path):
1220
+ """Test correct sourcing of an element group input within a loop, for a task that is
1221
+ not that loop's "input task" with respect to that parameter."""
1222
+ s1 = hf.TaskSchema(
1223
+ objective="t1",
1224
+ inputs=[hf.SchemaInput("p1")],
1225
+ outputs=[hf.SchemaOutput("p2"), hf.SchemaOutput("p3")],
1226
+ actions=[
1227
+ hf.Action(
1228
+ commands=[
1229
+ hf.Command(
1230
+ command="echo $((<<parameter:p1>> + 1))",
1231
+ stdout="<<parameter:p2>>",
1232
+ stderr="<<parameter:p3>>",
1233
+ )
1234
+ ]
1235
+ )
1236
+ ],
1237
+ )
1238
+ s2 = hf.TaskSchema(
1239
+ objective="t2",
1240
+ inputs=[hf.SchemaInput("p2", group="my_group")],
1241
+ outputs=[hf.SchemaOutput("p4")],
1242
+ actions=[
1243
+ hf.Action(
1244
+ commands=[
1245
+ hf.Command(
1246
+ command="echo $((<<sum(parameter:p2)>> + 1))",
1247
+ stdout="<<parameter:p4>>",
1248
+ )
1249
+ ]
1250
+ )
1251
+ ],
1252
+ )
1253
+ s3 = hf.TaskSchema(
1254
+ objective="t3",
1255
+ inputs=[hf.SchemaInput("p3", group="my_group"), hf.SchemaInput("p4")],
1256
+ outputs=[hf.SchemaOutput("p2")],
1257
+ actions=[
1258
+ hf.Action(
1259
+ commands=[
1260
+ hf.Command(
1261
+ command="echo $((<<sum(parameter:p3)>> + <<parameter:p4>>))",
1262
+ stdout="<<parameter:p2>>",
1263
+ )
1264
+ ]
1265
+ )
1266
+ ],
1267
+ )
1268
+ wk = hf.Workflow.from_template_data(
1269
+ template_name="test_loop",
1270
+ path=tmp_path,
1271
+ tasks=[
1272
+ hf.Task(
1273
+ schema=s1,
1274
+ sequences=[hf.ValueSequence("inputs.p1", values=[1, 2, 3])],
1275
+ groups=[hf.ElementGroup("my_group")],
1276
+ ),
1277
+ hf.Task(schema=s2),
1278
+ hf.Task(schema=s3), # test source of p3 (should be group from t1)
1279
+ ],
1280
+ loops=[hf.Loop(name="inner", tasks=[1, 2], num_iterations=2)],
1281
+ )
1282
+ pathway = wk.get_iteration_task_pathway(ret_data_idx=True)
1283
+ assert len(pathway) == 5
1284
+
1285
+ expected = [i["outputs.p3"] for i in pathway[0][2]]
1286
+ for i in pathway:
1287
+ if i[0] == 2: # task 3
1288
+ assert i[2][0]["inputs.p3"] == expected
@@ -13,6 +13,8 @@ from hpcflow.sdk.core.utils import (
13
13
  get_nested_indices,
14
14
  is_fsspec_url,
15
15
  linspace_rect,
16
+ nth_key,
17
+ nth_value,
16
18
  process_string_nodes,
17
19
  replace_items,
18
20
  check_valid_py_identifier,
@@ -556,3 +558,22 @@ def test_dict_values_process_flat_single_item_lists():
556
558
  "b": [4],
557
559
  "c": [5],
558
560
  }
561
+
562
+
563
+ def test_nth_key():
564
+ dct = {"a": 1, "b": 2}
565
+ assert [nth_key(dct, i) for i in range(len(dct))] == ["a", "b"]
566
+
567
+
568
+ def test_nth_value():
569
+ dct = {"a": 1, "b": 2}
570
+ assert [nth_value(dct, i) for i in range(len(dct))] == [1, 2]
571
+
572
+
573
+ def test_nth_key_raises():
574
+ dct = {"a": 1, "b": 2}
575
+ with pytest.raises(Exception):
576
+ nth_key(dct, 2)
577
+
578
+ with pytest.raises(Exception):
579
+ nth_key(dct, -1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hpcflow-new2
3
- Version: 0.2.0a175
3
+ Version: 0.2.0a177
4
4
  Summary: Computational workflow management
5
5
  License: MIT
6
6
  Author: aplowman
@@ -1,7 +1,7 @@
1
1
  hpcflow/__init__.py,sha256=WIETuRHeOp2SqUqHUzpjQ-lk9acbYv-6aWOhZPRdlhs,64
2
2
  hpcflow/__pyinstaller/__init__.py,sha256=YOzBlPSck6slucv6lJM9K80JtsJWxXRL00cv6tRj3oc,98
3
3
  hpcflow/__pyinstaller/hook-hpcflow.py,sha256=SeMopsPkhCyd9gqIrzwFNRj3ZlkUlUYl-74QYz61mo4,1089
4
- hpcflow/_version.py,sha256=qS9M42Fmpevc84bybtkqyQeAZhWacKKmZ1vAOYpl2WE,26
4
+ hpcflow/_version.py,sha256=c6sVLAvL-ZtlEF_CBbI6lCJoA-qh3KPMN5Smq6FFaPk,26
5
5
  hpcflow/app.py,sha256=d-kgfnZNlqlCi2H8bK26714brD_u3ibN3FaEZgjF9aA,1332
6
6
  hpcflow/cli.py,sha256=G2J3D9v6MnMWOWMMWK6UEKLn_6wnV9lT_qygEBBxg-I,66
7
7
  hpcflow/data/demo_data_manifest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -46,24 +46,26 @@ hpcflow/sdk/config/config_file.py,sha256=JlMcprj0aujFVk8552ahP2f8EXB0tglMaHwzbcG
46
46
  hpcflow/sdk/config/errors.py,sha256=2D7HJ1dbyeoD3xk4MuaGSsbJsUyQzyw8kaThEBZfP2I,6876
47
47
  hpcflow/sdk/core/__init__.py,sha256=GcIklEsXy3M5PWpmxyhd2KoI0u6HjXRIjD_aR1bgRjo,215
48
48
  hpcflow/sdk/core/actions.py,sha256=66CHgwYAB0oCR6oB5bNbBdUGRGTU3juS1XcMNjj3vP0,77068
49
+ hpcflow/sdk/core/cache.py,sha256=MDzqsCg8uMjxEdQ-8ta-uG042yiPrzQoVKMeE6jYW8k,5127
49
50
  hpcflow/sdk/core/command_files.py,sha256=GEFlgZv7g9lkFoNgwyDtmlI_90e2TWliCJuJimnJZts,18685
50
51
  hpcflow/sdk/core/commands.py,sha256=5SKxSBuYz8sSvfpp9p5utBwMoQV6Pd2KlGBCpXAHDxE,12741
51
- hpcflow/sdk/core/element.py,sha256=hTAR2kxfGSRf4vFgWwrnyuP5z5RnKYOd2X6c6Xd70zo,47048
52
+ hpcflow/sdk/core/element.py,sha256=kWEbGWzrXCwhQ1Ie1RFm1v5_q3MQkCDPEIp01nHIf1Q,47202
52
53
  hpcflow/sdk/core/environment.py,sha256=DGUz1NvliKh6opP0IueGHD69rn_8wFLhDsq6kAmEgM4,4849
53
54
  hpcflow/sdk/core/errors.py,sha256=ku4wwsrmxBpJBFflUeZD6vrmAqgC7H02VdlRG4aAGqQ,9292
54
55
  hpcflow/sdk/core/json_like.py,sha256=LRZsUd1tn8zXC8fESeiXs7Eko-VdnB8zcXiqixKVcZM,18874
55
- hpcflow/sdk/core/loop.py,sha256=7WHif9U3KenNqICN5Ibq76WCwEn9xzBo0jnROwv4z-4,30051
56
+ hpcflow/sdk/core/loop.py,sha256=vj3b0jRCJxkKdhURYTgULoDJ6U3LzAYZMXBzqcCMHr8,31506
57
+ hpcflow/sdk/core/loop_cache.py,sha256=BBmJn_pS11gaiHS8qvujBpzWLzPsfs8N6iYIBkZtIwI,5881
56
58
  hpcflow/sdk/core/object_list.py,sha256=HASx7AMniX82bTlROIgIvrjE_DupmwDgxfkfROmI3GA,20168
57
59
  hpcflow/sdk/core/parallel.py,sha256=LI-g-qOuOR1oaEUWVT0qW0hmiP9hsJyUP8_IfSTKYYo,95
58
60
  hpcflow/sdk/core/parameters.py,sha256=0h1M-fXqOVgruyM0Au7Fo38cUbHgDNEPd1Alb1FULxE,65588
59
61
  hpcflow/sdk/core/rule.py,sha256=3jVsSZCBv4Odxy8QbSbKo9ZcRuU-5DRJoNK8adXCEpI,4567
60
62
  hpcflow/sdk/core/run_dir_files.py,sha256=_k-hA7dlry9GZw5ZXcntFcPGxg07p03hnHSM5S-2G2Y,2197
61
- hpcflow/sdk/core/task.py,sha256=-Ugs13wl76FxBv9q0Ik2dWGSDPZQ4KR4qvwmrfsAEgE,122247
63
+ hpcflow/sdk/core/task.py,sha256=TTAn9aeJOLyso7t11wt87wxPDVi037vwpFgF9rCfZwQ,122319
62
64
  hpcflow/sdk/core/task_schema.py,sha256=TipXzC2guu9zilv0En-rHt6lUCTSIj5faI4lVWQdUbA,32346
63
65
  hpcflow/sdk/core/test_utils.py,sha256=IhCLvRzDuG4hVNGeGulGKfZEgg7Ow-vgiEqewzMiaZ4,9762
64
- hpcflow/sdk/core/utils.py,sha256=pReOwnmuxJqexPUdaA8UMjJ4o8ucllBVVssWjb_LNQc,25651
66
+ hpcflow/sdk/core/utils.py,sha256=cpwfoHgbHanZQXmVZRN3VRW8X-zZxb1I6T0v2tWgBK0,25811
65
67
  hpcflow/sdk/core/validation.py,sha256=KBKiy5DdfGiGmMaB0HdKTY0V972u5dJzvkYkX0_KtCo,518
66
- hpcflow/sdk/core/workflow.py,sha256=oi9QdBgAMSr62c6HQx2OXw3ljRmxhEb_3YNXGCwIbBE,111164
68
+ hpcflow/sdk/core/workflow.py,sha256=ziKn1cA4s_eHKPMzyKfHF4bVNF7bfho4dko5qtyZKjU,113111
67
69
  hpcflow/sdk/core/zarr_io.py,sha256=V_Zm6uSiuaCbXyHFJUO74K1pAr4Zqrj3aLCBjohCwvs,5724
68
70
  hpcflow/sdk/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
71
  hpcflow/sdk/data/config_file_schema.yaml,sha256=7i3z_m3GBRtLyB4c7qPngnlQWqcIq1CyCcOysDyq4es,791
@@ -81,12 +83,12 @@ hpcflow/sdk/helper/helper.py,sha256=MkjYKHox1F4XOpy-20sCCDUTWUbQY84QpWZkcpSq9n8,
81
83
  hpcflow/sdk/helper/watcher.py,sha256=hLqgwXtZw-6ihNUUcWYnZw8TCyD_AdhYE7abOrO2r_0,4003
82
84
  hpcflow/sdk/log.py,sha256=_DA5nNS8BoSIFB3d9nrIjbxNDxFflEaL3Ubkq8UYQK8,5735
83
85
  hpcflow/sdk/persistence/__init__.py,sha256=IzWycfiO6rDn_7Kocw4Df5ETe9BSoaqqxG7Yp4FW_ls,900
84
- hpcflow/sdk/persistence/base.py,sha256=cmfvgUQAp6BVcOL04IemzmtPvzSJfVd2nQFvgp2VLyU,61718
85
- hpcflow/sdk/persistence/json.py,sha256=XD4km426WZ6F6YCrnw87ntS_Qfg3qa9CAyK2GQmJNFU,21700
86
- hpcflow/sdk/persistence/pending.py,sha256=ZaiY_I6c0CpXGPOkHfs595GtDvx8daP4nqVZGSJ6tS4,25566
86
+ hpcflow/sdk/persistence/base.py,sha256=cvk2Uqd671ZFe6JEP_UrZ7W0q2mZjimyA8DFvss8hdo,62030
87
+ hpcflow/sdk/persistence/json.py,sha256=55F4Txa50I9HzfETPqwo6gAOBRaoewMHGR3V4-2Fifc,22013
88
+ hpcflow/sdk/persistence/pending.py,sha256=XktGkRpJmlyjceOiDY0GEL2xRl6k-gbjt057LmEj5oc,25656
87
89
  hpcflow/sdk/persistence/store_resource.py,sha256=oEyocRqa8Uym-57UFosrwate-Xw9O7i2FM82TxHc4m0,4307
88
90
  hpcflow/sdk/persistence/utils.py,sha256=yQT6gS-Ipj2N6grtlV5d0czxxKE0CaeqAkXA1247XGo,1522
89
- hpcflow/sdk/persistence/zarr.py,sha256=cyhLVaHUVLuFg-sokfD8L2YOMvfCCk1KCawRD9_qg30,45452
91
+ hpcflow/sdk/persistence/zarr.py,sha256=otZbR17O3ZNIot7uVAP1UdWs_L0PHS682LuWk3z1_1g,45708
90
92
  hpcflow/sdk/runtime.py,sha256=_in5ojiy9R8fD1ZNbdE6PDmZx6kSaiG9WPB6kVBFE7k,9217
91
93
  hpcflow/sdk/submission/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
94
  hpcflow/sdk/submission/jobscript.py,sha256=Z9NUzkIcmoFw-XAtG8FdLpO2LtMt3czk1v1BnbM1eZw,44678
@@ -129,7 +131,7 @@ hpcflow/tests/unit/test_group.py,sha256=J7Gx6BdzD2uoRUnBow7L_OfdfLUZi7sv5AZd1yss
129
131
  hpcflow/tests/unit/test_input_source.py,sha256=pYm1V4kBsBIFstKDcrbwUiDLb82rr7ITcUEFJES2dI0,39194
130
132
  hpcflow/tests/unit/test_input_value.py,sha256=H6GX1ee7fuq5f-OsfkfiSW8eye_pWwVLUCYUSnj1-Gg,5731
131
133
  hpcflow/tests/unit/test_json_like.py,sha256=aGCiGfT-tNiFu3yzW6d_T-oDc5QLwSUgq3pN3jFhyF0,29939
132
- hpcflow/tests/unit/test_loop.py,sha256=6SPRzqxk0X3aWPiUJJTu6lKODsPGNUOdDgzdN1dFs0k,40438
134
+ hpcflow/tests/unit/test_loop.py,sha256=GNKMGAXP0AaB7fl1TShluyh-PoG7O96X7SGUg6vnK6Y,45149
133
135
  hpcflow/tests/unit/test_object_list.py,sha256=nDpbRpCu4XqoYxKMr1_QmDS1s2_6nQOpIEBRHSAXoVg,3049
134
136
  hpcflow/tests/unit/test_parameter.py,sha256=39CVido_NJGX-Xj9NDSlazpGzWqMG4zp0GmIKwzO7lI,6659
135
137
  hpcflow/tests/unit/test_persistence.py,sha256=DPXFiuY2v8vj0zZ7299nf-KtgYT8LhHI52fq7UPoa6Y,8128
@@ -142,14 +144,14 @@ hpcflow/tests/unit/test_slurm.py,sha256=ewfNuXXUEEelAxcd7MBbAQ-RCvU8xBenHTAyfXYF
142
144
  hpcflow/tests/unit/test_submission.py,sha256=kQ3ksjGlfp47AYuwTA27RDX2XxRU3YxKlKC1ACTbXw8,16682
143
145
  hpcflow/tests/unit/test_task.py,sha256=QJuEpJ0y0nBesprgoau5R2kFZBCW-ygNmYatLT_M5-o,80227
144
146
  hpcflow/tests/unit/test_task_schema.py,sha256=j5HHxoqq4Mb223jKcusgX-C6-TsmKG0PLjYQ4M01ZHo,4531
145
- hpcflow/tests/unit/test_utils.py,sha256=JMhSRZFqmI9ZhREJet9en_y3aRVlQlWE7OKpkdt8SVI,14172
147
+ hpcflow/tests/unit/test_utils.py,sha256=RH3UZ99g1pKKJme1rNgzT3j_txWLT9_OWE1lWx67W5M,14610
146
148
  hpcflow/tests/unit/test_value_sequence.py,sha256=yJh5YRxN-VYMbCWiUaLH4T_Ue5F2IfVS3e11zx6HlS0,15740
147
149
  hpcflow/tests/unit/test_workflow.py,sha256=Eyr9BhnsFisAPotEAeYrAvxXT1d2i6oshEh1_OxgnSc,22732
148
150
  hpcflow/tests/unit/test_workflow_template.py,sha256=fF7LNveMwCledgncNCRfD9Nd9dL9tSPtlAAOKV3ovAU,5396
149
151
  hpcflow/tests/workflows/test_jobscript.py,sha256=9sp1o0g72JZbv2QlOl5v7wCZEFjotxiIKGNUxVaFgaA,724
150
152
  hpcflow/tests/workflows/test_workflows.py,sha256=xai6FRtGqG4lStJk6KmsqPUSuvqs9FrsBOxMVALshIs,13400
151
153
  hpcflow/viz_demo.ipynb,sha256=1QdnVsk72vihv2L6hOGyk318uEa22ZSgGxQCa7hW2oo,6238
152
- hpcflow_new2-0.2.0a175.dist-info/METADATA,sha256=43yDTsgpidfr8FPVgUgIDwGX4GJz9qZ9Owf5POXxBQ0,2466
153
- hpcflow_new2-0.2.0a175.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
154
- hpcflow_new2-0.2.0a175.dist-info/entry_points.txt,sha256=aoGtCnFdfPcXfBdu2zZyMOJoz6fPgdR0elqsgrE-USU,106
155
- hpcflow_new2-0.2.0a175.dist-info/RECORD,,
154
+ hpcflow_new2-0.2.0a177.dist-info/METADATA,sha256=I1tkrIUSwRwNsKxjcTy7lrpcOhZp9Z3HUGV_Wdoo9qw,2466
155
+ hpcflow_new2-0.2.0a177.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
156
+ hpcflow_new2-0.2.0a177.dist-info/entry_points.txt,sha256=aoGtCnFdfPcXfBdu2zZyMOJoz6fPgdR0elqsgrE-USU,106
157
+ hpcflow_new2-0.2.0a177.dist-info/RECORD,,