yellowdog-python-examples 7.10.2__tar.gz → 7.10.3__tar.gz

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 (77) hide show
  1. {yellowdog_python_examples-7.10.2/yellowdog_python_examples.egg-info → yellowdog_python_examples-7.10.3}/PKG-INFO +1 -1
  2. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/README.md +1 -1
  3. yellowdog_python_examples-7.10.3/yd_commands/__init__.py +1 -0
  4. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/list.py +2 -6
  5. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/object_utilities.py +27 -0
  6. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/show.py +7 -11
  7. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/shutdown.py +8 -39
  8. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/variables.py +6 -1
  9. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3/yellowdog_python_examples.egg-info}/PKG-INFO +1 -1
  10. yellowdog_python_examples-7.10.2/yd_commands/__init__.py +0 -1
  11. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/LICENSE +0 -0
  12. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/PYPI_README.md +0 -0
  13. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/pyproject.toml +0 -0
  14. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/requirements.txt +0 -0
  15. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/setup.cfg +0 -0
  16. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/setup.py +0 -0
  17. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_create_remove.py +0 -0
  18. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_demos.py +0 -0
  19. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_dryruns.py +0 -0
  20. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_entrypoints.py +0 -0
  21. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_gui.py +0 -0
  22. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_list.py +0 -0
  23. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_objects.py +0 -0
  24. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/tests/test_variable_processing.py +0 -0
  25. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/abort.py +0 -0
  26. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/admin.py +0 -0
  27. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/args.py +0 -0
  28. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/boost.py +0 -0
  29. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cancel.py +0 -0
  30. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/check_imports.py +0 -0
  31. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard.py +0 -0
  32. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard_aws.py +0 -0
  33. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard_aws_types.py +0 -0
  34. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard_azure.py +0 -0
  35. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard_common.py +0 -0
  36. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/cloudwizard_gcp.py +0 -0
  37. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/compact_json.py +0 -0
  38. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/config_types.py +0 -0
  39. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/create.py +0 -0
  40. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/csv_data.py +0 -0
  41. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/delete.py +0 -0
  42. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/download.py +0 -0
  43. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/follow.py +0 -0
  44. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/follow_utils.py +0 -0
  45. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/format_json.py +0 -0
  46. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/hold.py +0 -0
  47. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/id_utils.py +0 -0
  48. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/instantiate.py +0 -0
  49. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/interactive.py +0 -0
  50. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/items.py +0 -0
  51. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/jsonnet2json.py +0 -0
  52. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/load_config.py +0 -0
  53. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/load_resources.py +0 -0
  54. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/printing.py +0 -0
  55. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/property_names.py +0 -0
  56. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/provision.py +0 -0
  57. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/provision_utils.py +0 -0
  58. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/remove.py +0 -0
  59. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/resize.py +0 -0
  60. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/settings.py +0 -0
  61. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/start.py +0 -0
  62. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/start_hold_common.py +0 -0
  63. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/submit.py +0 -0
  64. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/submit_utils.py +0 -0
  65. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/terminate.py +0 -0
  66. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/type_check.py +0 -0
  67. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/upload.py +0 -0
  68. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/upload_utils.py +0 -0
  69. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/utils.py +0 -0
  70. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/validate_properties.py +0 -0
  71. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/version.py +0 -0
  72. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yd_commands/wrapper.py +0 -0
  73. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yellowdog_python_examples.egg-info/SOURCES.txt +0 -0
  74. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yellowdog_python_examples.egg-info/dependency_links.txt +0 -0
  75. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yellowdog_python_examples.egg-info/entry_points.txt +0 -0
  76. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yellowdog_python_examples.egg-info/requires.txt +0 -0
  77. {yellowdog_python_examples-7.10.2 → yellowdog_python_examples-7.10.3}/yellowdog_python_examples.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: yellowdog-python-examples
3
- Version: 7.10.2
3
+ Version: 7.10.3
4
4
  Summary: Example Python commands using the YellowDog Python SDK
5
5
  Home-page: https://github.com/yellowdog/python-examples
6
6
  Author: YellowDog Limited
@@ -581,7 +581,7 @@ All properties are optional except for **`taskType`** (or **`taskTypes`**).
581
581
  | `maxWorkers` | The maximum number of Workers that can be claimed for the associated Task Group. E.g., `10`. | Yes | Yes | Yes | |
582
582
  | `minWorkers` | The minimum number of Workers that the associated Task Group requires. This many workers must be claimed before the associated Task Group will start working. E.g., `1`. | Yes | Yes | Yes | |
583
583
  | `name` | The name of the Work Requirement, Task Group or Task. E.g., `"wr_name"`. Note that the `name` property is not inherited. | Yes | Yes | Yes | Yes |
584
- | `namespaces` | Only Worker Pools whose workers match one of the namespaces in this list can be claimed by the Task Group. E.g., `["namespace_1", "namespace_2"]. Defaults to `None`. | Yes | Yes | Yes | |
584
+ | `namespaces` | Only Workers whose Worker Pools match one of the namespaces in this list can be claimed by the Task Group. E.g., `["namespace_1", "namespace_2"]. Defaults to `None`. | Yes | Yes | Yes | |
585
585
  | `outputs` | The files to be uploaded to the YellowDog Object Store by a Worker node on completion of the Task. E.g., `["results_1.txt", "results_2.txt"]`. | Yes | Yes | Yes | Yes |
586
586
  | `outputsOther` | Files to be uploaded to the YellowDog Object Store from outside the Tasks's Working Directory by a Worker node on completion of a Task. E.g., `outputsOther = [{"directoryName" = "tmp", "filePattern" = "out.txt", "required" = false}]`. | Yes | Yes | Yes | Yes |
587
587
  | `outputsRequired` | The files that *must* be uploaded to the YellowDog Object Store by a Worker node on completion of the Task. The Task will fail if any outputs are unavailable. | Yes | Yes | Yes | Yes |
@@ -0,0 +1 @@
1
+ __version__ = "7.10.3"
@@ -31,7 +31,6 @@ from yellowdog_client.model import (
31
31
  ObjectDetail,
32
32
  Task,
33
33
  TaskGroup,
34
- TaskSearch,
35
34
  WorkerPool,
36
35
  WorkerPoolStatus,
37
36
  WorkerPoolSummary,
@@ -43,6 +42,7 @@ from yd_commands.interactive import select
43
42
  from yd_commands.object_utilities import (
44
43
  get_filtered_work_requirements,
45
44
  get_task_groups_from_wr_summary,
45
+ get_tasks,
46
46
  list_matching_object_paths,
47
47
  )
48
48
  from yd_commands.printing import (
@@ -185,11 +185,7 @@ def list_task_groups(work_summary: WorkRequirementSummary):
185
185
 
186
186
 
187
187
  def list_tasks(task_group: TaskGroup, work_summary: WorkRequirementSummary):
188
- task_search = TaskSearch(
189
- workRequirementId=work_summary.id,
190
- taskGroupId=task_group.id,
191
- )
192
- tasks: List[Task] = CLIENT.work_client.find_tasks(task_search)
188
+ tasks: List[Task] = get_tasks(CLIENT, work_summary.id, task_group.id)
193
189
  tasks = sorted_objects(tasks)
194
190
  if ARGS_PARSER.details:
195
191
  for task in select(CLIENT, tasks):
@@ -21,6 +21,7 @@ from yellowdog_client.model import (
21
21
  ProvisionedWorkerPool,
22
22
  Task,
23
23
  TaskGroup,
24
+ TaskSearch,
24
25
  WorkerPool,
25
26
  WorkerPoolSummary,
26
27
  WorkRequirementStatus,
@@ -304,3 +305,29 @@ def list_matching_object_paths(
304
305
  for object_path in object_paths
305
306
  if object_path.name.startswith(prefix)
306
307
  ]
308
+
309
+
310
+ def get_task_by_id(
311
+ client: PlatformClient, wr_id: str, task_group_id: str, task_id: str
312
+ ) -> Optional[Task]:
313
+ """
314
+ Find a task by its ID.
315
+ """
316
+ tasks: List[Task] = get_tasks(client, wr_id, task_group_id)
317
+ for task in tasks:
318
+ if task.id == task_id:
319
+ return task
320
+
321
+
322
+ @lru_cache()
323
+ def get_tasks(client: PlatformClient, wr_id: str, task_group_id: str) -> List[Task]:
324
+ """
325
+ Return all the tasks in a task group, with caching.
326
+ There is no native way to search for a task by its id.
327
+ """
328
+ task_search = TaskSearch(
329
+ workRequirementId=wr_id,
330
+ taskGroupId=task_group_id,
331
+ )
332
+ tasks: List[Task] = client.work_client.find_tasks(task_search)
333
+ return tasks
@@ -4,11 +4,11 @@
4
4
  Command to show the JSON details of YellowDog entities via their IDs.
5
5
  """
6
6
 
7
- from typing import List
7
+ from typing import Optional
8
8
 
9
- from yellowdog_client.model import ConfiguredWorkerPool, Task, TaskSearch
10
- from yellowdog_client.model.exceptions import InvalidRequestException
9
+ from yellowdog_client.model import ConfiguredWorkerPool, Task
11
10
 
11
+ from yd_commands.object_utilities import get_task_by_id
12
12
  from yd_commands.printing import print_log, print_warning, print_yd_object
13
13
  from yd_commands.wrapper import ARGS_PARSER, CLIENT, main_wrapper
14
14
 
@@ -106,15 +106,11 @@ def show_details(ydid: str):
106
106
  else:
107
107
  print_warning(f"Task Group ID '{ydid}' not found")
108
108
  return
109
- task_search = TaskSearch(
110
- workRequirementId=work_requirement.id,
111
- taskGroupId=task_group.id,
109
+ task: Optional[Task] = get_task_by_id(
110
+ CLIENT, work_requirement.id, task_group.id, ydid
112
111
  )
113
- tasks: List[Task] = CLIENT.work_client.find_tasks(task_search)
114
- for task in tasks:
115
- if task.id == ydid:
116
- print_yd_object(task)
117
- return
112
+ if task is not None:
113
+ print_yd_object(task)
118
114
  else:
119
115
  print_warning(f"Task ID '{ydid}' not found")
120
116
 
@@ -1,18 +1,12 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
3
  """
4
- A script to shut down Provisioned Worker Pools.
4
+ A script to shut down Worker Pools.
5
5
  """
6
6
 
7
7
  from typing import List
8
8
 
9
- from yellowdog_client.model import (
10
- ComputeRequirement,
11
- ComputeRequirementStatus,
12
- WorkerPool,
13
- WorkerPoolStatus,
14
- WorkerPoolSummary,
15
- )
9
+ from yellowdog_client.model import WorkerPool, WorkerPoolStatus, WorkerPoolSummary
16
10
 
17
11
  from yd_commands.follow_utils import follow_ids
18
12
  from yd_commands.interactive import confirmed, select
@@ -32,12 +26,11 @@ def main():
32
26
  return
33
27
 
34
28
  print_log(
35
- "Shutting down Provisioned Worker Pools with Compute Requirements in "
29
+ "Shutting down Worker Pools in "
36
30
  f"namespace '{CONFIG_COMMON.namespace}' and "
37
- f"tag starting with '{CONFIG_COMMON.name_tag}' "
38
- "(or Configured Worker Pools with names starting with "
39
- f"'{CONFIG_COMMON.name_tag}')"
31
+ f"names including '{CONFIG_COMMON.name_tag}'"
40
32
  )
33
+
41
34
  worker_pool_summaries: List[WorkerPoolSummary] = (
42
35
  CLIENT.worker_pool_client.find_all_worker_pools()
43
36
  )
@@ -49,34 +42,10 @@ def main():
49
42
  WorkerPoolStatus.TERMINATED,
50
43
  WorkerPoolStatus.SHUTDOWN,
51
44
  ]:
52
- if "ProvisionedWorkerPool" not in worker_pool_summary.type:
53
- # Configured Worker Pool: check worker pool name only
54
- if (
55
- worker_pool_summary.name is not None
56
- and worker_pool_summary.name.startswith(CONFIG_COMMON.name_tag)
57
- ):
58
- selected_worker_pool_summaries.append(worker_pool_summary)
59
- continue
60
-
61
- worker_pool: WorkerPool = get_worker_pool_by_id(
62
- CLIENT, worker_pool_summary.id
63
- )
64
- compute_requirement: ComputeRequirement = (
65
- CLIENT.compute_client.get_compute_requirement_by_id(
66
- worker_pool.computeRequirementId
67
- )
68
- )
69
- compute_requirement.tag = (
70
- "" if compute_requirement.tag is None else compute_requirement.tag
71
- )
72
45
  if (
73
- compute_requirement.tag.startswith(CONFIG_COMMON.name_tag)
74
- and compute_requirement.namespace == CONFIG_COMMON.namespace
75
- and compute_requirement.status
76
- not in [
77
- ComputeRequirementStatus.TERMINATED,
78
- ComputeRequirementStatus.TERMINATING,
79
- ]
46
+ worker_pool_summary.name is not None
47
+ and worker_pool_summary.namespace == CONFIG_COMMON.namespace
48
+ and CONFIG_COMMON.name_tag in worker_pool_summary.name
80
49
  ):
81
50
  selected_worker_pool_summaries.append(worker_pool_summary)
82
51
 
@@ -42,8 +42,13 @@ from yd_commands.utils import (
42
42
  )
43
43
 
44
44
  # Set up default variable substitutions
45
+ try:
46
+ USERNAME = getuser().replace(" ", "_").lower()
47
+ except:
48
+ USERNAME = "default-yd-user"
49
+
45
50
  VARIABLE_SUBSTITUTIONS = {
46
- "username": getuser().replace(" ", "_").lower(),
51
+ "username": USERNAME,
47
52
  "date": UTCNOW.strftime("%y%m%d"),
48
53
  "time": UTCNOW.strftime("%H%M%S%f")[:-4],
49
54
  "datetime": UTCNOW.strftime("%y%m%d-%H%M%S"),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: yellowdog-python-examples
3
- Version: 7.10.2
3
+ Version: 7.10.3
4
4
  Summary: Example Python commands using the YellowDog Python SDK
5
5
  Home-page: https://github.com/yellowdog/python-examples
6
6
  Author: YellowDog Limited
@@ -1 +0,0 @@
1
- __version__ = "7.10.2"