yellowdog-python-examples 7.11.2__tar.gz → 7.11.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.11.2 → yellowdog_python_examples-7.11.3}/PKG-INFO +1 -1
  2. yellowdog_python_examples-7.11.3/yd_commands/__init__.py +1 -0
  3. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/args.py +22 -0
  4. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/items.py +4 -0
  5. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/list.py +73 -16
  6. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/printing.py +77 -1
  7. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yellowdog_python_examples.egg-info/PKG-INFO +1 -1
  8. yellowdog_python_examples-7.11.2/yd_commands/__init__.py +0 -1
  9. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/LICENSE +0 -0
  10. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/PYPI_README.md +0 -0
  11. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/README.md +0 -0
  12. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/pyproject.toml +0 -0
  13. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/requirements.txt +0 -0
  14. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/setup.cfg +0 -0
  15. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/setup.py +0 -0
  16. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_create_remove.py +0 -0
  17. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_demos.py +0 -0
  18. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_dryruns.py +0 -0
  19. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_entrypoints.py +0 -0
  20. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_gui.py +0 -0
  21. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_list.py +0 -0
  22. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_objects.py +0 -0
  23. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/tests/test_variable_processing.py +0 -0
  24. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/abort.py +0 -0
  25. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/admin.py +0 -0
  26. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/boost.py +0 -0
  27. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cancel.py +0 -0
  28. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/check_imports.py +0 -0
  29. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard.py +0 -0
  30. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard_aws.py +0 -0
  31. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard_aws_types.py +0 -0
  32. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard_azure.py +0 -0
  33. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard_common.py +0 -0
  34. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/cloudwizard_gcp.py +0 -0
  35. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/compact_json.py +0 -0
  36. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/config_types.py +0 -0
  37. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/create.py +0 -0
  38. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/csv_data.py +0 -0
  39. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/delete.py +0 -0
  40. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/download.py +0 -0
  41. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/follow.py +0 -0
  42. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/follow_utils.py +0 -0
  43. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/format_json.py +0 -0
  44. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/hold.py +0 -0
  45. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/id_utils.py +0 -0
  46. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/instantiate.py +0 -0
  47. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/interactive.py +0 -0
  48. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/jsonnet2json.py +0 -0
  49. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/load_config.py +0 -0
  50. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/load_resources.py +0 -0
  51. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/object_utilities.py +0 -0
  52. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/property_names.py +0 -0
  53. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/provision.py +0 -0
  54. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/provision_utils.py +0 -0
  55. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/remove.py +0 -0
  56. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/resize.py +0 -0
  57. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/settings.py +0 -0
  58. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/show.py +0 -0
  59. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/shutdown.py +0 -0
  60. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/start.py +0 -0
  61. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/start_hold_common.py +0 -0
  62. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/submit.py +0 -0
  63. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/submit_utils.py +0 -0
  64. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/terminate.py +0 -0
  65. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/type_check.py +0 -0
  66. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/upload.py +0 -0
  67. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/upload_utils.py +0 -0
  68. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/utils.py +0 -0
  69. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/validate_properties.py +0 -0
  70. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/variables.py +0 -0
  71. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/version.py +0 -0
  72. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yd_commands/wrapper.py +0 -0
  73. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yellowdog_python_examples.egg-info/SOURCES.txt +0 -0
  74. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yellowdog_python_examples.egg-info/dependency_links.txt +0 -0
  75. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yellowdog_python_examples.egg-info/entry_points.txt +0 -0
  76. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.3}/yellowdog_python_examples.egg-info/requires.txt +0 -0
  77. {yellowdog_python_examples-7.11.2 → yellowdog_python_examples-7.11.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.11.2
3
+ Version: 7.11.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
@@ -0,0 +1 @@
1
+ __version__ = "7.11.3"
@@ -516,6 +516,18 @@ class CLIParser:
516
516
  required=False,
517
517
  help="list compute instances",
518
518
  )
519
+ parser.add_argument(
520
+ "--nodes",
521
+ action="store_true",
522
+ required=False,
523
+ help="list worker pool nodes",
524
+ )
525
+ parser.add_argument(
526
+ "--workers",
527
+ action="store_true",
528
+ required=False,
529
+ help="list all workers in a worker pool",
530
+ )
519
531
  parser.add_argument(
520
532
  "--public-ips-only",
521
533
  action="store_true",
@@ -1328,6 +1340,16 @@ class CLIParser:
1328
1340
  def instances(self) -> Optional[bool]:
1329
1341
  return self.args.instances
1330
1342
 
1343
+ @property
1344
+ @allow_missing_attribute
1345
+ def nodes(self) -> Optional[bool]:
1346
+ return self.args.nodes
1347
+
1348
+ @property
1349
+ @allow_missing_attribute
1350
+ def workers(self) -> Optional[bool]:
1351
+ return self.args.workers
1352
+
1331
1353
  @property
1332
1354
  @allow_missing_attribute
1333
1355
  def allowances(self) -> Optional[bool]:
@@ -16,10 +16,12 @@ from yellowdog_client.model import (
16
16
  MachineImageFamilySummary,
17
17
  NamespacePolicy,
18
18
  NamespaceStorageConfiguration,
19
+ Node,
19
20
  ObjectPath,
20
21
  ProvisionedWorkerPool,
21
22
  Task,
22
23
  TaskGroup,
24
+ Worker,
23
25
  WorkerPoolSummary,
24
26
  WorkRequirementSummary,
25
27
  )
@@ -44,6 +46,8 @@ Item = TypeVar(
44
46
  ProvisionedWorkerPool,
45
47
  Task,
46
48
  TaskGroup,
49
+ Worker,
47
50
  WorkRequirementSummary,
48
51
  WorkerPoolSummary,
52
+ Node,
49
53
  )
@@ -30,9 +30,12 @@ from yellowdog_client.model import (
30
30
  NamespacePolicy,
31
31
  NamespacePolicySearch,
32
32
  NamespaceStorageConfiguration,
33
+ Node,
34
+ NodeSearch,
33
35
  ObjectDetail,
34
36
  Task,
35
37
  TaskGroup,
38
+ Worker,
36
39
  WorkerPool,
37
40
  WorkerPoolStatus,
38
41
  WorkerPoolSummary,
@@ -73,7 +76,7 @@ def main():
73
76
  list_object_paths()
74
77
  elif ARGS_PARSER.work_requirements or ARGS_PARSER.task_groups or ARGS_PARSER.tasks:
75
78
  list_work_requirements()
76
- elif ARGS_PARSER.worker_pools:
79
+ elif ARGS_PARSER.worker_pools or ARGS_PARSER.nodes or ARGS_PARSER.workers:
77
80
  list_worker_pools()
78
81
  elif ARGS_PARSER.compute_requirements or ARGS_PARSER.instances:
79
82
  list_compute_requirements()
@@ -100,21 +103,23 @@ def check_for_valid_option() -> bool:
100
103
  Only one of the listing options must be selected.
101
104
  """
102
105
  if [
103
- ARGS_PARSER.object_paths,
104
- ARGS_PARSER.work_requirements,
105
- ARGS_PARSER.task_groups,
106
- ARGS_PARSER.tasks,
107
- ARGS_PARSER.worker_pools,
106
+ ARGS_PARSER.allowances,
107
+ ARGS_PARSER.attribute_definitions,
108
108
  ARGS_PARSER.compute_requirements,
109
109
  ARGS_PARSER.compute_templates,
110
- ARGS_PARSER.source_templates,
111
- ARGS_PARSER.keyrings,
112
110
  ARGS_PARSER.image_families,
113
- ARGS_PARSER.namespace_storage_configurations,
114
111
  ARGS_PARSER.instances,
115
- ARGS_PARSER.allowances,
116
- ARGS_PARSER.attribute_definitions,
112
+ ARGS_PARSER.keyrings,
117
113
  ARGS_PARSER.namespace_policies,
114
+ ARGS_PARSER.namespace_storage_configurations,
115
+ ARGS_PARSER.nodes,
116
+ ARGS_PARSER.object_paths,
117
+ ARGS_PARSER.source_templates,
118
+ ARGS_PARSER.task_groups,
119
+ ARGS_PARSER.tasks,
120
+ ARGS_PARSER.work_requirements,
121
+ ARGS_PARSER.worker_pools,
122
+ ARGS_PARSER.workers,
118
123
  ].count(True) == 1:
119
124
  return True
120
125
  else:
@@ -257,6 +262,21 @@ def list_worker_pools():
257
262
  if len(worker_pool_summaries) == 0:
258
263
  print_log("No Worker Pools to display")
259
264
  return
265
+
266
+ if ARGS_PARSER.nodes or ARGS_PARSER.workers:
267
+ print_log(
268
+ "Please select the Worker Pool for which to list "
269
+ f"{'Nodes' if ARGS_PARSER.nodes else 'all Workers'}"
270
+ )
271
+ worker_pool_summary = select(
272
+ CLIENT,
273
+ sorted_objects(worker_pool_summaries),
274
+ showing_all=showing_all,
275
+ single_result=True,
276
+ )
277
+ list_nodes(worker_pool_summary[0])
278
+ return
279
+
260
280
  if ARGS_PARSER.details:
261
281
  for worker_pool_summary in select(
262
282
  CLIENT, sorted_objects(worker_pool_summaries), showing_all=showing_all
@@ -330,9 +350,7 @@ def list_instances(compute_requirement: ComputeRequirement):
330
350
  """
331
351
  List the instances within a Compute Requirement.
332
352
  """
333
- instance_search: InstanceSearch = InstanceSearch(
334
- computeRequirementId=compute_requirement.id
335
- )
353
+ instance_search = InstanceSearch(computeRequirementId=compute_requirement.id)
336
354
  search_client: SearchClient = CLIENT.compute_client.get_instances(
337
355
  instance_search=instance_search
338
356
  )
@@ -352,10 +370,49 @@ def list_instances(compute_requirement: ComputeRequirement):
352
370
  return
353
371
 
354
372
  if ARGS_PARSER.details:
355
- for instance in select(CLIENT, search_client.list_all()):
373
+ for instance in select(CLIENT, instances):
356
374
  print_yd_object(instance)
357
375
  else:
358
- print_numbered_object_list(CLIENT, search_client.list_all())
376
+ print_numbered_object_list(CLIENT, instances)
377
+
378
+
379
+ def list_nodes(worker_pool_summary: WorkerPoolSummary):
380
+ """
381
+ List the nodes in a Worker Pool.
382
+ """
383
+ nodes_search = NodeSearch(worker_pool_summary.id)
384
+ search_client = CLIENT.worker_pool_client.get_nodes(search=nodes_search)
385
+ nodes: List[Node] = search_client.list_all()
386
+
387
+ if ARGS_PARSER.workers:
388
+ list_workers(nodes)
389
+ return
390
+
391
+ if ARGS_PARSER.details:
392
+ for node in select(CLIENT, nodes):
393
+ print_yd_object(node)
394
+ else:
395
+ print_numbered_object_list(CLIENT, nodes)
396
+
397
+
398
+ def list_workers(nodes: List[Node]):
399
+ """
400
+ Display a list of workers across all nodes in a worker pool.
401
+ """
402
+ workers_all: List[Worker] = []
403
+ for node in nodes:
404
+ for worker in node.workers:
405
+ # Add extra info to the Worker object
406
+ worker.workerTag = node.details.workerTag
407
+ worker.taskTypes = node.details.supportedTaskTypes
408
+ workers_all.append(worker)
409
+
410
+ if not ARGS_PARSER.details:
411
+ print_numbered_object_list(CLIENT, workers_all)
412
+ return
413
+
414
+ for worker in select(CLIENT, workers_all):
415
+ print_yd_object(worker)
359
416
 
360
417
 
361
418
  def list_compute_templates():
@@ -33,6 +33,7 @@ from yellowdog_client.model import (
33
33
  KeyringSummary,
34
34
  MachineImageFamilySummary,
35
35
  NamespacePolicy,
36
+ Node,
36
37
  NodeStatus,
37
38
  NodeSummary,
38
39
  ObjectDetail,
@@ -41,6 +42,7 @@ from yellowdog_client.model import (
41
42
  ProvisionedWorkerPoolProperties,
42
43
  Task,
43
44
  TaskGroup,
45
+ Worker,
44
46
  WorkerPool,
45
47
  WorkerPoolSummary,
46
48
  WorkRequirement,
@@ -212,11 +214,13 @@ TYPE_MAP = {
212
214
  KeyringSummary: "Keyring",
213
215
  MachineImageFamilySummary: "Machine Image Family",
214
216
  NamespacePolicy: "Namespace Policy",
217
+ Node: "Node",
215
218
  ObjectPath: "Object Path",
216
219
  ProvisionedWorkerPool: "Provisioned Worker Pool",
217
220
  Task: "Task",
218
221
  TaskGroup: "Task Group",
219
222
  WorkRequirementSummary: "Work Requirement",
223
+ Worker: "Worker",
220
224
  WorkerPoolSummary: "Worker Pool",
221
225
  }
222
226
 
@@ -535,6 +539,68 @@ def instances_table(
535
539
  return headers, table
536
540
 
537
541
 
542
+ def nodes_table(
543
+ nodes: List[Node],
544
+ ) -> (List[str], List[str]):
545
+ headers = [
546
+ "#",
547
+ "Provider",
548
+ "RAM",
549
+ "vCPUs",
550
+ "Task Types",
551
+ "Worker Tag",
552
+ "# Workers",
553
+ "Status",
554
+ "ID",
555
+ ]
556
+ table = []
557
+ for index, node in enumerate(nodes):
558
+ if node.details is None:
559
+ continue
560
+ table.append(
561
+ [
562
+ index + 1,
563
+ node.details.provider,
564
+ node.details.ram,
565
+ node.details.vcpus,
566
+ ", ".join(node.details.supportedTaskTypes),
567
+ node.details.workerTag,
568
+ len(node.workers),
569
+ node.status,
570
+ node.id,
571
+ ]
572
+ )
573
+ return headers, table
574
+
575
+
576
+ def workers_table(
577
+ workers: List[Worker],
578
+ ) -> (List[str], List[str]):
579
+ headers = [
580
+ "#",
581
+ "Task Types",
582
+ "Worker Tag",
583
+ "Status",
584
+ "Claims",
585
+ "Exclusive?",
586
+ "ID",
587
+ ]
588
+ table = []
589
+ for index, worker in enumerate(workers):
590
+ table.append(
591
+ [
592
+ index + 1,
593
+ ", ".join(worker.taskTypes),
594
+ worker.workerTag,
595
+ worker.status,
596
+ worker.claimCount,
597
+ worker.exclusive,
598
+ worker.id,
599
+ ]
600
+ )
601
+ return headers, table
602
+
603
+
538
604
  def allowances_table(
539
605
  allowances: List[Allowance],
540
606
  ) -> (List[str], List[str]):
@@ -691,6 +757,10 @@ def print_numbered_object_list(
691
757
  headers, table = attribute_definitions_table(objects)
692
758
  elif isinstance(objects[0], NamespacePolicy):
693
759
  headers, table = namespace_policies_table(objects)
760
+ elif isinstance(objects[0], Node):
761
+ headers, table = nodes_table(objects)
762
+ elif isinstance(objects[0], Worker):
763
+ headers, table = workers_table(objects)
694
764
  else:
695
765
  table = []
696
766
  for index, obj in enumerate(objects):
@@ -731,7 +801,7 @@ def sorted_objects(
731
801
  """
732
802
  Sort objects by their 'name' property, or 'namespace' in the case of
733
803
  Namespace Storage Configurations, or 'instanceType' in the case of
734
- Instances.
804
+ Instances, etc.
735
805
  """
736
806
  if len(objects) == 0:
737
807
  return objects
@@ -745,6 +815,12 @@ def sorted_objects(
745
815
  if isinstance(objects[0], Instance):
746
816
  return sorted(objects, key=lambda x: x.instanceType, reverse=reverse)
747
817
 
818
+ if isinstance(objects[0], Node):
819
+ return sorted(objects, key=lambda x: str(x.status), reverse=reverse)
820
+
821
+ if isinstance(objects[0], Worker):
822
+ return sorted(objects, key=lambda x: str(x.id), reverse=reverse)
823
+
748
824
  if isinstance(objects[0], AWSAvailabilityZone):
749
825
  return sorted(objects)
750
826
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: yellowdog-python-examples
3
- Version: 7.11.2
3
+ Version: 7.11.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.11.2"