sagemaker-hyperpod 3.0.0__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 (66) hide show
  1. sagemaker/__init__.py +0 -0
  2. sagemaker/hyperpod/__init__.py +2 -0
  3. sagemaker/hyperpod/cli/__init__.py +0 -0
  4. sagemaker/hyperpod/cli/clients/__init__.py +12 -0
  5. sagemaker/hyperpod/cli/clients/kubernetes_client.py +365 -0
  6. sagemaker/hyperpod/cli/commands/__init__.py +0 -0
  7. sagemaker/hyperpod/cli/commands/cluster.py +627 -0
  8. sagemaker/hyperpod/cli/commands/inference.py +659 -0
  9. sagemaker/hyperpod/cli/commands/training.py +347 -0
  10. sagemaker/hyperpod/cli/constants/__init__.py +0 -0
  11. sagemaker/hyperpod/cli/constants/command_constants.py +105 -0
  12. sagemaker/hyperpod/cli/constants/exception_constants.py +13 -0
  13. sagemaker/hyperpod/cli/constants/hyperpod_instance_types.py +100 -0
  14. sagemaker/hyperpod/cli/constants/kueue_constants.py +17 -0
  15. sagemaker/hyperpod/cli/constants/pytorch_constants.py +15 -0
  16. sagemaker/hyperpod/cli/hyp_cli.py +132 -0
  17. sagemaker/hyperpod/cli/inference_utils.py +121 -0
  18. sagemaker/hyperpod/cli/service/__init__.py +12 -0
  19. sagemaker/hyperpod/cli/service/cancel_training_job.py +70 -0
  20. sagemaker/hyperpod/cli/service/discover_namespaces.py +108 -0
  21. sagemaker/hyperpod/cli/service/exec_command.py +75 -0
  22. sagemaker/hyperpod/cli/service/get_logs.py +136 -0
  23. sagemaker/hyperpod/cli/service/get_namespaces.py +59 -0
  24. sagemaker/hyperpod/cli/service/get_training_job.py +110 -0
  25. sagemaker/hyperpod/cli/service/list_pods.py +138 -0
  26. sagemaker/hyperpod/cli/service/list_training_jobs.py +178 -0
  27. sagemaker/hyperpod/cli/service/self_subject_access_review.py +47 -0
  28. sagemaker/hyperpod/cli/telemetry/__init__.py +12 -0
  29. sagemaker/hyperpod/cli/telemetry/user_agent.py +36 -0
  30. sagemaker/hyperpod/cli/templates/__init__.py +12 -0
  31. sagemaker/hyperpod/cli/templates/k8s_pytorch_job_template.py +74 -0
  32. sagemaker/hyperpod/cli/training_utils.py +200 -0
  33. sagemaker/hyperpod/cli/utils.py +183 -0
  34. sagemaker/hyperpod/cli/validators/__init__.py +12 -0
  35. sagemaker/hyperpod/cli/validators/cluster_validator.py +52 -0
  36. sagemaker/hyperpod/cli/validators/job_validator.py +346 -0
  37. sagemaker/hyperpod/cli/validators/validator.py +75 -0
  38. sagemaker/hyperpod/common/__init__.py +0 -0
  39. sagemaker/hyperpod/common/config/__init__.py +1 -0
  40. sagemaker/hyperpod/common/config/metadata.py +18 -0
  41. sagemaker/hyperpod/common/utils.py +299 -0
  42. sagemaker/hyperpod/inference/__init__.py +11 -0
  43. sagemaker/hyperpod/inference/config/__init__.py +0 -0
  44. sagemaker/hyperpod/inference/config/constants.py +18 -0
  45. sagemaker/hyperpod/inference/config/hp_endpoint_config.py +767 -0
  46. sagemaker/hyperpod/inference/config/hp_jumpstart_endpoint_config.py +572 -0
  47. sagemaker/hyperpod/inference/hp_endpoint.py +203 -0
  48. sagemaker/hyperpod/inference/hp_endpoint_base.py +223 -0
  49. sagemaker/hyperpod/inference/hp_jumpstart_endpoint.py +232 -0
  50. sagemaker/hyperpod/observability/MonitoringConfig.py +10 -0
  51. sagemaker/hyperpod/observability/__init__.py +0 -0
  52. sagemaker/hyperpod/observability/constants.py +2 -0
  53. sagemaker/hyperpod/observability/utils.py +64 -0
  54. sagemaker/hyperpod/training/__init__.py +9 -0
  55. sagemaker/hyperpod/training/config/__init__.py +1 -0
  56. sagemaker/hyperpod/training/config/hyperpod_pytorch_job_config.py +2977 -0
  57. sagemaker/hyperpod/training/config/hyperpod_pytorch_job_status.py +3083 -0
  58. sagemaker/hyperpod/training/hyperpod_pytorch_job.py +253 -0
  59. sagemaker_hyperpod-3.0.0.dist-info/METADATA +534 -0
  60. sagemaker_hyperpod-3.0.0.dist-info/RECORD +66 -0
  61. sagemaker_hyperpod-3.0.0.dist-info/WHEEL +5 -0
  62. sagemaker_hyperpod-3.0.0.dist-info/entry_points.txt +2 -0
  63. sagemaker_hyperpod-3.0.0.dist-info/licenses/LICENSE +175 -0
  64. sagemaker_hyperpod-3.0.0.dist-info/licenses/NOTICE +1 -0
  65. sagemaker_hyperpod-3.0.0.dist-info/top_level.txt +1 -0
  66. sagemaker_hyperpod-3.0.0.dist-info/zip-safe +1 -0
@@ -0,0 +1,64 @@
1
+ import re
2
+ from typing import Optional
3
+
4
+ import boto3
5
+ import yaml
6
+
7
+ from sagemaker.hyperpod.observability.constants import AMAZON_HYPERPOD_OBSERVABILITY, GRAFANA_DASHBOARD_UID
8
+ from sagemaker.hyperpod.observability.MonitoringConfig import MonitoringConfig
9
+ # ToDO : move below functions to SDK util method instead of importing from CLI
10
+ from sagemaker.hyperpod.cli.utils import get_eks_cluster_name, get_hyperpod_cluster_region
11
+
12
+ def is_observability_addon_enabled(eks_cluster_name):
13
+ response = boto3.client("eks").list_addons(clusterName=eks_cluster_name, maxResults=50)
14
+ if AMAZON_HYPERPOD_OBSERVABILITY in response.get('addons', []):
15
+ return True
16
+ else:
17
+ return False
18
+
19
+ def get_grafana_ws_name_from_arn(arn: str) -> str:
20
+ """
21
+ Parse the Grafana workspace name from a grafana workspace ARN.
22
+
23
+ Args:
24
+ arn (str): The ARN of the grafana workspace.
25
+
26
+ Returns: str: The name of the grafana workspace name if parsing is successful.
27
+ """
28
+ # Define the regex pattern to match the Grafana workspace ARN and capture the workspace name
29
+ pattern = r'g-[a-z0-9]+$'
30
+ workspace_id = re.search(pattern, arn).group(0)
31
+ #TODO : Add exception handling here.
32
+ return workspace_id
33
+
34
+
35
+ def build_grafana_url(grafana_workspace, region, dashboardUid):
36
+ grafana_url = f'https://{grafana_workspace}.grafana-workspace.{region}.amazonaws.com/d/{dashboardUid}'
37
+ return grafana_url
38
+
39
+
40
+ def get_monitoring_config() -> Optional[MonitoringConfig]:
41
+ eks_cluster_name = get_eks_cluster_name()
42
+ if not is_observability_addon_enabled(eks_cluster_name):
43
+ return None
44
+ response = boto3.client("eks").describe_addon(clusterName=eks_cluster_name, addonName=AMAZON_HYPERPOD_OBSERVABILITY)
45
+ config_values = yaml.safe_load(response['addon']['configurationValues'])
46
+
47
+ try:
48
+ prometheus_url = config_values['ampWorkspace']['prometheusEndpoint']
49
+ except KeyError:
50
+ prometheus_url = None
51
+ try:
52
+ region = get_hyperpod_cluster_region()
53
+ workspace_arn = config_values['amgWorkspace']['arn']
54
+ grafana_url = build_grafana_url(
55
+ get_grafana_ws_name_from_arn(workspace_arn) if workspace_arn else "default-workspace", region,
56
+ GRAFANA_DASHBOARD_UID)
57
+ except KeyError:
58
+ grafana_url = None
59
+ try:
60
+ metrics_data = config_values['metricsProvider']
61
+ except KeyError:
62
+ metrics_data = None
63
+
64
+ return MonitoringConfig(grafanaURL=grafana_url, prometheusURL=prometheus_url, availableMetrics=metrics_data)
@@ -0,0 +1,9 @@
1
+ from sagemaker.hyperpod.training.config.hyperpod_pytorch_job_config import *
2
+ from sagemaker.hyperpod.training.config.hyperpod_pytorch_job_status import (
3
+ HyperPodPytorchJobStatus,
4
+ )
5
+ from sagemaker.hyperpod.training.hyperpod_pytorch_job import (
6
+ HyperPodPytorchJob,
7
+ _load_hp_job,
8
+ _load_hp_job_list,
9
+ )
@@ -0,0 +1 @@
1
+ from sagemaker.hyperpod.common.config import *