yellowdog-python-examples 8.2.1__py3-none-any.whl → 8.3.1__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 (49) hide show
  1. yellowdog_cli/__init__.py +1 -1
  2. yellowdog_cli/abort.py +11 -11
  3. yellowdog_cli/admin.py +2 -2
  4. yellowdog_cli/application.py +104 -0
  5. yellowdog_cli/boost.py +3 -3
  6. yellowdog_cli/cancel.py +9 -9
  7. yellowdog_cli/cloudwizard.py +4 -4
  8. yellowdog_cli/compare.py +6 -6
  9. yellowdog_cli/create.py +56 -54
  10. yellowdog_cli/delete.py +10 -10
  11. yellowdog_cli/download.py +15 -15
  12. yellowdog_cli/finish.py +9 -9
  13. yellowdog_cli/instantiate.py +19 -17
  14. yellowdog_cli/list.py +45 -43
  15. yellowdog_cli/provision.py +28 -28
  16. yellowdog_cli/remove.py +28 -26
  17. yellowdog_cli/resize.py +9 -9
  18. yellowdog_cli/show.py +29 -27
  19. yellowdog_cli/shutdown.py +9 -9
  20. yellowdog_cli/submit.py +29 -29
  21. yellowdog_cli/terminate.py +8 -8
  22. yellowdog_cli/upload.py +11 -11
  23. yellowdog_cli/utils/args.py +2 -0
  24. yellowdog_cli/utils/cloudwizard_aws.py +32 -32
  25. yellowdog_cli/utils/cloudwizard_azure.py +27 -27
  26. yellowdog_cli/utils/cloudwizard_common.py +12 -10
  27. yellowdog_cli/utils/cloudwizard_gcp.py +8 -8
  28. yellowdog_cli/utils/csv_data.py +7 -7
  29. yellowdog_cli/utils/entity_utils.py +85 -20
  30. yellowdog_cli/utils/follow_utils.py +5 -5
  31. yellowdog_cli/utils/interactive.py +8 -8
  32. yellowdog_cli/utils/load_config.py +11 -11
  33. yellowdog_cli/utils/load_resources.py +4 -4
  34. yellowdog_cli/utils/misc_utils.py +6 -3
  35. yellowdog_cli/utils/printing.py +10 -9
  36. yellowdog_cli/utils/provision_utils.py +2 -2
  37. yellowdog_cli/utils/settings.py +1 -0
  38. yellowdog_cli/utils/start_hold_common.py +7 -7
  39. yellowdog_cli/utils/submit_utils.py +5 -5
  40. yellowdog_cli/utils/upload_utils.py +3 -3
  41. yellowdog_cli/utils/variables.py +5 -5
  42. yellowdog_cli/utils/wrapper.py +32 -53
  43. {yellowdog_python_examples-8.2.1.dist-info → yellowdog_python_examples-8.3.1.dist-info}/METADATA +3 -2
  44. yellowdog_python_examples-8.3.1.dist-info/RECORD +65 -0
  45. {yellowdog_python_examples-8.2.1.dist-info → yellowdog_python_examples-8.3.1.dist-info}/entry_points.txt +1 -0
  46. yellowdog_python_examples-8.2.1.dist-info/RECORD +0 -64
  47. {yellowdog_python_examples-8.2.1.dist-info → yellowdog_python_examples-8.3.1.dist-info}/WHEEL +0 -0
  48. {yellowdog_python_examples-8.2.1.dist-info → yellowdog_python_examples-8.3.1.dist-info}/licenses/LICENSE +0 -0
  49. {yellowdog_python_examples-8.2.1.dist-info → yellowdog_python_examples-8.3.1.dist-info}/top_level.txt +0 -0
@@ -12,7 +12,7 @@ from yellowdog_cli.utils.items import Item
12
12
  from yellowdog_cli.utils.printing import (
13
13
  CONSOLE,
14
14
  print_error,
15
- print_log,
15
+ print_info,
16
16
  print_numbered_object_list,
17
17
  print_string,
18
18
  sorted_objects,
@@ -64,7 +64,7 @@ def select(
64
64
  return objects
65
65
 
66
66
  if ARGS_PARSER.auto_select_all:
67
- print_log("Automatically selecting all objects")
67
+ print_info("Automatically selecting all objects")
68
68
  return objects
69
69
 
70
70
  return [
@@ -148,9 +148,9 @@ def get_selected_list_items(
148
148
  )
149
149
  else:
150
150
  display_selections = ", ".join([str(x) for x in selected_list])
151
- print_log(f"Selected item number(s): {display_selections}")
151
+ print_info(f"Selected item number(s): {display_selections}")
152
152
  else:
153
- print_log("No items selected")
153
+ print_info("No items selected")
154
154
 
155
155
  return selected_list
156
156
 
@@ -161,13 +161,13 @@ def confirmed(msg: str) -> bool:
161
161
  """
162
162
  # Confirmed on the command line?
163
163
  if ARGS_PARSER is not None and ARGS_PARSER.yes:
164
- print_log(f"Action proceeding without user confirmation ({msg})")
164
+ print_info(f"Action proceeding without user confirmation ({msg})")
165
165
  return True
166
166
 
167
167
  # Confirmed using the environment variable?
168
168
  yd_yes = getenv(YD_YES, "")
169
169
  if yd_yes != "":
170
- print_log(
170
+ print_info(
171
171
  f"'{YD_YES}={yd_yes}': Action proceeding without user confirmation ({msg})"
172
172
  )
173
173
  return True
@@ -176,10 +176,10 @@ def confirmed(msg: str) -> bool:
176
176
  while True:
177
177
  response = _get_user_input(print_string(f"{msg} (y/N):") + " ")
178
178
  if response.lower() in ["y", "yes"]:
179
- print_log("Action confirmed by user")
179
+ print_info("Action confirmed by user")
180
180
  return True
181
181
  elif response.lower() in ["n", "no", ""]:
182
- print_log("Action cancelled by user")
182
+ print_info("Action cancelled by user")
183
183
  return False
184
184
 
185
185
 
@@ -25,7 +25,7 @@ from yellowdog_cli.utils.misc_utils import (
25
25
  # Load additional environment variables as early as possible
26
26
  load_dotenv_file()
27
27
 
28
- from yellowdog_cli.utils.printing import print_error, print_log
28
+ from yellowdog_cli.utils.printing import print_error, print_info
29
29
  from yellowdog_cli.utils.property_names import *
30
30
  from yellowdog_cli.utils.settings import (
31
31
  CR_BATCH_SIZE_DEFAULT,
@@ -69,7 +69,7 @@ CONFIG_FILE = relpath(
69
69
 
70
70
  if ARGS_PARSER.no_config:
71
71
  # Suppress use of any TOML config file
72
- print_log(f"Configuration file ('{CONFIG_FILE}') ignored")
72
+ print_info(f"Configuration file ('{CONFIG_FILE}') ignored")
73
73
  CONFIG_TOML = {COMMON_SECTION: {}}
74
74
  CONFIG_FILE_DIR = os.getcwd()
75
75
 
@@ -82,7 +82,7 @@ else:
82
82
  VARIABLE_SUBSTITUTIONS.update(
83
83
  {"config_dir_abs": config_dir_abs, "config_dir_name": config_dir_short}
84
84
  )
85
- print_log(f"Loading configuration data from: '{CONFIG_FILE}'")
85
+ print_info(f"Loading configuration data from: '{CONFIG_FILE}'")
86
86
  CONFIG_TOML: Dict = load_toml_file_with_variable_substitutions(CONFIG_FILE)
87
87
  try:
88
88
  validate_properties(CONFIG_TOML, f"'{CONFIG_FILE}'")
@@ -95,7 +95,7 @@ else:
95
95
  print_error(e)
96
96
  exit(1)
97
97
  # No config file, so create a stub config dictionary
98
- print_log(
98
+ print_info(
99
99
  "No configuration file; expecting configuration data on command line "
100
100
  "or in environment variables"
101
101
  )
@@ -140,7 +140,7 @@ def load_config_common() -> ConfigCommon:
140
140
  ]:
141
141
  if args_parser_value is not None:
142
142
  common_section[key_name] = args_parser_value
143
- print_log(
143
+ print_info(
144
144
  f"Using '{key_name}' provided on command line "
145
145
  "(or automatically set)"
146
146
  )
@@ -149,27 +149,27 @@ def load_config_common() -> ConfigCommon:
149
149
  and os.environ.get(env_var_name, None) is not None
150
150
  ):
151
151
  common_section[key_name] = os.environ[env_var_name]
152
- print_log(f"Using '{key_name}' provided via the environment")
152
+ print_info(f"Using '{key_name}' provided via the environment")
153
153
 
154
154
  # Provide default values for namespace and tag
155
155
  if common_section.get(NAMESPACE, None) is None:
156
156
  common_section[NAMESPACE] = "default"
157
157
  if ARGS_PARSER.namespace_required:
158
- print_log(
158
+ print_info(
159
159
  "Using default value for 'namespace': "
160
160
  f"'{common_section[NAMESPACE]}'"
161
161
  )
162
162
  if common_section.get(NAME_TAG, None) is None:
163
163
  common_section[NAME_TAG] = "{{username}}"
164
164
  if ARGS_PARSER.tag_required:
165
- print_log(
165
+ print_info(
166
166
  "Using default value for 'tag/prefix/name' = "
167
167
  f"'{VARIABLE_SUBSTITUTIONS['username']}'"
168
168
  )
169
169
 
170
170
  url = process_variable_substitutions(common_section.get(URL, DEFAULT_URL))
171
171
  if url != DEFAULT_URL:
172
- print_log(f"Using the YellowDog API at: {url}")
172
+ print_info(f"Using the YellowDog API at: {url}")
173
173
 
174
174
  # Exhaustive variable processing for common section variables
175
175
  # Note that add_substitutions() will perform all possible
@@ -193,7 +193,7 @@ def load_config_common() -> ConfigCommon:
193
193
  if certificates is not None:
194
194
  certificates = abspath(certificates)
195
195
  requests_ca_bundle = "REQUESTS_CA_BUNDLE"
196
- print_log(
196
+ print_info(
197
197
  f"Setting environment variable '{requests_ca_bundle}' to '{certificates}'"
198
198
  )
199
199
  os.environ["REQUESTS_CA_BUNDLE"] = certificates
@@ -218,7 +218,7 @@ def load_config_common() -> ConfigCommon:
218
218
 
219
219
  def import_toml(filename: str) -> Dict:
220
220
  filename = relpath(join(CONFIG_FILE_DIR, process_variable_substitutions(filename)))
221
- print_log(f"Loading imported common configuration data from: '{filename}'")
221
+ print_info(f"Loading imported common configuration data from: '{filename}'")
222
222
  try:
223
223
  common_config: Dict = load_toml_file_with_variable_substitutions(filename)
224
224
  return common_config[COMMON_SECTION]
@@ -6,7 +6,7 @@ from sys import exit
6
6
  from typing import Dict, List
7
7
 
8
8
  from yellowdog_cli.utils.args import ARGS_PARSER
9
- from yellowdog_cli.utils.printing import print_log, print_warning
9
+ from yellowdog_cli.utils.printing import print_info, print_warning
10
10
  from yellowdog_cli.utils.settings import (
11
11
  RN_ALLOWANCE,
12
12
  RN_APPLICATION,
@@ -72,7 +72,7 @@ def load_resource_specifications(creation_or_update: bool = True) -> List[Dict]:
72
72
  for resource in resources_loaded:
73
73
  process_variable_substitutions_insitu(resource)
74
74
 
75
- print_log(
75
+ print_info(
76
76
  f"Including {len(resources_loaded)} resource(s) from '{resource_spec}'"
77
77
  )
78
78
  resources += resources_loaded
@@ -81,7 +81,7 @@ def load_resource_specifications(creation_or_update: bool = True) -> List[Dict]:
81
81
  exit(0)
82
82
 
83
83
  if len(ARGS_PARSER.resource_specifications) > 1:
84
- print_log(f"Including {len(resources)} resources in total")
84
+ print_info(f"Including {len(resources)} resources in total")
85
85
 
86
86
  return _resequence_resources(resources, creation_or_update=creation_or_update)
87
87
 
@@ -96,7 +96,7 @@ def _resequence_resources(
96
96
  """
97
97
 
98
98
  if ARGS_PARSER.no_resequence:
99
- print_log("Not re-sequencing the resource list")
99
+ print_info("Not re-sequencing the resource list")
100
100
  return resources
101
101
 
102
102
  if len(resources) == 1:
@@ -19,7 +19,7 @@ from yellowdog_client.model import (
19
19
  )
20
20
 
21
21
  from yellowdog_cli.utils.args import ARGS_PARSER
22
- from yellowdog_cli.utils.printing import print_log
22
+ from yellowdog_cli.utils.printing import print_info
23
23
  from yellowdog_cli.utils.settings import NAMESPACE_OBJECT_STORE_PREFIX_SEPARATOR
24
24
 
25
25
  UTCNOW = datetime.now(timezone.utc)
@@ -256,7 +256,10 @@ def load_dotenv_file():
256
256
  if dotenv_file == "":
257
257
  return
258
258
 
259
- print_log(f"Loading environment variables from '{dotenv_file}'")
259
+ print_info(
260
+ f"Loading environment variables from '{dotenv_file}' ("
261
+ f"{'' if ARGS_PARSER.env_override else 'NOT '}OVERRIDING existing variables)"
262
+ )
260
263
 
261
264
  dotenv_yd_substitutions = [ # Find 'YD' variables
262
265
  f"'{key}'"
@@ -266,7 +269,7 @@ def load_dotenv_file():
266
269
  ]
267
270
 
268
271
  if len(dotenv_yd_substitutions) > 0:
269
- print_log(
272
+ print_info(
270
273
  "Adding 'YD' environment variable(s): "
271
274
  f"{', '.join(dotenv_yd_substitutions)}"
272
275
  )
@@ -98,7 +98,7 @@ except OSError:
98
98
  # Set up Rich formatting for coloured output
99
99
  class PrintLogHighlighter(RegexHighlighter):
100
100
  """
101
- Apply styles for print_log() lines.
101
+ Apply styles for print_info() lines.
102
102
  """
103
103
 
104
104
  base_style = "pyexamples."
@@ -196,7 +196,7 @@ def print_simple(
196
196
  CONSOLE.print(escape(log_message))
197
197
 
198
198
 
199
- def print_log(
199
+ def print_info(
200
200
  log_message: str = "",
201
201
  override_quiet: bool = False,
202
202
  no_fill: bool = False,
@@ -930,7 +930,7 @@ def print_numbered_object_list(
930
930
  if len(objects) == 0:
931
931
  return
932
932
 
933
- print_log(
933
+ print_info(
934
934
  "Displaying"
935
935
  f" {'all' if showing_all else 'matching'}"
936
936
  f" {(object_type_name if object_type_name is not None else get_type_name(objects[0]))}(s):",
@@ -1181,7 +1181,7 @@ def print_yd_object_list(
1181
1181
  """
1182
1182
 
1183
1183
  if ARGS_PARSER.output_file is not None:
1184
- print_log(f"Copying detailed resource list to '{ARGS_PARSER.output_file}'")
1184
+ print_info(f"Copying detailed resource list to '{ARGS_PARSER.output_file}'")
1185
1185
 
1186
1186
  if len(objects) > 1:
1187
1187
  print("[")
@@ -1208,7 +1208,7 @@ def print_worker_pool(
1208
1208
  """
1209
1209
  Reconstruct and print the JSON-formatted Worker Pool specification.
1210
1210
  """
1211
- print_log("Dry-run: Printing JSON Worker Pool specification")
1211
+ print_info("Dry-run: Printing JSON Worker Pool specification")
1212
1212
  wp_data = {
1213
1213
  "provisionedProperties": Json.dump(pwpp),
1214
1214
  "requirementTemplateUsage": Json.dump(crtu),
@@ -1248,9 +1248,9 @@ class WorkRequirementSnapshot:
1248
1248
  """
1249
1249
  Print the JSON representation.
1250
1250
  """
1251
- print_log("Dry-run: Printing JSON Work Requirement specification:")
1251
+ print_info("Dry-run: Printing JSON Work Requirement specification:")
1252
1252
  print_json(self.wr_data)
1253
- print_log("Dry-run: Complete")
1253
+ print_info("Dry-run: Complete")
1254
1254
 
1255
1255
 
1256
1256
  def print_compute_template_test_result(result: ComputeRequirementTemplateTestResult):
@@ -1258,7 +1258,7 @@ def print_compute_template_test_result(result: ComputeRequirementTemplateTestRes
1258
1258
  Print the results of a test submission of a Dynamic Compute Template.
1259
1259
  """
1260
1260
  if not isinstance(result, ComputeRequirementDynamicTemplateTestResult):
1261
- print_log("Reports are only available for Dynamic Templates")
1261
+ print_info("Reports are only available for Dynamic Templates")
1262
1262
  return
1263
1263
 
1264
1264
  report: BestComputeSourceReport = result.report
@@ -1410,6 +1410,7 @@ STATUS_COUNTS_INSTANCES = [
1410
1410
  ]
1411
1411
 
1412
1412
  STATUS_COUNTS_WORKERS = [
1413
+ StatusCount("BATCH_ALLOCATION"),
1413
1414
  StatusCount("DOING_TASK", True),
1414
1415
  StatusCount("STOPPED", True),
1415
1416
  StatusCount("SLEEPING"), # Should no longer see this state
@@ -1554,7 +1555,7 @@ def print_event(event: str, id_type: YDIDType):
1554
1555
  else:
1555
1556
  return
1556
1557
 
1557
- print_log(msg, no_fill=True)
1558
+ print_info(msg, no_fill=True)
1558
1559
 
1559
1560
 
1560
1561
  FIRST_OUTPUT_TO_FILE = True # Determine whether to 'write' or 'append'
@@ -13,7 +13,7 @@ from yellowdog_cli.utils.entity_utils import (
13
13
  find_image_name_or_id,
14
14
  )
15
15
  from yellowdog_cli.utils.load_config import CONFIG_FILE_DIR
16
- from yellowdog_cli.utils.printing import print_log
16
+ from yellowdog_cli.utils.printing import print_info
17
17
  from yellowdog_cli.utils.property_names import USERDATA, USERDATAFILE, USERDATAFILES
18
18
  from yellowdog_cli.utils.settings import WP_VARIABLES_POSTFIX, WP_VARIABLES_PREFIX
19
19
  from yellowdog_cli.utils.variables import (
@@ -92,7 +92,7 @@ def get_template_id(client: PlatformClient, template_id_or_name: str) -> str:
92
92
  f"Compute Requirement Template '{template_id_or_name}' not found"
93
93
  )
94
94
 
95
- print_log(
95
+ print_info(
96
96
  f"Substituting Compute Requirement Template name '{template_id_or_name}'"
97
97
  f" with ID {template_id}"
98
98
  )
@@ -56,6 +56,7 @@ JSON_INDENT = 2
56
56
  HIGHLIGHTED_STATES = [
57
57
  r"(?P<active>ALLOCATED)",
58
58
  r"(?P<active>DOING_TASK)",
59
+ r"(?P<active>BATCH_ALLOCATION)",
59
60
  r"(?P<active>EXECUTING)",
60
61
  r"(?P<active>EXPECTED)",
61
62
  r"(?P<active>PENDING)",
@@ -19,7 +19,7 @@ from yellowdog_cli.utils.entity_utils import (
19
19
  from yellowdog_cli.utils.follow_utils import follow_ids
20
20
  from yellowdog_cli.utils.interactive import confirmed, select
21
21
  from yellowdog_cli.utils.misc_utils import link_entity
22
- from yellowdog_cli.utils.printing import print_error, print_log, print_warning
22
+ from yellowdog_cli.utils.printing import print_error, print_info, print_warning
23
23
  from yellowdog_cli.utils.wrapper import ARGS_PARSER, CLIENT, CONFIG_COMMON
24
24
 
25
25
 
@@ -51,7 +51,7 @@ def _start_or_hold_work_requirements(
51
51
  names_or_ids=ARGS_PARSER.work_requirement_names,
52
52
  )
53
53
 
54
- print_log(
54
+ print_info(
55
55
  f"{action}ing Work Requirements in namespace "
56
56
  f"'{CONFIG_COMMON.namespace}' with "
57
57
  f"'{CONFIG_COMMON.name_tag}' in tag"
@@ -85,7 +85,7 @@ def _start_or_hold_work_requirements(
85
85
  CLIENT.work_client.get_work_requirement_by_id(work_summary.id)
86
86
  )
87
87
  count += 1
88
- print_log(
88
+ print_info(
89
89
  f"Applied {action} to "
90
90
  f"{link_entity(CONFIG_COMMON.url, work_requirement)} "
91
91
  f"('{work_summary.name}')"
@@ -97,12 +97,12 @@ def _start_or_hold_work_requirements(
97
97
  work_requirement_ids.append(work_summary.id)
98
98
 
99
99
  if count > 0:
100
- print_log(f"{action} applied to {count} Work Requirement(s)")
100
+ print_info(f"{action} applied to {count} Work Requirement(s)")
101
101
  else:
102
- print_log(f"No Work Requirements to {action}")
102
+ print_info(f"No Work Requirements to {action}")
103
103
 
104
104
  else:
105
- print_log(f"No Work Requirements available to {action}")
105
+ print_info(f"No Work Requirements available to {action}")
106
106
 
107
107
  return work_requirement_ids
108
108
 
@@ -142,7 +142,7 @@ def _start_or_hold_work_requirements_by_name_or_id(
142
142
 
143
143
  try:
144
144
  action_function(work_requirement_summary.id)
145
- print_log(f"Applied action '{action}' to Work Requirement '{name_or_id}'")
145
+ print_info(f"Applied action '{action}' to Work Requirement '{name_or_id}'")
146
146
  work_requirement_summaries.append(work_requirement_summary)
147
147
  except Exception as e:
148
148
  print_error(
@@ -22,7 +22,7 @@ from yellowdog_client.model import (
22
22
  )
23
23
 
24
24
  from yellowdog_cli.utils.config_types import ConfigCommon, ConfigWorkRequirement
25
- from yellowdog_cli.utils.printing import print_error, print_log, print_warning
25
+ from yellowdog_cli.utils.printing import print_error, print_info, print_warning
26
26
  from yellowdog_cli.utils.property_names import (
27
27
  DEPENDENCIES,
28
28
  DEPENDENT_ON,
@@ -187,7 +187,7 @@ class UploadedFiles:
187
187
  remote_file=uploaded_file_path,
188
188
  )
189
189
  else:
190
- print_log(
190
+ print_info(
191
191
  f"Dry-run: Would upload '{upload_file}' to"
192
192
  f" '{namespace}{NAMESPACE_OBJECT_STORE_PREFIX_SEPARATOR}{uploaded_file_path}'"
193
193
  )
@@ -245,7 +245,7 @@ class UploadedFiles:
245
245
  for uf in self._uploaded_files
246
246
  if uf.upload_namespace == namespace
247
247
  ]
248
- print_log(
248
+ print_info(
249
249
  f"Deleting {len(object_paths)} uploaded object(s) in "
250
250
  f"namespace '{namespace}'"
251
251
  )
@@ -288,7 +288,7 @@ def pause_between_batches(task_batch_size: int, batch_number: int, num_tasks: in
288
288
  )
289
289
 
290
290
  if ARGS_PARSER.pause_between_batches <= 0: # Manual delay
291
- print_log(
291
+ print_info(
292
292
  (
293
293
  f"Submitting batch number {batch_number + 1} ({task_range_str})"
294
294
  if first_batch
@@ -303,7 +303,7 @@ def pause_between_batches(task_batch_size: int, batch_number: int, num_tasks: in
303
303
  input()
304
304
 
305
305
  elif ARGS_PARSER.pause_between_batches > 0: # Automatic delay
306
- print_log(
306
+ print_info(
307
307
  f"Submitting batch number {batch_number + 1} ({task_range_str})"
308
308
  if first_batch
309
309
  else (
@@ -11,7 +11,7 @@ from yellowdog_client import PlatformClient
11
11
  from yellowdog_client.object_store.model import FileTransferStatus
12
12
 
13
13
  from yellowdog_cli.utils.misc_utils import link
14
- from yellowdog_cli.utils.printing import print_log
14
+ from yellowdog_cli.utils.printing import print_info
15
15
  from yellowdog_cli.utils.settings import NAMESPACE_OBJECT_STORE_PREFIX_SEPARATOR
16
16
 
17
17
 
@@ -107,7 +107,7 @@ def upload_file_core(
107
107
  if session.status != FileTransferStatus.Completed:
108
108
  raise Exception(f"Failed to upload file: {local_file}")
109
109
 
110
- print_log(
110
+ print_info(
111
111
  f"Uploaded file '{local_file}' to"
112
112
  f" '{namespace}{NAMESPACE_OBJECT_STORE_PREFIX_SEPARATOR}{remote_file}'"
113
113
  )
@@ -116,4 +116,4 @@ def upload_file_core(
116
116
  url,
117
117
  f"#/objects/{namespace}/{remote_file}?object=true",
118
118
  )
119
- print_log(f"Object URL: {link_}")
119
+ print_info(f"Object URL: {link_}")
@@ -22,7 +22,7 @@ from yellowdog_cli.utils.misc_utils import (
22
22
  remove_outer_delimiters,
23
23
  split_delimited_string,
24
24
  )
25
- from yellowdog_cli.utils.printing import print_error, print_json, print_log
25
+ from yellowdog_cli.utils.printing import print_error, print_info, print_json
26
26
  from yellowdog_cli.utils.property_names import *
27
27
  from yellowdog_cli.utils.settings import (
28
28
  ARRAY_TYPE_TAG,
@@ -79,7 +79,7 @@ for key, value in os.environ.items():
79
79
  subs_list.append(f"'{key}'")
80
80
 
81
81
  if len(subs_list) > 0:
82
- print_log(
82
+ print_info(
83
83
  "Adding environment-defined variable substitution(s) for: "
84
84
  f"{', '.join(subs_list)}"
85
85
  )
@@ -100,7 +100,7 @@ if ARGS_PARSER.variables is not None:
100
100
  exit(1) # Note: exception trap not yet in place
101
101
 
102
102
  if len(subs_list) > 0:
103
- print_log(
103
+ print_info(
104
104
  "Adding command-line-defined variable substitution(s) for: "
105
105
  f"{', '.join(subs_list)}"
106
106
  )
@@ -477,9 +477,9 @@ def load_jsonnet_file_with_variable_substitutions(
477
477
  process_variable_substitutions_insitu(dict_data, prefix, postfix)
478
478
 
479
479
  if ARGS_PARSER.jsonnet_dry_run:
480
- print_log(f"Dry-run: Printing Jsonnet to JSON conversion for '{filename}'")
480
+ print_info(f"Dry-run: Printing Jsonnet to JSON conversion for '{filename}'")
481
481
  print_json(dict_data)
482
- print_log("Dry-run: Complete")
482
+ print_info("Dry-run: Complete")
483
483
  if exit_on_dry_run:
484
484
  sys.exit(0)
485
485
 
@@ -5,16 +5,15 @@ for all commands.
5
5
 
6
6
  import os
7
7
  from sys import exit
8
- from typing import List
9
8
 
10
9
  from pypac import pac_context_for_url
11
10
  from yellowdog_client import PlatformClient
12
- from yellowdog_client.model import ApiKey, KeyringSummary, ServicesSchema
11
+ from yellowdog_client.model import ApiKey, ServicesSchema
13
12
 
14
13
  from yellowdog_cli.utils.args import ARGS_PARSER
15
14
  from yellowdog_cli.utils.config_types import ConfigCommon
16
15
  from yellowdog_cli.utils.load_config import load_config_common
17
- from yellowdog_cli.utils.printing import print_error, print_log
16
+ from yellowdog_cli.utils.printing import print_error, print_info
18
17
 
19
18
  CONFIG_COMMON: ConfigCommon = load_config_common()
20
19
  CLIENT = PlatformClient.create(
@@ -22,62 +21,38 @@ CLIENT = PlatformClient.create(
22
21
  ApiKey(CONFIG_COMMON.key, CONFIG_COMMON.secret),
23
22
  )
24
23
 
25
- from requests.exceptions import HTTPError
26
-
27
24
 
28
25
  def dry_run() -> bool:
29
26
  """
30
27
  Is this a dry-run?
31
28
  """
32
- dry_run = ARGS_PARSER.dry_run or ARGS_PARSER.process_csv_only
33
- if dry_run is None:
29
+ dry_run_ = ARGS_PARSER.dry_run or ARGS_PARSER.process_csv_only
30
+ if dry_run_ is None:
34
31
  return False
35
32
  else:
36
- return dry_run
37
-
38
-
39
- def print_account():
40
- """
41
- Print the six character hexadecimal account ID. Depends on there
42
- being at least one Keyring in the account. Omit if this is a dry run.
43
- """
44
- if not dry_run():
45
- try:
46
- keyrings: List[KeyringSummary] = CLIENT.keyring_client.find_all_keyrings()
47
- if len(keyrings) > 0:
48
- # This is a little brittle, obviously
49
- print_log(
50
- f"YellowDog Account short identifier is: '{keyrings[0].id[13:19]}'"
51
- )
52
- except HTTPError as e:
53
- if "Unauthorized" in str(e):
54
- print_error(
55
- "Unable to authorise YellowDog Application; please check"
56
- " your Application Key/Secret and its permissions"
57
- )
58
- exit(1)
59
- except:
60
- pass
33
+ return dry_run_
61
34
 
62
35
 
63
36
  def set_proxy():
64
37
  """
65
38
  Set the HTTPS proxy using autoconfiguration (PAC) if enabled.
66
39
  """
67
- if not dry_run():
68
- proxy_var = "HTTPS_PROXY"
69
- if CONFIG_COMMON.use_pac:
70
- print_log("Using Proxy Auto-Configuration (PAC)")
71
- with pac_context_for_url(CONFIG_COMMON.url):
72
- https_proxy = os.getenv(proxy_var, None)
73
- if https_proxy is not None:
74
- os.environ[proxy_var] = https_proxy
75
- else:
76
- print_log("No PAC proxy settings found")
77
- else:
40
+ if dry_run():
41
+ return
42
+
43
+ proxy_var = "HTTPS_PROXY"
44
+ if CONFIG_COMMON.use_pac:
45
+ print_info("Using Proxy Auto-Configuration (PAC)")
46
+ with pac_context_for_url(CONFIG_COMMON.url):
78
47
  https_proxy = os.getenv(proxy_var, None)
79
48
  if https_proxy is not None:
80
- print_log(f"Using {proxy_var}={https_proxy}")
49
+ os.environ[proxy_var] = https_proxy
50
+ else:
51
+ print_info("No PAC proxy settings found")
52
+ else:
53
+ https_proxy = os.getenv(proxy_var, None)
54
+ if https_proxy is not None:
55
+ print_info(f"Using {proxy_var}={https_proxy}")
81
56
 
82
57
 
83
58
  def main_wrapper(func):
@@ -86,7 +61,6 @@ def main_wrapper(func):
86
61
  exit_code = 0
87
62
  try:
88
63
  set_proxy()
89
- # print_account()
90
64
  func()
91
65
  except Exception as e:
92
66
  if "MissingPermissionException" in str(e):
@@ -96,24 +70,29 @@ def main_wrapper(func):
96
70
  " Application belongs to the required group(s), e.g.,"
97
71
  f" 'administrators', with roles in the required namespace(s): {e}"
98
72
  )
73
+ elif "Unauthorized" in str(e):
74
+ print_error(
75
+ f"Your Application Key ID and SECRET are not recognised: {e}"
76
+ )
99
77
  else:
100
78
  print_error(e)
101
79
  exit_code = 1
102
80
  except KeyboardInterrupt:
103
81
  print("\r", end="") # Overwrite the display of ^C
104
- print_log("Keyboard interruption ... exiting")
82
+ print_info("Keyboard interruption ... exiting")
105
83
  exit_code = 1
106
84
  finally:
107
85
  CLIENT.close()
108
86
  if exit_code == 0:
109
- print_log("Done")
87
+ print_info("Done")
110
88
  exit(exit_code)
111
89
  else:
112
- set_proxy()
113
- # print_account()
114
- func()
115
- CLIENT.close()
116
- print_log("Done")
117
- exit(0)
90
+ try:
91
+ set_proxy()
92
+ func()
93
+ print_info("Done")
94
+ exit(0)
95
+ finally:
96
+ CLIENT.close()
118
97
 
119
98
  return wrapper
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yellowdog-python-examples
3
- Version: 8.2.1
3
+ Version: 8.3.1
4
4
  Summary: Python CLI commands using the YellowDog Python SDK
5
5
  Author-email: YellowDog Limited <support@yellowdog.co>
6
6
  License-Expression: Apache-2.0
@@ -26,7 +26,7 @@ Requires-Dist: requests
26
26
  Requires-Dist: rich==13.9.4
27
27
  Requires-Dist: tabulate>=0.9.0
28
28
  Requires-Dist: toml
29
- Requires-Dist: yellowdog-sdk>=11.7.0
29
+ Requires-Dist: yellowdog-sdk>=12.0.0
30
30
  Provides-Extra: jsonnet
31
31
  Requires-Dist: jsonnet; extra == "jsonnet"
32
32
  Provides-Extra: cloudwizard
@@ -62,6 +62,7 @@ The commands support:
62
62
  - **Provisioning** Worker Pools with the **`yd-provision`** command
63
63
  - **Resizing** Worker Pools and Compute Requirements with the **`yd-resize`** command
64
64
  - **Showing** the details of any YellowDog entity using its YellowDog ID with the **`yd-show`** command
65
+ - **Showing** the details of the current Application with the **`yd-application`** command
65
66
  - **Shutting Down** Worker Pools and Nodes with the **`yd-shutdown`** command
66
67
  - **Starting** HELD Work Requirements and **Holding** (or pausing) RUNNING Work Requirements with the **`yd-start`** and **`yd-hold`** commands
67
68
  - **Submitting** Work Requirements with the **`yd-submit`** command