hpcflow-new2 0.2.0a155__py3-none-any.whl → 0.2.0a156__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.
- hpcflow/_version.py +1 -1
- hpcflow/sdk/app.py +2 -2
- hpcflow/sdk/core/utils.py +22 -8
- hpcflow/sdk/demo/cli.py +2 -2
- hpcflow/tests/unit/test_utils.py +13 -0
- {hpcflow_new2-0.2.0a155.dist-info → hpcflow_new2-0.2.0a156.dist-info}/METADATA +1 -1
- {hpcflow_new2-0.2.0a155.dist-info → hpcflow_new2-0.2.0a156.dist-info}/RECORD +9 -9
- {hpcflow_new2-0.2.0a155.dist-info → hpcflow_new2-0.2.0a156.dist-info}/WHEEL +0 -0
- {hpcflow_new2-0.2.0a155.dist-info → hpcflow_new2-0.2.0a156.dist-info}/entry_points.txt +0 -0
hpcflow/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.2.
|
1
|
+
__version__ = "0.2.0a156"
|
hpcflow/sdk/app.py
CHANGED
@@ -822,12 +822,12 @@ class BaseApp(metaclass=Singleton):
|
|
822
822
|
# load the file, modify, then dump to temp location:
|
823
823
|
if builtin_path.suffix in (".yaml", ".yml"):
|
824
824
|
# use round-trip loader to preserve comments:
|
825
|
-
data = read_YAML_file(builtin_path, typ="rt")
|
825
|
+
data = read_YAML_file(builtin_path, typ="rt", variables=False)
|
826
826
|
data.pop("doc", None)
|
827
827
|
write_YAML_file(data, path, typ="rt")
|
828
828
|
|
829
829
|
elif builtin_path.suffix in (".json", ".jsonc"):
|
830
|
-
data = read_JSON_file(builtin_path)
|
830
|
+
data = read_JSON_file(builtin_path, variables=False)
|
831
831
|
data.pop("doc", None)
|
832
832
|
write_JSON_file(data, path)
|
833
833
|
|
hpcflow/sdk/core/utils.py
CHANGED
@@ -387,22 +387,36 @@ def check_in_object_list(spec_name, spec_pos=1, obj_list_pos=2):
|
|
387
387
|
return decorator
|
388
388
|
|
389
389
|
|
390
|
+
@TimeIt.decorator
|
390
391
|
def substitute_string_vars(string, variables: Dict[str, str] = None):
|
391
392
|
variables = variables or {}
|
392
393
|
|
393
394
|
def var_repl(match_obj):
|
394
|
-
|
395
|
+
kwargs = {}
|
396
|
+
var_name, kwargs_str = match_obj.groups()
|
397
|
+
if kwargs_str:
|
398
|
+
kwargs_lst = kwargs_str.split(",")
|
399
|
+
for i in kwargs_lst:
|
400
|
+
k, v = i.strip().split("=")
|
401
|
+
kwargs[k.strip()] = v.strip()
|
395
402
|
try:
|
396
403
|
out = str(variables[var_name])
|
397
404
|
except KeyError:
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
405
|
+
if "default" in kwargs:
|
406
|
+
out = kwargs["default"]
|
407
|
+
print(
|
408
|
+
f"Using default value ({out!r}) for workflow template string "
|
409
|
+
f"variable {var_name!r}."
|
410
|
+
)
|
411
|
+
else:
|
412
|
+
raise MissingVariableSubstitutionError(
|
413
|
+
f"The variable {var_name!r} referenced in the string does not match "
|
414
|
+
f"any of the provided variables: {list(variables)!r}."
|
415
|
+
)
|
402
416
|
return out
|
403
417
|
|
404
418
|
new_str = re.sub(
|
405
|
-
pattern=r"\<\<var:(.*?)
|
419
|
+
pattern=r"\<\<var:(.*?)(?:\[(.*)\])?\>\>",
|
406
420
|
repl=var_repl,
|
407
421
|
string=string,
|
408
422
|
)
|
@@ -412,7 +426,7 @@ def substitute_string_vars(string, variables: Dict[str, str] = None):
|
|
412
426
|
@TimeIt.decorator
|
413
427
|
def read_YAML_str(yaml_str, typ="safe", variables: Dict[str, str] = None):
|
414
428
|
"""Load a YAML string."""
|
415
|
-
if variables:
|
429
|
+
if variables is not False and "<<var:" in yaml_str:
|
416
430
|
yaml_str = substitute_string_vars(yaml_str, variables=variables)
|
417
431
|
yaml = YAML(typ=typ)
|
418
432
|
return yaml.load(yaml_str)
|
@@ -432,7 +446,7 @@ def write_YAML_file(obj, path: PathLike, typ="safe"):
|
|
432
446
|
|
433
447
|
|
434
448
|
def read_JSON_string(json_str: str, variables: Dict[str, str] = None):
|
435
|
-
if variables:
|
449
|
+
if variables is not False and "<<var:" in json_str:
|
436
450
|
json_str = substitute_string_vars(json_str, variables=variables)
|
437
451
|
return json.loads(json_str)
|
438
452
|
|
hpcflow/sdk/demo/cli.py
CHANGED
@@ -120,7 +120,7 @@ def get_demo_workflow_CLI(app):
|
|
120
120
|
store=store,
|
121
121
|
ts_fmt=ts_fmt,
|
122
122
|
ts_name_fmt=ts_name_fmt,
|
123
|
-
variables=variables,
|
123
|
+
variables=dict(variables),
|
124
124
|
)
|
125
125
|
click.echo(wk.path)
|
126
126
|
|
@@ -164,7 +164,7 @@ def get_demo_workflow_CLI(app):
|
|
164
164
|
store=store,
|
165
165
|
ts_fmt=ts_fmt,
|
166
166
|
ts_name_fmt=ts_name_fmt,
|
167
|
-
variables=variables,
|
167
|
+
variables=dict(variables),
|
168
168
|
JS_parallelism=js_parallelism,
|
169
169
|
wait=wait,
|
170
170
|
add_to_known=add_to_known,
|
hpcflow/tests/unit/test_utils.py
CHANGED
@@ -515,3 +515,16 @@ def test_substitute_string_vars_raise_missing():
|
|
515
515
|
|
516
516
|
def test_substitute_string_vars_non_str():
|
517
517
|
assert substitute_string_vars("<<var:a>>", variables={"a": 2}) == "2"
|
518
|
+
|
519
|
+
|
520
|
+
def test_substitute_string_vars_default_value():
|
521
|
+
assert substitute_string_vars("hello <<var:my_name[default=bill]>>!") == "hello bill!"
|
522
|
+
|
523
|
+
|
524
|
+
def test_substitute_string_vars_default_value_with_specified():
|
525
|
+
assert (
|
526
|
+
substitute_string_vars(
|
527
|
+
"hello <<var:my_name[default=bill]>>!", variables={"my_name": "bob"}
|
528
|
+
)
|
529
|
+
== "hello bob!"
|
530
|
+
)
|
@@ -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=
|
4
|
+
hpcflow/_version.py,sha256=hIoMm5ojG_YRRzcmbye_3NpTvZ051KBnJaOd1DAInzU,26
|
5
5
|
hpcflow/app.py,sha256=GQsMq_sjjXxMLLiIPF1ZvyapW_7IgsxALCCwMiqmC8I,1520
|
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
|
@@ -34,7 +34,7 @@ hpcflow/data/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
34
34
|
hpcflow/data/workflows/workflow_1.yaml,sha256=lF7Re2SVc_5gQk5AwB0gXaq-n-T5ia4su3zNQ9oMRV0,220
|
35
35
|
hpcflow/examples.ipynb,sha256=cLKp4QsxwwMXRanDnfWY9kqsV23q6G4raOpu6IZXnMw,28553
|
36
36
|
hpcflow/sdk/__init__.py,sha256=QN1hUM9MdJ5yB3ou8q3ky530TdSd8BJi1V4XI2NmT4k,5643
|
37
|
-
hpcflow/sdk/app.py,sha256=
|
37
|
+
hpcflow/sdk/app.py,sha256=5HkZ7DUQPyg081WW2jVVg_Ene_-1C7MOB6CTlqPTnTk,90416
|
38
38
|
hpcflow/sdk/cli.py,sha256=0ww5eqikpUcy-zNwpZiKgFs86lF1hymtDFXWau-E9UA,34624
|
39
39
|
hpcflow/sdk/cli_common.py,sha256=5lYYuwlP1D9kmULEk4r5iCT30hrx8sCjd40pttIfvh4,4257
|
40
40
|
hpcflow/sdk/config/__init__.py,sha256=qJrrxcAN4f1u_RyTtXgz-xlTLwNafE9v0VEMP1x6-bU,70
|
@@ -59,7 +59,7 @@ hpcflow/sdk/core/rule.py,sha256=chMn-Unu_4Mtc3T4z93OpmYcqOapqYAdBWuRSP8CBdg,4510
|
|
59
59
|
hpcflow/sdk/core/task.py,sha256=qX_LECPBK2ZESsSTvl_DQFN8IwULorJXy7g5WBwHpaE,108874
|
60
60
|
hpcflow/sdk/core/task_schema.py,sha256=T94-3KIoMaAlQc0Z51zqGDO46n6CUfE1Mwkvf9GVtXQ,31452
|
61
61
|
hpcflow/sdk/core/test_utils.py,sha256=9VwdOi4oPZ-fPXvLgJNRnRjLy2G4-We9lrOkbrzCVcQ,9334
|
62
|
-
hpcflow/sdk/core/utils.py,sha256=
|
62
|
+
hpcflow/sdk/core/utils.py,sha256=vgFc0_UD-2HWanUINT_e4VOffglP_H7RIcpuN-7AoQs,25015
|
63
63
|
hpcflow/sdk/core/validation.py,sha256=KBKiy5DdfGiGmMaB0HdKTY0V972u5dJzvkYkX0_KtCo,518
|
64
64
|
hpcflow/sdk/core/workflow.py,sha256=139wrrGPZfNyNpcb0TP_1892yOvPByqczJuQ-N1k5Kw,100608
|
65
65
|
hpcflow/sdk/core/zarr_io.py,sha256=V_Zm6uSiuaCbXyHFJUO74K1pAr4Zqrj3aLCBjohCwvs,5724
|
@@ -72,7 +72,7 @@ hpcflow/sdk/data/parameters_spec_schema.yaml,sha256=Wj7CvG7Ul1nZDtBca-oxeFH_aSZk
|
|
72
72
|
hpcflow/sdk/data/task_schema_spec_schema.yaml,sha256=6NROg7x-493bdvRwvY4M71R7POT-tNnmROkEsnnoL4k,93
|
73
73
|
hpcflow/sdk/data/workflow_spec_schema.yaml,sha256=LLUV6RsdgT2BQrEPNKLCUB5Uijt9wxT9Bac2PLyGha8,1797
|
74
74
|
hpcflow/sdk/demo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
75
|
-
hpcflow/sdk/demo/cli.py,sha256=
|
75
|
+
hpcflow/sdk/demo/cli.py,sha256=0W0SLt3c0ZtK1o3o7Uhxl_6Y5x-DJ_gb38fWCgFbKqg,5357
|
76
76
|
hpcflow/sdk/helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
77
77
|
hpcflow/sdk/helper/cli.py,sha256=QPVvhXEtY3n87ua_6eBh-osaQeEBgG7g7kUR4jghqtI,3491
|
78
78
|
hpcflow/sdk/helper/helper.py,sha256=MkjYKHox1F4XOpy-20sCCDUTWUbQY84QpWZkcpSq9n8,8143
|
@@ -139,14 +139,14 @@ hpcflow/tests/unit/test_slurm.py,sha256=ewfNuXXUEEelAxcd7MBbAQ-RCvU8xBenHTAyfXYF
|
|
139
139
|
hpcflow/tests/unit/test_submission.py,sha256=E8ku48TeCpAQlYDci30D-hf0YvzbT3jpm-emAaS02Is,15764
|
140
140
|
hpcflow/tests/unit/test_task.py,sha256=94TwyjlhKMRRXTQjys2a1PiK7A-rCzhnvrkk4vRz39I,70000
|
141
141
|
hpcflow/tests/unit/test_task_schema.py,sha256=7a7o42gQhrZPMXfH0a6sGzFCJnuFrbDEl9u3u_bFsgw,3624
|
142
|
-
hpcflow/tests/unit/test_utils.py,sha256=
|
142
|
+
hpcflow/tests/unit/test_utils.py,sha256=aWfhGDJWGlBfk7yi0hcrPlcd159MX0V0MwsndureeP8,13466
|
143
143
|
hpcflow/tests/unit/test_value_sequence.py,sha256=mEU_e5Bu0GzRjBGIgPbcu1MOcafd2bBn6Gz2b02U7jA,15258
|
144
144
|
hpcflow/tests/unit/test_workflow.py,sha256=-zLw-vytXbD9vEGrAQ9ZYLuNqVdxSe9OG0LgSoneTiU,22855
|
145
145
|
hpcflow/tests/unit/test_workflow_template.py,sha256=EItRqUyXpU2z_z1rvpRqa848YOkXiBRLMj3oF_m7Ybw,1328
|
146
146
|
hpcflow/tests/workflows/test_jobscript.py,sha256=9sp1o0g72JZbv2QlOl5v7wCZEFjotxiIKGNUxVaFgaA,724
|
147
147
|
hpcflow/tests/workflows/test_workflows.py,sha256=xai6FRtGqG4lStJk6KmsqPUSuvqs9FrsBOxMVALshIs,13400
|
148
148
|
hpcflow/viz_demo.ipynb,sha256=1QdnVsk72vihv2L6hOGyk318uEa22ZSgGxQCa7hW2oo,6238
|
149
|
-
hpcflow_new2-0.2.
|
150
|
-
hpcflow_new2-0.2.
|
151
|
-
hpcflow_new2-0.2.
|
152
|
-
hpcflow_new2-0.2.
|
149
|
+
hpcflow_new2-0.2.0a156.dist-info/METADATA,sha256=whrUKGf2XT9ab-U9YZVs4-iKE6HVoFuqBhsVOmOOKkU,2516
|
150
|
+
hpcflow_new2-0.2.0a156.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
|
151
|
+
hpcflow_new2-0.2.0a156.dist-info/entry_points.txt,sha256=aoGtCnFdfPcXfBdu2zZyMOJoz6fPgdR0elqsgrE-USU,106
|
152
|
+
hpcflow_new2-0.2.0a156.dist-info/RECORD,,
|
File without changes
|
File without changes
|