hpcflow-new2 0.2.0a108__py3-none-any.whl → 0.2.0a109__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.0a108"
1
+ __version__ = "0.2.0a109"
@@ -513,16 +513,14 @@ class ElementActionRun:
513
513
  outputs[out_typ] = self.get(f"outputs.{out_typ}")
514
514
  return outputs
515
515
 
516
- def compose_source(self) -> str:
516
+ def compose_source(self, snip_path: Path) -> str:
517
517
  """Generate the file contents of this source."""
518
518
 
519
- script_name = self.action.get_script_name(self.action.script)
520
- script_key = self.action.get_app_data_script_path(self.action.script)
521
- script_path = self.app.scripts.get(script_key)
522
- with script_path.open("rt") as fp:
519
+ script_name = snip_path.name
520
+ with snip_path.open("rt") as fp:
523
521
  script_str = fp.read()
524
522
 
525
- is_python = script_path.suffix == ".py"
523
+ is_python = snip_path.suffix == ".py"
526
524
  if is_python:
527
525
  py_imports = dedent(
528
526
  """\
@@ -639,10 +637,12 @@ class ElementActionRun:
639
637
 
640
638
  # write the script if it is specified as a app data script, otherwise we assume
641
639
  # the script already exists in the working directory:
642
- if self.action.script and self.action.is_app_data_script(self.action.script):
643
- script_name = self.action.get_script_name(self.action.script)
640
+ snip_path = self.action.get_snippet_script_path(self.action.script)
641
+ if snip_path:
642
+ script_name = snip_path.name
643
+ source_str = self.compose_source(snip_path)
644
644
  with Path(script_name).open("wt", newline="\n") as fp:
645
- fp.write(self.compose_source())
645
+ fp.write(source_str)
646
646
 
647
647
  def _param_dump_JSON(self, dump_path: Path):
648
648
  with dump_path.open("wt") as fp:
@@ -1358,15 +1358,16 @@ class Action(JSONLike):
1358
1358
  )
1359
1359
 
1360
1360
  @staticmethod
1361
- def is_app_data_script(script: str) -> bool:
1361
+ def is_snippet_script(script: str) -> bool:
1362
+ """Returns True if the provided script string represents a script snippets that is
1363
+ to be modified before execution (e.g. to receive and provide parameter data)."""
1362
1364
  return script.startswith("<<script:")
1363
1365
 
1364
1366
  @classmethod
1365
1367
  def get_script_name(cls, script: str) -> str:
1366
1368
  """Return the script name."""
1367
- if cls.is_app_data_script(script):
1368
- # an app data script:
1369
- pattern = r"\<\<script:(?:.*\/)*(.*:?)\>\>"
1369
+ if cls.is_snippet_script(script):
1370
+ pattern = r"\<\<script:(?:.*(?:\/|\\))*(.*)\>\>"
1370
1371
  match_obj = re.match(pattern, script)
1371
1372
  return match_obj.group(1)
1372
1373
  else:
@@ -1374,8 +1375,8 @@ class Action(JSONLike):
1374
1375
  return script
1375
1376
 
1376
1377
  @classmethod
1377
- def get_app_data_script_path(cls, script) -> str:
1378
- if not cls.is_app_data_script(script):
1378
+ def get_snippet_script_str(cls, script) -> str:
1379
+ if not cls.is_snippet_script(script):
1379
1380
  raise ValueError(
1380
1381
  f"Must be an app-data script name (e.g. "
1381
1382
  f"<<script:path/to/app/data/script.py>>), but received {script}"
@@ -1384,6 +1385,17 @@ class Action(JSONLike):
1384
1385
  match_obj = re.match(pattern, script)
1385
1386
  return match_obj.group(1)
1386
1387
 
1388
+ @classmethod
1389
+ def get_snippet_script_path(cls, script_path) -> Path:
1390
+ if not cls.is_snippet_script(script_path):
1391
+ return False
1392
+
1393
+ path = cls.get_snippet_script_str(script_path)
1394
+ if path in cls.app.scripts:
1395
+ path = cls.app.scripts.get(path)
1396
+
1397
+ return Path(path)
1398
+
1387
1399
  @staticmethod
1388
1400
  def get_param_dump_file_stem(js_idx: int, js_act_idx: int):
1389
1401
  return f"js_{js_idx}_act_{js_act_idx}_inputs"
@@ -134,12 +134,9 @@ class InputFileGenerator(JSONLike):
134
134
  def compose_source(self, action) -> str:
135
135
  """Generate the file contents of this input file generator source."""
136
136
 
137
- script_name = self.script
138
- script_key = action.get_app_data_script_path(self.script)
139
- script_path = self.app.scripts.get(script_key)
140
- script_main_func = Path(script_name).stem
141
-
142
- with script_path.open("rt") as fp:
137
+ snip_path = action.get_snippet_script_path(self.script)
138
+ script_main_func = snip_path.stem
139
+ with snip_path.open("rt") as fp:
143
140
  script_str = fp.read()
144
141
 
145
142
  main_block = dedent(
@@ -261,12 +258,9 @@ class OutputFileParser(JSONLike):
261
258
  def compose_source(self, action) -> str:
262
259
  """Generate the file contents of this output file parser source."""
263
260
 
264
- script_name = self.script
265
- script_key = action.get_app_data_script_path(self.script)
266
- script_path = self.app.scripts.get(script_key)
267
- script_main_func = Path(script_name).stem
268
-
269
- with script_path.open("rt") as fp:
261
+ snip_path = action.get_snippet_script_path(self.script)
262
+ script_main_func = snip_path.stem
263
+ with snip_path.open("rt") as fp:
270
264
  script_str = fp.read()
271
265
 
272
266
  main_block = dedent(
@@ -217,6 +217,27 @@ class TaskSchema(JSONLike):
217
217
  tab_cmds_i = Table(show_header=False, box=None)
218
218
  tab_cmds_i.add_column(justify="right")
219
219
  tab_cmds_i.add_column()
220
+ if act.rules:
221
+ seen_rules = [] # bug: some rules seem to be repeated
222
+ for act_rule_j in act.rules:
223
+ if act_rule_j.rule in seen_rules:
224
+ continue
225
+ else:
226
+ seen_rules.append(act_rule_j.rule)
227
+ r_path = ""
228
+ if act_rule_j.rule.check_missing:
229
+ r_cond = f"check missing: {act_rule_j.rule.check_missing}"
230
+ elif act_rule_j.rule.check_exists:
231
+ r_cond = f"check exists: {act_rule_j.rule.check_exists}"
232
+ elif act_rule_j.rule.condition:
233
+ r_path = f"{act_rule_j.rule.path}: "
234
+ r_cond = str(act_rule_j.rule.condition.to_json_like())
235
+ else:
236
+ continue
237
+ tab_cmds_i.add_row(
238
+ "[italic]rule:[/italic]",
239
+ escape(f"{r_path}{r_cond}"),
240
+ )
220
241
  tab_cmds_i.add_row(
221
242
  "[italic]scope:[/italic]",
222
243
  escape(act.get_precise_scope().to_string()),
@@ -1,3 +1,4 @@
1
+ from pathlib import Path
1
2
  import pytest
2
3
 
3
4
  from hpcflow.app import app as hf
@@ -215,3 +216,39 @@ def test_get_command_input_types_label_sub_parameters_false_no_sub_param():
215
216
  def test_get_command_input_types_label_sub_parameters_false_with_sub_parameter():
216
217
  act = hf.Action(commands=[hf.Command("Write-Output (<<parameter:p1[one].a>> + 100)")])
217
218
  assert act.get_command_input_types(sub_parameters=False) == ("p1[one]",)
219
+
220
+
221
+ def test_get_script_name(null_config):
222
+ expected = {
223
+ "<<script:/software/hello.py>>": "hello.py",
224
+ "<<script:software/hello.py>>": "hello.py",
225
+ r"<<script:C:\long\path\to\script.py>>": "script.py",
226
+ "/path/to/script.py": "/path/to/script.py",
227
+ }
228
+ for k, v in expected.items():
229
+ assert hf.Action.get_script_name(k) == v
230
+
231
+
232
+ def test_is_snippet_script(null_config):
233
+ expected = {
234
+ "<<script:/software/hello.py>>": True,
235
+ "<<script:software/hello.py>>": True,
236
+ r"<<script:C:\long\path\to\script.py>>": True,
237
+ "/path/to/script.py": False,
238
+ }
239
+ for k, v in expected.items():
240
+ assert hf.Action.is_snippet_script(k) == v
241
+
242
+
243
+ def test_get_snippet_script_path(null_config):
244
+ expected = {
245
+ "<<script:/software/hello.py>>": Path("/software/hello.py"),
246
+ "<<script:software/hello.py>>": Path("software/hello.py"),
247
+ r"<<script:C:\long\path\to\script.py>>": Path(r"C:\long\path\to\script.py"),
248
+ }
249
+ for k, v in expected.items():
250
+ assert hf.Action.get_snippet_script_path(k) == v
251
+
252
+
253
+ def test_get_snippet_script_path_False(null_config):
254
+ assert not hf.Action.get_snippet_script_path("/path/to/script.py")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hpcflow-new2
3
- Version: 0.2.0a108
3
+ Version: 0.2.0a109
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=xyEXMIKYRpy0cf3N2ksLEbZxNb6Bw9WOYbLuuj4t1qM,924
4
- hpcflow/_version.py,sha256=jlvKXkU9xWla9lXzwjlPC-YeGbUpXqlx4tvVkVza2Pc,26
4
+ hpcflow/_version.py,sha256=Nkwb1thRPq6eII0fnUVrpgGvVYJ0wpqCGaJ0ybaTlvE,26
5
5
  hpcflow/app.py,sha256=CMr8XlaGbAEQ0uvKrmnhnYw7TSQ7KhVkOUbLioecjL4,1377
6
6
  hpcflow/cli.py,sha256=G2J3D9v6MnMWOWMMWK6UEKLn_6wnV9lT_qygEBBxg-I,66
7
7
  hpcflow/examples.ipynb,sha256=cLKp4QsxwwMXRanDnfWY9kqsV23q6G4raOpu6IZXnMw,28553
@@ -16,8 +16,8 @@ hpcflow/sdk/config/config.py,sha256=0HLUtoah3kWm985rwuvvOsoIQxEw0yzm838kfcv3O90,
16
16
  hpcflow/sdk/config/config_file.py,sha256=JlMcprj0aujFVk8552ahP2f8EXB0tglMaHwzbcGZH6w,12373
17
17
  hpcflow/sdk/config/errors.py,sha256=2D7HJ1dbyeoD3xk4MuaGSsbJsUyQzyw8kaThEBZfP2I,6876
18
18
  hpcflow/sdk/core/__init__.py,sha256=GcIklEsXy3M5PWpmxyhd2KoI0u6HjXRIjD_aR1bgRjo,215
19
- hpcflow/sdk/core/actions.py,sha256=H4TmDaJI4F8w1_5vu4kv88_yI-PvAr49qZx3EbbXgUA,63146
20
- hpcflow/sdk/core/command_files.py,sha256=3eHU5IByDnLVQWRLwkSHhDhNM-MdnmEgLsmGcZJe51g,17139
19
+ hpcflow/sdk/core/actions.py,sha256=r8ZiPsOYmgdY7DIywjoK-_c6gos4JHoqhzQreQozgDs,63480
20
+ hpcflow/sdk/core/command_files.py,sha256=vdxpQYDfyg2EoytsTD5NzsOsZNypHwBq0Gu6IkQSnGo,16935
21
21
  hpcflow/sdk/core/commands.py,sha256=1nVU_E7QntuY0FiNluhf_ouxu3ML4KoRqwvbfsqXOz0,11061
22
22
  hpcflow/sdk/core/element.py,sha256=HBX1mGpgr_UNFvvC4zJJ1tI6SH2qCQxA0-_3Onh6SYQ,44524
23
23
  hpcflow/sdk/core/environment.py,sha256=DGUz1NvliKh6opP0IueGHD69rn_8wFLhDsq6kAmEgM4,4849
@@ -29,7 +29,7 @@ hpcflow/sdk/core/parallel.py,sha256=LI-g-qOuOR1oaEUWVT0qW0hmiP9hsJyUP8_IfSTKYYo,
29
29
  hpcflow/sdk/core/parameters.py,sha256=KZc0BLqPkbMIcsCerDgQ1zPQQ33s0LsCUfmR_hFy0GM,60462
30
30
  hpcflow/sdk/core/rule.py,sha256=chMn-Unu_4Mtc3T4z93OpmYcqOapqYAdBWuRSP8CBdg,4510
31
31
  hpcflow/sdk/core/task.py,sha256=MIleH_ahiLlPe1cDRAJ4rolFJLN0ixum_faJRMSB7Jk,103373
32
- hpcflow/sdk/core/task_schema.py,sha256=BW6Gr1lNEdOHmGzHKY71LRcCaFZSrlJ9LIc4iFoySyA,17352
32
+ hpcflow/sdk/core/task_schema.py,sha256=Z6yxywwVmF8a4ITumhqC8mZNwUYk32UHB7UMY4SGKkU,18471
33
33
  hpcflow/sdk/core/test_utils.py,sha256=Zrun61DdJWngVMneXhpJCp6nXbjS0OLfoSM1BT_55VI,6660
34
34
  hpcflow/sdk/core/utils.py,sha256=QHzVae2b3JheweeNWHbQjKB-kFHRwv0pBYpP2HY1QGo,19836
35
35
  hpcflow/sdk/core/validation.py,sha256=KBKiy5DdfGiGmMaB0HdKTY0V972u5dJzvkYkX0_KtCo,518
@@ -98,7 +98,7 @@ hpcflow/tests/conftest.py,sha256=Xjyq9tjVdFGIf5HD1G0iZ1V_-cJAYC6A240OX8eBexU,261
98
98
  hpcflow/tests/schedulers/direct_linux/test_direct_linux_submission.py,sha256=pgHHG4iak0tx-1JTtpo8sCIvcZF2XayzEysjqWa_9LM,456
99
99
  hpcflow/tests/schedulers/slurm/test_slurm_submission.py,sha256=XMv_0YQ6GUeDPpQ4tO2LEm_kT_A40t_JzK8v-gl-ji8,442
100
100
  hpcflow/tests/shells/wsl/test_wsl_submission.py,sha256=cRkl_1H2Y4k91TJOX9wXZthW8AJFuuWuQ8X98624JDw,589
101
- hpcflow/tests/unit/test_action.py,sha256=JP0g3Eb6wZOVeoQ2o7Bf7pB6VAruTvp8qFaTydmGN2U,7841
101
+ hpcflow/tests/unit/test_action.py,sha256=qh8v9GhFxkK7zmBqHyjWQh6vlJYXADLysPE_qhmvEqo,9078
102
102
  hpcflow/tests/unit/test_action_rule.py,sha256=r3G7-EEdsF1ND6kCOGI0S6N9WLi1vd3OABRIp6EvtMA,547
103
103
  hpcflow/tests/unit/test_app.py,sha256=W89TvXt9AD9AEn0tBkZgmEpiEeg1R_SpuQLV2tjQSAs,2916
104
104
  hpcflow/tests/unit/test_cli.py,sha256=9oQZOlX0z5LC4e2JFLuIgGnUXgmR2RCAtbXR5XRwqJs,288
@@ -128,7 +128,7 @@ hpcflow/tests/unit/test_workflow.py,sha256=zHM9KCkbEupKocrnTOkYagas7amXSpj9QNuEG
128
128
  hpcflow/tests/unit/test_workflow_template.py,sha256=4AFA2d4ZYOHdOJEH485D-fg8x1O-psZ0Qr2kOlrCc88,963
129
129
  hpcflow/tests/workflows/test_workflows.py,sha256=xWx2x70_3WdGR0ijgjk2F5Tg_V9YRCgN0E02ZFUi9Hk,13390
130
130
  hpcflow/viz_demo.ipynb,sha256=1QdnVsk72vihv2L6hOGyk318uEa22ZSgGxQCa7hW2oo,6238
131
- hpcflow_new2-0.2.0a108.dist-info/METADATA,sha256=CETQcTbiIA4dFWfL169ZLTLkLNFinnCUT2HpRHqoCWo,1879
132
- hpcflow_new2-0.2.0a108.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
133
- hpcflow_new2-0.2.0a108.dist-info/entry_points.txt,sha256=aoGtCnFdfPcXfBdu2zZyMOJoz6fPgdR0elqsgrE-USU,106
134
- hpcflow_new2-0.2.0a108.dist-info/RECORD,,
131
+ hpcflow_new2-0.2.0a109.dist-info/METADATA,sha256=Km5lIPZ33qmI4LpUEyqcMvh58koOEjj0tXrqJF19rhw,1879
132
+ hpcflow_new2-0.2.0a109.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
133
+ hpcflow_new2-0.2.0a109.dist-info/entry_points.txt,sha256=aoGtCnFdfPcXfBdu2zZyMOJoz6fPgdR0elqsgrE-USU,106
134
+ hpcflow_new2-0.2.0a109.dist-info/RECORD,,