hpcflow-new2 0.2.0a50__py3-none-any.whl → 0.2.0a52__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 (38) hide show
  1. hpcflow/_version.py +1 -1
  2. hpcflow/sdk/__init__.py +1 -1
  3. hpcflow/sdk/api.py +1 -1
  4. hpcflow/sdk/app.py +20 -11
  5. hpcflow/sdk/cli.py +34 -59
  6. hpcflow/sdk/core/__init__.py +13 -1
  7. hpcflow/sdk/core/actions.py +235 -126
  8. hpcflow/sdk/core/command_files.py +32 -24
  9. hpcflow/sdk/core/element.py +110 -114
  10. hpcflow/sdk/core/errors.py +57 -0
  11. hpcflow/sdk/core/loop.py +18 -34
  12. hpcflow/sdk/core/parameters.py +5 -3
  13. hpcflow/sdk/core/task.py +135 -131
  14. hpcflow/sdk/core/task_schema.py +11 -4
  15. hpcflow/sdk/core/utils.py +110 -2
  16. hpcflow/sdk/core/workflow.py +964 -676
  17. hpcflow/sdk/data/template_components/environments.yaml +0 -44
  18. hpcflow/sdk/data/template_components/task_schemas.yaml +52 -10
  19. hpcflow/sdk/persistence/__init__.py +21 -33
  20. hpcflow/sdk/persistence/base.py +1340 -458
  21. hpcflow/sdk/persistence/json.py +424 -546
  22. hpcflow/sdk/persistence/pending.py +563 -0
  23. hpcflow/sdk/persistence/store_resource.py +131 -0
  24. hpcflow/sdk/persistence/utils.py +57 -0
  25. hpcflow/sdk/persistence/zarr.py +852 -841
  26. hpcflow/sdk/submission/jobscript.py +133 -112
  27. hpcflow/sdk/submission/shells/bash.py +62 -16
  28. hpcflow/sdk/submission/shells/powershell.py +87 -16
  29. hpcflow/sdk/submission/submission.py +59 -35
  30. hpcflow/tests/unit/test_element.py +4 -9
  31. hpcflow/tests/unit/test_persistence.py +218 -0
  32. hpcflow/tests/unit/test_task.py +11 -12
  33. hpcflow/tests/unit/test_utils.py +82 -0
  34. hpcflow/tests/unit/test_workflow.py +3 -1
  35. {hpcflow_new2-0.2.0a50.dist-info → hpcflow_new2-0.2.0a52.dist-info}/METADATA +3 -1
  36. {hpcflow_new2-0.2.0a50.dist-info → hpcflow_new2-0.2.0a52.dist-info}/RECORD +38 -34
  37. {hpcflow_new2-0.2.0a50.dist-info → hpcflow_new2-0.2.0a52.dist-info}/WHEEL +0 -0
  38. {hpcflow_new2-0.2.0a50.dist-info → hpcflow_new2-0.2.0a52.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,57 @@
1
+ from getpass import getpass
2
+ from paramiko.ssh_exception import SSHException
3
+
4
+ from hpcflow.sdk.core.errors import WorkflowNotFoundError
5
+
6
+
7
+ def ask_pw_on_auth_exc(f, *args, add_pw_to=None, **kwargs):
8
+ try:
9
+ out = f(*args, **kwargs)
10
+ pw = None
11
+
12
+ except SSHException:
13
+ pw = getpass()
14
+
15
+ if not add_pw_to:
16
+ kwargs["password"] = pw
17
+ else:
18
+ kwargs[add_pw_to]["password"] = pw
19
+
20
+ out = f(*args, **kwargs)
21
+
22
+ if not add_pw_to:
23
+ del kwargs["password"]
24
+ else:
25
+ del kwargs[add_pw_to]["password"]
26
+
27
+ return out, pw
28
+
29
+
30
+ def infer_store(path: str, fs) -> str:
31
+ """Identify the store type using the path and file system parsed by fsspec.
32
+
33
+ Parameters
34
+ ----------
35
+ fs
36
+ fsspec file system
37
+
38
+ """
39
+ # try to identify store type just from the path string:
40
+ if path.endswith(".zip"):
41
+ store_fmt = "zip"
42
+
43
+ elif path.endswith(".json"):
44
+ store_fmt = "json-single"
45
+
46
+ else:
47
+ # look at the directory contents:
48
+ if fs.glob(f"{path}/.zattrs"):
49
+ store_fmt = "zarr"
50
+ elif fs.glob(f"{path}/metadata.json"):
51
+ store_fmt = "json"
52
+ else:
53
+ raise WorkflowNotFoundError(
54
+ f"Cannot infer a store format at path {path!r} with file system {fs!r}."
55
+ )
56
+
57
+ return store_fmt