sagemaker-hyperpod 3.10.0__tar.gz → 3.12.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 (107) hide show
  1. {sagemaker_hyperpod-3.10.0/src/sagemaker_hyperpod.egg-info → sagemaker_hyperpod-3.12.0}/PKG-INFO +1 -1
  2. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/pyproject.toml +1 -1
  3. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/setup.py +1 -1
  4. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/clients/kubernetes_client.py +29 -10
  5. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/cluster.py +5 -5
  6. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/ray_dashboard_connection.py +8 -29
  7. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/list_pods.py +33 -29
  8. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/self_subject_access_review.py +0 -1
  9. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0/src/sagemaker_hyperpod.egg-info}/PKG-INFO +1 -1
  10. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/LICENSE +0 -0
  11. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/NOTICE +0 -0
  12. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/README.md +0 -0
  13. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/setup.cfg +0 -0
  14. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/__init__.py +0 -0
  15. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/__init__.py +0 -0
  16. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/__init__.py +0 -0
  17. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/clients/__init__.py +0 -0
  18. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/cluster_stack_utils.py +0 -0
  19. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/cluster_utils.py +0 -0
  20. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/__init__.py +0 -0
  21. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/cluster_stack.py +0 -0
  22. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/inference.py +0 -0
  23. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/init.py +0 -0
  24. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/space.py +0 -0
  25. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/space_access.py +0 -0
  26. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/space_template.py +0 -0
  27. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/training.py +0 -0
  28. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/commands/training_recipe.py +0 -0
  29. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/common_utils.py +0 -0
  30. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/__init__.py +0 -0
  31. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/command_constants.py +0 -0
  32. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/exception_constants.py +0 -0
  33. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/hyperpod_instance_types.py +0 -0
  34. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/init_constants.py +0 -0
  35. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/kueue_constants.py +0 -0
  36. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/pytorch_constants.py +0 -0
  37. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/ray_dashboard_connection_constants.py +0 -0
  38. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/space_access_constants.py +0 -0
  39. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/space_constants.py +0 -0
  40. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/constants/space_template_constants.py +0 -0
  41. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/hyp_cli.py +0 -0
  42. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/inference_utils.py +0 -0
  43. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/init_utils.py +0 -0
  44. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/recipe_param_order.py +0 -0
  45. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/recipe_utils.py +0 -0
  46. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/__init__.py +0 -0
  47. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/cancel_training_job.py +0 -0
  48. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/discover_namespaces.py +0 -0
  49. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/exec_command.py +0 -0
  50. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/get_logs.py +0 -0
  51. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/get_namespaces.py +0 -0
  52. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/get_training_job.py +0 -0
  53. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/service/list_training_jobs.py +0 -0
  54. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/space_utils.py +0 -0
  55. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/templates/__init__.py +0 -0
  56. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/training_utils.py +0 -0
  57. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/type_handler_utils.py +0 -0
  58. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/utils.py +0 -0
  59. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/validators/__init__.py +0 -0
  60. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/validators/cluster_validator.py +0 -0
  61. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/validators/job_validator.py +0 -0
  62. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cli/validators/validator.py +0 -0
  63. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cluster_management/__init__.py +0 -0
  64. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cluster_management/config/__init__.py +0 -0
  65. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cluster_management/config/hp_cluster_stack_config.py +0 -0
  66. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/cluster_management/hp_cluster_stack.py +0 -0
  67. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/__init__.py +0 -0
  68. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/cli_decorators.py +0 -0
  69. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/config/__init__.py +0 -0
  70. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/config/metadata.py +0 -0
  71. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/exceptions/__init__.py +0 -0
  72. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/telemetry/__init__.py +0 -0
  73. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/telemetry/constants.py +0 -0
  74. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/telemetry/telemetry_logging.py +0 -0
  75. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/telemetry/user_agent.py +0 -0
  76. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/common/utils.py +0 -0
  77. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/__init__.py +0 -0
  78. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/config/__init__.py +0 -0
  79. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/config/constants.py +0 -0
  80. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/config/hp_endpoint_config.py +0 -0
  81. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/config/hp_jumpstart_endpoint_config.py +0 -0
  82. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/constant.py +0 -0
  83. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/hp_endpoint.py +0 -0
  84. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/hp_endpoint_base.py +0 -0
  85. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/hp_jumpstart_endpoint.py +0 -0
  86. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/inference/jumpstart_public_hub_visualization_utils.py +0 -0
  87. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/observability/MonitoringConfig.py +0 -0
  88. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/observability/__init__.py +0 -0
  89. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/observability/constants.py +0 -0
  90. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/observability/utils.py +0 -0
  91. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/space/__init__.py +0 -0
  92. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/space/hyperpod_space.py +0 -0
  93. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/space/hyperpod_space_template.py +0 -0
  94. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/space/utils.py +0 -0
  95. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/__init__.py +0 -0
  96. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/accelerator_partition_util.py +0 -0
  97. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/config/__init__.py +0 -0
  98. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/config/hyperpod_pytorch_job_unified_config.py +0 -0
  99. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/constants.py +0 -0
  100. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/hyperpod_pytorch_job.py +0 -0
  101. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker/hyperpod/training/quota_allocation_util.py +0 -0
  102. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/SOURCES.txt +0 -0
  103. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/dependency_links.txt +0 -0
  104. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/entry_points.txt +0 -0
  105. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/requires.txt +0 -0
  106. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/top_level.txt +0 -0
  107. {sagemaker_hyperpod-3.10.0 → sagemaker_hyperpod-3.12.0}/src/sagemaker_hyperpod.egg-info/zip-safe +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sagemaker-hyperpod
3
- Version: 3.10.0
3
+ Version: 3.12.0
4
4
  Summary: Amazon SageMaker HyperPod SDK and CLI
5
5
  Home-page: https://github.com/aws/sagemaker-hyperpod-cli
6
6
  Author: Amazon Web Services
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  dynamic = ["dependencies"]
7
7
  name = "sagemaker-hyperpod"
8
- version = "3.10.0"
8
+ version = "3.12.0"
9
9
  description = "Amazon SageMaker HyperPod SDK and CLI"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.8"
@@ -47,7 +47,7 @@ for root, dirs, files in os.walk(
47
47
  setup(
48
48
  data_files=sagemaker_hyperpod_recipes,
49
49
  name="sagemaker-hyperpod",
50
- version="3.9.0",
50
+ version="3.12.0",
51
51
  description="Amazon SageMaker HyperPod SDK and CLI",
52
52
  long_description=open("README.md").read(),
53
53
  long_description_content_type="text/markdown",
@@ -69,10 +69,20 @@ class KubernetesClient:
69
69
  def __new__(cls, config_file: Optional[str] = None) -> "KubernetesClient":
70
70
  if cls._instance is None:
71
71
  cls._instance = super(KubernetesClient, cls).__new__(cls)
72
+ cls._instance._config_file = config_file or KUBE_CONFIG_PATH
72
73
  config.load_kube_config(config_file=config_file or KUBE_CONFIG_PATH)
73
74
  cls._instance._kube_client = client.ApiClient()
74
75
  return cls._instance
75
76
 
77
+ @classmethod
78
+ def _from_config_file(cls, config_file: str) -> "KubernetesClient":
79
+ instance = super(KubernetesClient, cls).__new__(cls)
80
+ instance._config_file = config_file
81
+ instance._kube_client = config.new_client_from_config(
82
+ config_file=config_file
83
+ )
84
+ return instance
85
+
76
86
  def set_context(
77
87
  self,
78
88
  context_name: str,
@@ -110,8 +120,10 @@ class KubernetesClient:
110
120
  with open(KUBE_CONFIG_PATH, "w") as file:
111
121
  yaml.safe_dump(kubeconfig, file)
112
122
 
113
- # Load the updated kubeconfig
123
+ # Load the updated kubeconfig and refresh this client's configuration.
114
124
  config.load_kube_config(config_file=KUBE_CONFIG_PATH)
125
+ self._config_file = KUBE_CONFIG_PATH
126
+ self._kube_client = client.ApiClient()
115
127
  logger.debug(f"Current context set to '{context_name}'")
116
128
 
117
129
  def get_core_v1_api(self) -> client.CoreV1Api:
@@ -182,20 +194,23 @@ class KubernetesClient:
182
194
  file (str): The path to the kubeconfig file
183
195
  selector_str (str): Selector to filter
184
196
  """
185
- config.load_kube_config(config_file=file)
186
- v1Client = client.CoreV1Api()
197
+ api_client = self._kube_client
198
+ if getattr(self, "_config_file", None) != file:
199
+ api_client = config.new_client_from_config(config_file=file)
200
+
201
+ v1_client = client.CoreV1Api(api_client)
187
202
  _continue = None
188
203
 
189
204
  nodes = []
190
205
  while True:
191
- response = v1Client.list_node(
206
+ response = v1_client.list_node(
192
207
  label_selector=selector_str,
193
208
  limit=200, # Set a reasonable limit
194
209
  _continue=_continue,
195
210
  )
196
211
  nodes.extend(response.items)
197
212
 
198
- _continue = response._metadata._continue # Get the continue token
213
+ _continue = response.metadata._continue # Get the continue token
199
214
 
200
215
  if not _continue: # If there's no more data, break the loop
201
216
  break
@@ -236,7 +251,9 @@ class KubernetesClient:
236
251
  if namespace is None:
237
252
  return None
238
253
  try:
239
- response = client.CoreV1Api().read_namespace(name=namespace)
254
+ response = client.CoreV1Api(self._kube_client).read_namespace(
255
+ name=namespace
256
+ )
240
257
  labels = response.metadata.labels
241
258
  if labels and SAGEMAKER_MANAGED_QUEUE_LABEL in labels and labels[SAGEMAKER_MANAGED_QUEUE_LABEL] == "true":
242
259
  return response
@@ -254,19 +271,19 @@ class KubernetesClient:
254
271
  )
255
272
 
256
273
  def list_pods_in_all_namespaces_with_labels(self, label_selector: str):
257
- v1Client = client.CoreV1Api()
274
+ v1_client = client.CoreV1Api(self._kube_client)
258
275
  pods = []
259
276
  _continue = None
260
277
 
261
278
  while True:
262
- response = v1Client.list_pod_for_all_namespaces(
279
+ response = v1_client.list_pod_for_all_namespaces(
263
280
  label_selector=label_selector,
264
281
  limit=200, # Set a reasonable limit
265
282
  _continue=_continue,
266
283
  )
267
284
  pods.extend(response.items)
268
285
 
269
- _continue = response._metadata._continue # Get the continue token
286
+ _continue = response.metadata._continue # Get the continue token
270
287
 
271
288
  if not _continue: # If there's no more data, break the loop
272
289
  break
@@ -367,7 +384,9 @@ class KubernetesClient:
367
384
  )
368
385
 
369
386
  def get_cluster_queue(self, cluster_queue_name: str):
370
- return client.CustomObjectsApi().get_cluster_custom_object(
387
+ return client.CustomObjectsApi(
388
+ self._kube_client
389
+ ).get_cluster_custom_object(
371
390
  group=KUEUE_CUSTOM_OBJECT_GROUP,
372
391
  version=KUEUE_CUSTOM_OBJECT_VERSION,
373
392
  plural=CLUSTER_QUEUE_PRIORITY_CLASS_CUSTOM_OBJECT_PLURAL,
@@ -48,7 +48,7 @@ from sagemaker.hyperpod.common.telemetry.user_agent import (
48
48
  get_user_agent_extra_suffix,
49
49
  )
50
50
  from sagemaker.hyperpod.cli.service.list_pods import (
51
- ListPods,
51
+ _list_pods_and_get_requested_resources_group_by_node_name,
52
52
  )
53
53
  from sagemaker.hyperpod.cli.utils import (
54
54
  get_name_from_arn,
@@ -303,11 +303,11 @@ def rate_limited_operation(
303
303
  return None
304
304
  eks_cluster_name = get_name_from_arn(eks_cluster_arn)
305
305
  _update_kube_config(eks_cluster_name, region, temp_config_file)
306
- k8s_client = KubernetesClient(config_file=temp_config_file)
306
+ k8s_client = KubernetesClient._from_config_file(temp_config_file)
307
307
  nodes = k8s_client.list_node_with_temp_config(
308
308
  temp_config_file, SAGEMAKER_HYPERPOD_NAME_LABEL
309
309
  )
310
- nodes_info = _aggregate_nodes_info(nodes)
310
+ nodes_info = _aggregate_nodes_info(nodes, k8s_client)
311
311
 
312
312
  ns_nominal_quota = {}
313
313
  ns_quota_usage = {}
@@ -466,10 +466,10 @@ def _restructure_output(summary_list, namespaces):
466
466
 
467
467
  def _aggregate_nodes_info(
468
468
  nodes: List[client.V1Node],
469
+ k8s_client: KubernetesClient,
469
470
  ) -> Dict[str, Dict[str, Any]]:
470
- list_pods_service = ListPods()
471
471
  nodes_resource_allocated_dict = (
472
- list_pods_service.list_pods_and_get_requested_resources_group_by_node_name()
472
+ _list_pods_and_get_requested_resources_group_by_node_name(k8s_client)
473
473
  )
474
474
  nodes_summary: Dict[str, Dict[str, int]] = defaultdict(lambda: defaultdict(int))
475
475
 
@@ -27,36 +27,15 @@ from sagemaker.hyperpod.common.telemetry.constants import Feature
27
27
  from sagemaker.hyperpod.common.cli_decorators import handle_cli_exceptions
28
28
 
29
29
 
30
- def _get_eks_api_client():
31
- """Load kubeconfig and create an authenticated API client.
30
+ def _load_kube_config():
31
+ """Load kubeconfig so the default ApiClient is authenticated.
32
32
 
33
- Works around a kubernetes-client issue where exec-based tokens
34
- are not properly forwarded in the Authorization header.
33
+ Uses the library's default client (as HPSpace does) rather than copying
34
+ the token out of Configuration.api_key. The api_key entry is named
35
+ differently across kubernetes-client releases ("authorization" in 36.0.0,
36
+ "BearerToken" in 36.0.3+), so reading it by name is version-fragile.
35
37
  """
36
38
  config.load_kube_config()
37
- configuration = client.Configuration.get_default_copy()
38
-
39
- # Extract the token from the exec provider
40
- token = None
41
- if configuration.api_key and "authorization" in configuration.api_key:
42
- token_value = configuration.api_key["authorization"]
43
- prefix = "Bearer "
44
- if token_value.startswith(prefix):
45
- token = token_value.removeprefix(prefix)
46
- else:
47
- token = token_value
48
-
49
- # Clear api_key to avoid double-auth conflicts
50
- configuration.api_key = {}
51
- configuration.api_key_prefix = {}
52
-
53
- if token:
54
- return client.ApiClient(
55
- configuration,
56
- header_name="Authorization",
57
- header_value=f"Bearer {token}",
58
- )
59
- return client.ApiClient(configuration)
60
39
 
61
40
 
62
41
  @click.command("ray-dashboard-connection")
@@ -66,7 +45,7 @@ def _get_eks_api_client():
66
45
  @handle_cli_exceptions()
67
46
  def create_ray_dashboard_connection(cluster_name, namespace):
68
47
  """Create a RayDashboardConnection to get a dashboard URL for a RayCluster."""
69
- api_client = _get_eks_api_client()
48
+ _load_kube_config()
70
49
 
71
50
  body = {
72
51
  "apiVersion": f"{RAY_DASHBOARD_CONNECTION_GROUP}/{RAY_DASHBOARD_CONNECTION_VERSION}",
@@ -79,7 +58,7 @@ def create_ray_dashboard_connection(cluster_name, namespace):
79
58
  },
80
59
  }
81
60
 
82
- api = client.CustomObjectsApi(api_client)
61
+ api = client.CustomObjectsApi()
83
62
 
84
63
  try:
85
64
  result = api.create_namespaced_custom_object(
@@ -27,6 +27,36 @@ from kubernetes.client import (
27
27
  from sagemaker.hyperpod.cli.constants.command_constants import NVIDIA_GPU_RESOURCE_LIMIT_KEY
28
28
  from sagemaker.hyperpod.cli.service.discover_namespaces import DiscoverNamespaces
29
29
 
30
+ def _list_pods_and_get_requested_resources_group_by_node_name(
31
+ k8s_client: KubernetesClient,
32
+ ):
33
+ label_filter = "training.kubeflow.org/job-name"
34
+ pods = k8s_client.list_pods_in_all_namespaces_with_labels(label_filter)
35
+
36
+ accelerator_devices_requests_by_node = defaultdict(int)
37
+ for pod in pods:
38
+ node_name = pod.spec.node_name
39
+ if node_name:
40
+ for container in pod.spec.containers:
41
+ if container.resources and container.resources.requests:
42
+ gpu_request = container.resources.requests.get(
43
+ NVIDIA_GPU_RESOURCE_LIMIT_KEY
44
+ )
45
+ neuron_request = container.resources.requests.get(
46
+ "aws.amazon.com/neurondevice"
47
+ )
48
+ if gpu_request:
49
+ accelerator_devices_requests_by_node[node_name] += int(
50
+ gpu_request
51
+ )
52
+ if neuron_request:
53
+ accelerator_devices_requests_by_node[node_name] += int(
54
+ neuron_request
55
+ )
56
+
57
+ return accelerator_devices_requests_by_node
58
+
59
+
30
60
  class ListPods:
31
61
  def __init__(self):
32
62
  return
@@ -72,35 +102,9 @@ class ListPods:
72
102
  Group by the node_name of the pod and the value is the
73
103
  accelerator devices resources requested
74
104
  """
75
- k8s_client = KubernetesClient()
76
-
77
- label_filter = f"training.kubeflow.org/job-name"
78
- pods = k8s_client.list_pods_in_all_namespaces_with_labels(label_filter)
79
-
80
- # Dictionary to hold total GPU/Neuron requests per node
81
- accelerator_devices_requests_by_node = defaultdict(int)
82
-
83
- # Loop through each pod and aggregate the GPU resource requests per node
84
- for pod in pods:
85
- node_name = pod.spec.node_name
86
- # Check if the pod has a node_name assigned, if pod is not scheduled, it may not have node_name
87
- if node_name:
88
- for container in pod.spec.containers:
89
- if container.resources and container.resources.requests:
90
- gpu_request = container.resources.requests.get(NVIDIA_GPU_RESOURCE_LIMIT_KEY)
91
- neuron_request = container.resources.requests.get(
92
- "aws.amazon.com/neurondevice"
93
- )
94
- if gpu_request:
95
- accelerator_devices_requests_by_node[node_name] += int(
96
- gpu_request
97
- )
98
- if neuron_request:
99
- accelerator_devices_requests_by_node[node_name] += int(
100
- neuron_request
101
- )
102
-
103
- return accelerator_devices_requests_by_node
105
+ return _list_pods_and_get_requested_resources_group_by_node_name(
106
+ KubernetesClient()
107
+ )
104
108
 
105
109
  def _generate_list_pods_output(self, pods: V1PodList) -> Optional[str]:
106
110
  output_pods = {"pods": []}
@@ -38,7 +38,6 @@ class SelfSubjectAccessReview:
38
38
  spec=V1SelfSubjectAccessReviewSpec(
39
39
  resource_attributes=resource_attributes,
40
40
  non_resource_attributes=non_resource_attributes,
41
- local_vars_configuration=local_vars_configuration,
42
41
  )
43
42
  )
44
43
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sagemaker-hyperpod
3
- Version: 3.10.0
3
+ Version: 3.12.0
4
4
  Summary: Amazon SageMaker HyperPod SDK and CLI
5
5
  Home-page: https://github.com/aws/sagemaker-hyperpod-cli
6
6
  Author: Amazon Web Services