yellowdog-python-examples 7.9.3__tar.gz → 7.10.0__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.9.3/yellowdog_python_examples.egg-info → yellowdog_python_examples-7.10.0}/PKG-INFO +1 -1
  2. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/README.md +21 -1
  3. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/setup.cfg +1 -0
  4. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_create_remove.py +15 -1
  5. yellowdog_python_examples-7.10.0/yd_commands/__init__.py +1 -0
  6. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/args.py +3 -2
  7. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/object_utilities.py +2 -4
  8. yellowdog_python_examples-7.10.0/yd_commands/show.py +153 -0
  9. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0/yellowdog_python_examples.egg-info}/PKG-INFO +1 -1
  10. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yellowdog_python_examples.egg-info/SOURCES.txt +1 -0
  11. yellowdog_python_examples-7.9.3/yd_commands/__init__.py +0 -1
  12. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/LICENSE +0 -0
  13. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/PYPI_README.md +0 -0
  14. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/pyproject.toml +0 -0
  15. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/requirements.txt +0 -0
  16. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/setup.py +0 -0
  17. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_demos.py +0 -0
  18. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_dryruns.py +0 -0
  19. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_entrypoints.py +0 -0
  20. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_gui.py +0 -0
  21. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_list.py +0 -0
  22. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_objects.py +0 -0
  23. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/tests/test_variable_processing.py +0 -0
  24. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/abort.py +0 -0
  25. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/admin.py +0 -0
  26. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/boost.py +0 -0
  27. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cancel.py +0 -0
  28. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/check_imports.py +0 -0
  29. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard.py +0 -0
  30. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard_aws.py +0 -0
  31. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard_aws_types.py +0 -0
  32. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard_azure.py +0 -0
  33. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard_common.py +0 -0
  34. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/cloudwizard_gcp.py +0 -0
  35. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/compact_json.py +0 -0
  36. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/config_types.py +0 -0
  37. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/create.py +0 -0
  38. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/csv_data.py +0 -0
  39. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/delete.py +0 -0
  40. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/download.py +0 -0
  41. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/follow.py +0 -0
  42. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/follow_utils.py +0 -0
  43. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/format_json.py +0 -0
  44. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/hold.py +0 -0
  45. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/id_utils.py +0 -0
  46. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/instantiate.py +0 -0
  47. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/interactive.py +0 -0
  48. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/items.py +0 -0
  49. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/jsonnet2json.py +0 -0
  50. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/list.py +0 -0
  51. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/load_config.py +0 -0
  52. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/load_resources.py +0 -0
  53. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/printing.py +0 -0
  54. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/property_names.py +0 -0
  55. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/provision.py +0 -0
  56. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/provision_utils.py +0 -0
  57. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/remove.py +0 -0
  58. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/resize.py +0 -0
  59. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/settings.py +0 -0
  60. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/shutdown.py +0 -0
  61. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/start.py +0 -0
  62. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/start_hold_common.py +0 -0
  63. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/submit.py +0 -0
  64. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/submit_utils.py +0 -0
  65. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/terminate.py +0 -0
  66. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/type_check.py +0 -0
  67. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/upload.py +0 -0
  68. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/upload_utils.py +0 -0
  69. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/utils.py +0 -0
  70. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/validate_properties.py +0 -0
  71. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/variables.py +0 -0
  72. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/version.py +0 -0
  73. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yd_commands/wrapper.py +0 -0
  74. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yellowdog_python_examples.egg-info/dependency_links.txt +0 -0
  75. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yellowdog_python_examples.egg-info/entry_points.txt +0 -0
  76. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/yellowdog_python_examples.egg-info/requires.txt +0 -0
  77. {yellowdog_python_examples-7.9.3 → yellowdog_python_examples-7.10.0}/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.9.3
3
+ Version: 7.10.0
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
@@ -115,9 +115,10 @@
115
115
  * [yd-start](#yd-start)
116
116
  * [yd-hold](#yd-hold)
117
117
  * [yd-boost](#yd-boost)
118
+ * [yd-show](#yd-show)
118
119
 
119
120
  <!-- Created by https://github.com/ekalinin/github-markdown-toc -->
120
- <!-- Added by: pwt, at: Thu May 9 16:47:20 BST 2024 -->
121
+ <!-- Added by: pwt, at: Wed Jun 12 11:55:06 BST 2024 -->
121
122
 
122
123
  <!--te-->
123
124
 
@@ -150,6 +151,7 @@ The commands provide the following capabilities:
150
151
  - **Boosting** Allowances with the **`yd-boost`** command
151
152
  - **Creating, Updating and Removing** Source Templates, Compute Templates, Keyrings, Credentials, Namespace Storage Configurations, Image Families, Allowances, and Configured Worker Pools with the **`yd-create`** and **`yd-remove`** commands
152
153
  - **Following Event Streams** for Work Requirements, Worker Pools and Compute Requirements with the **`yd-follow`** command
154
+ - **Showing** the details of any YellowDog entity by its YellowDog ID
153
155
 
154
156
  The operation of the commands is controlled using TOML configuration files and/or environment variables and command line arguments. In addition, Work Requirements and Worker Pools can be defined using JSON files providing extensive configurability.
155
157
 
@@ -2651,3 +2653,21 @@ It can optionally be supplied with a list of the names and/or YDIDs of the speci
2651
2653
  ## yd-boost
2652
2654
 
2653
2655
  The `yd-boost` command is used to boost Allowances by the specified number of hours.
2656
+
2657
+ ## yd-show
2658
+
2659
+ The `yd-show` command will show the details (in JSON) of any YellowDog entity by its YellowDog ID. It supports IDs referring to:
2660
+
2661
+ - Compute Source Templates
2662
+ - Compute Requirement Templates
2663
+ - Compute Requirements
2664
+ - Sources
2665
+ - Worker Pools
2666
+ - Nodes
2667
+ - Workers
2668
+ - Work Requirements
2669
+ - Task Groups
2670
+ - Tasks
2671
+ - Image Families, Image Groups, and Images
2672
+ - Keyrings
2673
+ - Allowances
@@ -31,6 +31,7 @@ console_scripts =
31
31
  yd-list=yd_commands.list:main
32
32
  yd-provision=yd_commands.provision:main
33
33
  yd-reformat-json=yd_commands.reformat_json:main
34
+ yd-show=yd_commands.show:main
34
35
  yd-shutdown=yd_commands.shutdown:main
35
36
  yd-submit=yd_commands.submit:main
36
37
  yd-terminate=yd_commands.terminate:main
@@ -1,6 +1,6 @@
1
1
  from cli_test_helpers import shell
2
2
 
3
- RESOURCE_DIR = "resource-examples"
3
+ RESOURCE_DIR = "tests/resource-examples"
4
4
 
5
5
 
6
6
  class TestCreateRemove:
@@ -53,3 +53,17 @@ class TestCreateRemove:
53
53
  assert result.exit_code == 0
54
54
  result = shell(f"yd-remove -My {resources}")
55
55
  assert result.exit_code == 0
56
+
57
+ def test_string_attribute(self):
58
+ resources = f"{RESOURCE_DIR}/stringattribute.json"
59
+ result = shell(f"yd-create {resources}")
60
+ assert result.exit_code == 0
61
+ result = shell(f"yd-remove -y {resources}")
62
+ assert result.exit_code == 0
63
+
64
+ def test_numeric_attribute(self):
65
+ resources = f"{RESOURCE_DIR}/numericattribute.json"
66
+ result = shell(f"yd-create {resources}")
67
+ assert result.exit_code == 0
68
+ result = shell(f"yd-remove -y {resources}")
69
+ assert result.exit_code == 0
@@ -0,0 +1 @@
1
+ __version__ = "7.10.0"
@@ -802,14 +802,15 @@ class CLIParser:
802
802
  help="remove resources using their YellowDog IDs (YDIDs)",
803
803
  )
804
804
 
805
- if "follow" in sys.argv[0]:
805
+ if any(module in sys.argv[0] for module in ["follow", "show"]):
806
+ verb = "follow" if "follow" in sys.argv[0] else "show"
806
807
  parser.add_argument(
807
808
  "yellowdog_ids",
808
809
  nargs="+",
809
810
  default=[],
810
811
  metavar="<yellowdog-id>",
811
812
  type=str,
812
- help="the YellowDog ID(s) of the item(s) to follow",
813
+ help=f"the YellowDog ID(s) of the item(s) to {verb}",
813
814
  )
814
815
 
815
816
  if any(
@@ -298,11 +298,9 @@ def list_matching_object_paths(
298
298
  if object_paths is None:
299
299
  return []
300
300
 
301
- # Check that the prefix actually matches!
302
- object_paths = [
301
+ # Check the prefix actually matches!
302
+ return [
303
303
  object_path
304
304
  for object_path in object_paths
305
305
  if object_path.name.startswith(prefix)
306
306
  ]
307
-
308
- return object_paths
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ Command to show the JSON details of YellowDog entities via their IDs.
5
+ """
6
+
7
+ from typing import List
8
+
9
+ from yellowdog_client.model import Task, TaskSearch
10
+ from yellowdog_client.model.exceptions import InvalidRequestException
11
+
12
+ from yd_commands.printing import print_log, print_warning, print_yd_object
13
+ from yd_commands.wrapper import ARGS_PARSER, CLIENT, main_wrapper
14
+
15
+
16
+ @main_wrapper
17
+ def main():
18
+
19
+ ydids_set = set(ARGS_PARSER.yellowdog_ids)
20
+ if len(ydids_set) < len(ARGS_PARSER.yellowdog_ids):
21
+ print_warning("Dropping duplicate YDIDs")
22
+
23
+ for ydid in ydids_set:
24
+ show_details(ydid)
25
+
26
+
27
+ def show_details(ydid: str):
28
+ """
29
+ Show the details for a given YDID
30
+ """
31
+ try:
32
+ if ":cst:" in ydid:
33
+ print_log(f"Showing details of Compute Source Template ID '{ydid}'")
34
+ print_yd_object(CLIENT.compute_client.get_compute_source_template(ydid))
35
+
36
+ elif ":crt:" in ydid:
37
+ print_log(f"Showing details of Compute Requirement Template ID '{ydid}'")
38
+ print_yd_object(
39
+ CLIENT.compute_client.get_compute_requirement_template(ydid)
40
+ )
41
+
42
+ elif ":compreq:" in ydid:
43
+ print_log(f"Showing details of Compute Requirement ID '{ydid}'")
44
+ print_yd_object(CLIENT.compute_client.get_compute_requirement_by_id(ydid))
45
+
46
+ elif ":compsrc:" in ydid:
47
+ print_log(f"Showing details of Compute Source ID '{ydid}'")
48
+ compute_requirement = CLIENT.compute_client.get_compute_requirement_by_id(
49
+ ydid.rsplit(":", 1)[0].replace("compsrc", "compreq")
50
+ )
51
+ for source in compute_requirement.provisionStrategy.sources:
52
+ if source.id == ydid:
53
+ print_yd_object(source)
54
+ break
55
+ else:
56
+ print_warning(f"Compute Source ID '{ydid}' not found")
57
+
58
+ elif ":wrkrpool:" in ydid:
59
+ print_log(f"Showing details of Worker Pool ID '{ydid}'")
60
+ print_yd_object(CLIENT.worker_pool_client.get_worker_pool_by_id(ydid))
61
+
62
+ elif ":node:" in ydid:
63
+ print_log(f"Showing details of Node ID '{ydid}'")
64
+ print_yd_object(CLIENT.worker_pool_client.get_node_by_id(ydid))
65
+
66
+ elif ":wrkr:" in ydid:
67
+ print_log(f"Showing details of Worker ID '{ydid}'")
68
+ node = CLIENT.worker_pool_client.get_node_by_id(
69
+ ydid.rsplit(":", 1)[0].replace("wrkr", "node")
70
+ )
71
+ for worker in node.workers:
72
+ if worker.id == ydid:
73
+ print_yd_object(worker)
74
+ break
75
+ else:
76
+ print_warning(f"Worker ID '{ydid}' not found")
77
+
78
+ elif ":workreq:" in ydid:
79
+ print_log(f"Showing details of Work Requirement ID '{ydid}'")
80
+ print_yd_object(CLIENT.work_client.get_work_requirement_by_id(ydid))
81
+
82
+ elif ":taskgrp:" in ydid:
83
+ print_log(f"Showing details of Task Group ID '{ydid}'")
84
+ work_requirement = CLIENT.work_client.get_work_requirement_by_id(
85
+ ydid.rsplit(":", 1)[0].replace("taskgrp", "workreq")
86
+ )
87
+ for task_group in work_requirement.taskGroups:
88
+ if task_group.id == ydid:
89
+ print_yd_object(task_group)
90
+ break
91
+ else:
92
+ print_warning(f"Task Group ID '{ydid}' not found")
93
+
94
+ elif ":task:" in ydid:
95
+ print_log(f"Showing details of Task ID '{ydid}'")
96
+ work_requirement = CLIENT.work_client.get_work_requirement_by_id(
97
+ ydid.rsplit(":", 2)[0].replace("task", "workreq")
98
+ )
99
+ for task_group in work_requirement.taskGroups:
100
+ if task_group.id == ydid.rsplit(":", 1)[0].replace("task", "taskgrp"):
101
+ break
102
+ else:
103
+ print_warning(f"Task Group ID '{ydid}' not found")
104
+ return
105
+ task_search = TaskSearch(
106
+ workRequirementId=work_requirement.id,
107
+ taskGroupId=task_group.id,
108
+ )
109
+ tasks: List[Task] = CLIENT.work_client.find_tasks(task_search)
110
+ for task in tasks:
111
+ if task.id == ydid:
112
+ print_yd_object(task)
113
+ else:
114
+ print_warning(f"Task ID '{ydid}' not found")
115
+
116
+ elif ":imgfam:" in ydid:
117
+ print_log(f"Showing details of Image Family ID '{ydid}'")
118
+ print_yd_object(CLIENT.images_client.get_image_family_by_id(ydid))
119
+
120
+ elif ":imggrp:" in ydid:
121
+ print_log(f"Showing details of Image Group ID '{ydid}'")
122
+ print_yd_object(CLIENT.images_client.get_image_group_by_id(ydid))
123
+
124
+ elif ":image:" in ydid:
125
+ print_log(f"Showing details of Image ID '{ydid}'")
126
+ print_yd_object(CLIENT.images_client.get_image(ydid))
127
+
128
+ elif ":keyring:" in ydid:
129
+ print_log(f"Showing details of Keyring ID '{ydid}'")
130
+ keyrings = CLIENT.keyring_client.find_all_keyrings()
131
+ for keyring in keyrings:
132
+ if keyring.id == ydid:
133
+ print_yd_object(keyring)
134
+ break
135
+ else:
136
+ print_warning(f"Keyring ID '{ydid}' not found")
137
+
138
+ elif ":allow:" in ydid:
139
+ print_log(f"Showing details of Allowance ID '{ydid}'")
140
+ print_yd_object(CLIENT.allowances_client.get_allowance_by_id(ydid))
141
+
142
+ else:
143
+ print_warning(f"Unknown (or unsupported) YellowDog ID type for '{ydid}'")
144
+
145
+ except InvalidRequestException as e:
146
+ print_warning(f"Unable to show details for '{ydid}': {e}")
147
+ except Exception as e:
148
+ print_warning(f"Unable to show details for '{ydid}': {e}")
149
+
150
+
151
+ # Entry point
152
+ if __name__ == "__main__":
153
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: yellowdog-python-examples
3
- Version: 7.9.3
3
+ Version: 7.10.0
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
@@ -52,6 +52,7 @@ yd_commands/provision_utils.py
52
52
  yd_commands/remove.py
53
53
  yd_commands/resize.py
54
54
  yd_commands/settings.py
55
+ yd_commands/show.py
55
56
  yd_commands/shutdown.py
56
57
  yd_commands/start.py
57
58
  yd_commands/start_hold_common.py
@@ -1 +0,0 @@
1
- __version__ = "7.9.3"