hpcflow-new2 0.2.0a179__py3-none-any.whl → 0.2.0a180__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 (70) hide show
  1. hpcflow/_version.py +1 -1
  2. hpcflow/data/demo_data_manifest/__init__.py +3 -0
  3. hpcflow/sdk/__init__.py +4 -1
  4. hpcflow/sdk/app.py +160 -15
  5. hpcflow/sdk/cli.py +14 -0
  6. hpcflow/sdk/cli_common.py +83 -0
  7. hpcflow/sdk/config/__init__.py +4 -0
  8. hpcflow/sdk/config/callbacks.py +25 -2
  9. hpcflow/sdk/config/cli.py +4 -1
  10. hpcflow/sdk/config/config.py +188 -14
  11. hpcflow/sdk/config/config_file.py +91 -3
  12. hpcflow/sdk/config/errors.py +33 -0
  13. hpcflow/sdk/core/__init__.py +2 -0
  14. hpcflow/sdk/core/actions.py +492 -35
  15. hpcflow/sdk/core/cache.py +22 -0
  16. hpcflow/sdk/core/command_files.py +221 -5
  17. hpcflow/sdk/core/commands.py +57 -0
  18. hpcflow/sdk/core/element.py +407 -8
  19. hpcflow/sdk/core/environment.py +92 -0
  20. hpcflow/sdk/core/errors.py +245 -61
  21. hpcflow/sdk/core/json_like.py +72 -14
  22. hpcflow/sdk/core/loop.py +122 -21
  23. hpcflow/sdk/core/loop_cache.py +34 -9
  24. hpcflow/sdk/core/object_list.py +172 -26
  25. hpcflow/sdk/core/parallel.py +14 -0
  26. hpcflow/sdk/core/parameters.py +478 -25
  27. hpcflow/sdk/core/rule.py +31 -1
  28. hpcflow/sdk/core/run_dir_files.py +12 -2
  29. hpcflow/sdk/core/task.py +407 -80
  30. hpcflow/sdk/core/task_schema.py +70 -9
  31. hpcflow/sdk/core/test_utils.py +35 -0
  32. hpcflow/sdk/core/utils.py +101 -4
  33. hpcflow/sdk/core/validation.py +13 -1
  34. hpcflow/sdk/core/workflow.py +316 -96
  35. hpcflow/sdk/core/zarr_io.py +23 -0
  36. hpcflow/sdk/data/__init__.py +13 -0
  37. hpcflow/sdk/demo/__init__.py +3 -0
  38. hpcflow/sdk/helper/__init__.py +3 -0
  39. hpcflow/sdk/helper/cli.py +9 -0
  40. hpcflow/sdk/helper/helper.py +28 -0
  41. hpcflow/sdk/helper/watcher.py +33 -0
  42. hpcflow/sdk/log.py +40 -0
  43. hpcflow/sdk/persistence/__init__.py +14 -4
  44. hpcflow/sdk/persistence/base.py +289 -23
  45. hpcflow/sdk/persistence/json.py +29 -0
  46. hpcflow/sdk/persistence/pending.py +217 -107
  47. hpcflow/sdk/persistence/store_resource.py +58 -2
  48. hpcflow/sdk/persistence/utils.py +8 -0
  49. hpcflow/sdk/persistence/zarr.py +68 -1
  50. hpcflow/sdk/runtime.py +52 -10
  51. hpcflow/sdk/submission/__init__.py +3 -0
  52. hpcflow/sdk/submission/jobscript.py +198 -9
  53. hpcflow/sdk/submission/jobscript_info.py +13 -0
  54. hpcflow/sdk/submission/schedulers/__init__.py +60 -0
  55. hpcflow/sdk/submission/schedulers/direct.py +53 -0
  56. hpcflow/sdk/submission/schedulers/sge.py +45 -7
  57. hpcflow/sdk/submission/schedulers/slurm.py +45 -8
  58. hpcflow/sdk/submission/schedulers/utils.py +4 -0
  59. hpcflow/sdk/submission/shells/__init__.py +11 -1
  60. hpcflow/sdk/submission/shells/base.py +32 -1
  61. hpcflow/sdk/submission/shells/bash.py +36 -1
  62. hpcflow/sdk/submission/shells/os_version.py +18 -6
  63. hpcflow/sdk/submission/shells/powershell.py +22 -0
  64. hpcflow/sdk/submission/submission.py +88 -3
  65. hpcflow/sdk/typing.py +10 -1
  66. {hpcflow_new2-0.2.0a179.dist-info → hpcflow_new2-0.2.0a180.dist-info}/METADATA +1 -1
  67. {hpcflow_new2-0.2.0a179.dist-info → hpcflow_new2-0.2.0a180.dist-info}/RECORD +70 -70
  68. {hpcflow_new2-0.2.0a179.dist-info → hpcflow_new2-0.2.0a180.dist-info}/LICENSE +0 -0
  69. {hpcflow_new2-0.2.0a179.dist-info → hpcflow_new2-0.2.0a180.dist-info}/WHEEL +0 -0
  70. {hpcflow_new2-0.2.0a179.dist-info → hpcflow_new2-0.2.0a180.dist-info}/entry_points.txt +0 -0
@@ -1,3 +1,7 @@
1
+ """
2
+ General model of a searchable serializable list.
3
+ """
4
+
1
5
  import copy
2
6
  from types import SimpleNamespace
3
7
 
@@ -5,29 +9,25 @@ from hpcflow.sdk.core.json_like import ChildObjectSpec, JSONLike
5
9
 
6
10
 
7
11
  class ObjectListMultipleMatchError(ValueError):
8
- pass
12
+ """
13
+ Thrown when an object looked up by unique attribute ends up with multiple objects
14
+ being matched.
15
+ """
9
16
 
10
17
 
11
18
  class ObjectList(JSONLike):
12
19
  """A list-like class that provides item access via a `get` method according to
13
20
  attributes or dict-keys.
14
21
 
22
+ Parameters
23
+ ----------
24
+ objects : sequence
25
+ List
26
+ descriptor : str
27
+ Descriptive name for objects in the list.
15
28
  """
16
29
 
17
30
  def __init__(self, objects, descriptor=None):
18
- """
19
-
20
- Parameters
21
- ----------
22
- objects : sequence
23
- List
24
- access_attribute : str
25
- Name of the attribute through which objects are accessed. The values must be
26
- hashable.
27
- descriptor : str
28
-
29
- """
30
-
31
31
  self._objects = list(objects)
32
32
  self._descriptor = descriptor or "object"
33
33
  self._object_is_dict = False
@@ -145,6 +145,22 @@ class ObjectList(JSONLike):
145
145
  return self._validate_get(self.get_all(**kwargs), kwargs)
146
146
 
147
147
  def add_object(self, obj, index=-1, skip_duplicates=False):
148
+ """
149
+ Add an object to this object list.
150
+
151
+ Parameters
152
+ ----------
153
+ obj:
154
+ The object to add.
155
+ index:
156
+ Where to add it. Omit to append.
157
+ skip_duplicates:
158
+ If true, don't add the object if it is already in the list.
159
+
160
+ Returns
161
+ -------
162
+ The index of the added object, or ``None`` if the object was not added.
163
+ """
148
164
  if skip_duplicates and obj in self:
149
165
  return
150
166
 
@@ -160,8 +176,19 @@ class ObjectList(JSONLike):
160
176
 
161
177
 
162
178
  class DotAccessObjectList(ObjectList):
163
- """Provide dot-notation access via an access attribute for the case where the access
164
- attribute uniquely identifies a single object."""
179
+ """
180
+ Provide dot-notation access via an access attribute for the case where the access
181
+ attribute uniquely identifies a single object.
182
+
183
+ Parameters
184
+ ----------
185
+ _objects:
186
+ The objects in the list.
187
+ access_attribute:
188
+ The main attribute for selection and filtering. A unique property.
189
+ descriptor: str
190
+ Descriptive name for the objects in the list.
191
+ """
165
192
 
166
193
  # access attributes must not be named after any "public" methods, to avoid confusion!
167
194
  _pub_methods = ("get", "get_all", "add_object", "add_objects")
@@ -233,6 +260,9 @@ class DotAccessObjectList(ObjectList):
233
260
  ]
234
261
 
235
262
  def get(self, access_attribute_value=None, **kwargs):
263
+ """
264
+ Get an object from this list that matches the given criteria.
265
+ """
236
266
  vld_get_kwargs = kwargs
237
267
  if access_attribute_value:
238
268
  vld_get_kwargs = {self._access_attribute: access_attribute_value, **kwargs}
@@ -243,6 +273,9 @@ class DotAccessObjectList(ObjectList):
243
273
  )
244
274
 
245
275
  def get_all(self, access_attribute_value=None, **kwargs):
276
+ """
277
+ Get all objects in this list that match the given criteria.
278
+ """
246
279
  # use the index to narrow down the search first:
247
280
  if access_attribute_value:
248
281
  try:
@@ -260,11 +293,17 @@ class DotAccessObjectList(ObjectList):
260
293
  return self._get_all_from_objs(all_objs, **kwargs)
261
294
 
262
295
  def add_object(self, obj, index=-1, skip_duplicates=False):
296
+ """
297
+ Add an object to this list.
298
+ """
263
299
  index = super().add_object(obj, index, skip_duplicates)
264
300
  self._update_index()
265
301
  return index
266
302
 
267
303
  def add_objects(self, objs, index=-1, skip_duplicates=False):
304
+ """
305
+ Add multiple objects to the list.
306
+ """
268
307
  for obj in objs:
269
308
  index = self.add_object(obj, index, skip_duplicates)
270
309
  if index is not None:
@@ -273,6 +312,10 @@ class DotAccessObjectList(ObjectList):
273
312
 
274
313
 
275
314
  class AppDataList(DotAccessObjectList):
315
+ """
316
+ An application-aware object list.
317
+ """
318
+
276
319
  _app_attr = "_app"
277
320
 
278
321
  def to_dict(self):
@@ -281,11 +324,20 @@ class AppDataList(DotAccessObjectList):
281
324
  @classmethod
282
325
  def from_json_like(cls, json_like, shared_data=None, is_hashed: bool = False):
283
326
  """
327
+ Make an instance of this class from JSON (or YAML) data.
328
+
284
329
  Parameters
285
330
  ----------
286
- is_hashed
331
+ json_like:
332
+ The data to deserialise.
333
+ shared_data:
334
+ Shared context data.
335
+ is_hashed:
287
336
  If True, accept a dict whose keys are hashes of the dict values.
288
337
 
338
+ Returns
339
+ -------
340
+ The deserialised object.
289
341
  """
290
342
  if is_hashed:
291
343
  json_like = [
@@ -303,7 +355,13 @@ class AppDataList(DotAccessObjectList):
303
355
 
304
356
  class TaskList(AppDataList):
305
357
  """A list-like container for a task-like list with dot-notation access by task
306
- unique-name."""
358
+ unique-name.
359
+
360
+ Parameters
361
+ ----------
362
+ _objects: list[~hpcflow.app.Task]
363
+ The tasks in this list.
364
+ """
307
365
 
308
366
  _child_objects = (
309
367
  ChildObjectSpec(
@@ -320,7 +378,13 @@ class TaskList(AppDataList):
320
378
 
321
379
  class TaskTemplateList(AppDataList):
322
380
  """A list-like container for a task-like list with dot-notation access by task
323
- unique-name."""
381
+ unique-name.
382
+
383
+ Parameters
384
+ ----------
385
+ _objects: list[~hpcflow.app.TaskTemplate]
386
+ The task templates in this list.
387
+ """
324
388
 
325
389
  _child_objects = (
326
390
  ChildObjectSpec(
@@ -337,7 +401,13 @@ class TaskTemplateList(AppDataList):
337
401
 
338
402
  class TaskSchemasList(AppDataList):
339
403
  """A list-like container for a task schema list with dot-notation access by task
340
- schema unique-name."""
404
+ schema unique-name.
405
+
406
+ Parameters
407
+ ----------
408
+ _objects: list[~hpcflow.app.TaskSchema]
409
+ The task schemas in this list.
410
+ """
341
411
 
342
412
  _child_objects = (
343
413
  ChildObjectSpec(
@@ -354,7 +424,13 @@ class TaskSchemasList(AppDataList):
354
424
 
355
425
  class GroupList(AppDataList):
356
426
  """A list-like container for the task schema group list with dot-notation access by
357
- group name."""
427
+ group name.
428
+
429
+ Parameters
430
+ ----------
431
+ _objects: list[Group]
432
+ The groups in this list.
433
+ """
358
434
 
359
435
  _child_objects = (
360
436
  ChildObjectSpec(
@@ -370,7 +446,14 @@ class GroupList(AppDataList):
370
446
 
371
447
 
372
448
  class EnvironmentsList(AppDataList):
373
- """A list-like container for environments with dot-notation access by name."""
449
+ """
450
+ A list-like container for environments with dot-notation access by name.
451
+
452
+ Parameters
453
+ ----------
454
+ _objects: list[~hpcflow.app.Environment]
455
+ The environments in this list.
456
+ """
374
457
 
375
458
  _child_objects = (
376
459
  ChildObjectSpec(
@@ -393,9 +476,17 @@ class EnvironmentsList(AppDataList):
393
476
 
394
477
 
395
478
  class ExecutablesList(AppDataList):
396
- """A list-like container for environment executables with dot-notation access by
397
- executable label."""
479
+ """
480
+ A list-like container for environment executables with dot-notation access by
481
+ executable label.
482
+
483
+ Parameters
484
+ ----------
485
+ _objects: list[~hpcflow.app.Executable]
486
+ The executables in this list.
487
+ """
398
488
 
489
+ #: The environment containing these executables.
399
490
  environment = None
400
491
  _child_objects = (
401
492
  ChildObjectSpec(
@@ -418,7 +509,14 @@ class ExecutablesList(AppDataList):
418
509
 
419
510
 
420
511
  class ParametersList(AppDataList):
421
- """A list-like container for parameters with dot-notation access by parameter type."""
512
+ """
513
+ A list-like container for parameters with dot-notation access by parameter type.
514
+
515
+ Parameters
516
+ ----------
517
+ _objects: list[~hpcflow.app.Parameter]
518
+ The parameters in this list.
519
+ """
422
520
 
423
521
  _child_objects = (
424
522
  ChildObjectSpec(
@@ -455,7 +553,14 @@ class ParametersList(AppDataList):
455
553
 
456
554
 
457
555
  class CommandFilesList(AppDataList):
458
- """A list-like container for command files with dot-notation access by label."""
556
+ """
557
+ A list-like container for command files with dot-notation access by label.
558
+
559
+ Parameters
560
+ ----------
561
+ _objects: list[~hpcflow.app.FileSpec]
562
+ The files in this list.
563
+ """
459
564
 
460
565
  _child_objects = (
461
566
  ChildObjectSpec(
@@ -471,6 +576,15 @@ class CommandFilesList(AppDataList):
471
576
 
472
577
 
473
578
  class WorkflowTaskList(DotAccessObjectList):
579
+ """
580
+ A list-like container for workflow tasks with dot-notation access by unique name.
581
+
582
+ Parameters
583
+ ----------
584
+ _objects: list[~hpcflow.app.WorkflowTask]
585
+ The tasks in this list.
586
+ """
587
+
474
588
  def __init__(self, _objects):
475
589
  super().__init__(_objects, access_attribute="unique_name", descriptor="task")
476
590
 
@@ -491,6 +605,15 @@ class WorkflowTaskList(DotAccessObjectList):
491
605
 
492
606
 
493
607
  class WorkflowLoopList(DotAccessObjectList):
608
+ """
609
+ A list-like container for workflow loops with dot-notation access by name.
610
+
611
+ Parameters
612
+ ----------
613
+ _objects: list[~hpcflow.app.WorkflowLoop]
614
+ The loops in this list.
615
+ """
616
+
494
617
  def __init__(self, _objects):
495
618
  super().__init__(_objects, access_attribute="name", descriptor="loop")
496
619
 
@@ -499,6 +622,16 @@ class WorkflowLoopList(DotAccessObjectList):
499
622
 
500
623
 
501
624
  class ResourceList(ObjectList):
625
+ """
626
+ A list-like container for resources.
627
+ Each contained resource must have a unique scope.
628
+
629
+ Parameters
630
+ ----------
631
+ _objects: list[~hpcflow.app.ResourceSpec]
632
+ The resource descriptions in this list.
633
+ """
634
+
502
635
  _app_attr = "_app"
503
636
  _child_objects = (
504
637
  ChildObjectSpec(
@@ -534,10 +667,16 @@ class ResourceList(ObjectList):
534
667
 
535
668
  @property
536
669
  def element_set(self):
670
+ """
671
+ The parent element set, if a child of an element set.
672
+ """
537
673
  return self._element_set
538
674
 
539
675
  @property
540
676
  def workflow_template(self):
677
+ """
678
+ The parent workflow template, if a child of a workflow template.
679
+ """
541
680
  return self._workflow_template
542
681
 
543
682
  def to_json_like(self, dct=None, shared_data=None, exclude=None, path=None):
@@ -581,6 +720,9 @@ class ResourceList(ObjectList):
581
720
  return resources
582
721
 
583
722
  def get_scopes(self):
723
+ """
724
+ Get the scopes of the contained resources.
725
+ """
584
726
  return tuple(i.scope for i in self._objects)
585
727
 
586
728
  def merge_other(self, other):
@@ -603,6 +745,10 @@ class ResourceList(ObjectList):
603
745
 
604
746
 
605
747
  def index(obj_lst, obj):
748
+ """
749
+ Get the index of the object in the list.
750
+ The item is checked for by object identity, not equality.
751
+ """
606
752
  for idx, i in enumerate(obj_lst._objects):
607
753
  if obj is i:
608
754
  return idx
@@ -1,7 +1,21 @@
1
+ """
2
+ Parallel modes.
3
+ """
4
+
1
5
  import enum
2
6
 
3
7
 
4
8
  class ParallelMode(enum.Enum):
9
+ """
10
+ Potential parallel modes.
11
+
12
+ Note: this is not yet implemented in any meaningful way!
13
+
14
+ """
15
+
16
+ #: Use distributed-memory parallelism (e.g. MPI).
5
17
  DISTRIBUTED = 0
18
+ #: Use shared-memory parallelism (e.g. OpenMP).
6
19
  SHARED = 1
20
+ #: Use both distributed- and shared-memory parallelism.
7
21
  HYBRID = 2