Skip to content

Commit d74ad6d

Browse files
author
Mohamed Zeidan
committed
all unit tests passing, but need to fix inference import modules
1 parent 93da1ec commit d74ad6d

File tree

6 files changed

+670
-239
lines changed

6 files changed

+670
-239
lines changed

src/sagemaker/hyperpod/cli/commands/cluster.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
RATE_LIMIT = 4
2626
RATE_LIMIT_PERIOD = 1
2727

28+
# Import lightweight constants at module level for test compatibility
29+
from sagemaker.hyperpod.cli.constants.command_constants import (
30+
DEEP_HEALTH_CHECK_STATUS_LABEL,
31+
HP_HEALTH_STATUS_LABEL,
32+
INSTANCE_TYPE_LABEL,
33+
)
34+
35+
# Import lightweight ClusterValidator for test compatibility
36+
from sagemaker.hyperpod.cli.validators.cluster_validator import ClusterValidator
37+
2838
def _ensure_cluster_deps():
2939
"""Lazy load heavy dependencies for cluster commands"""
3040
global logging, subprocess, json, sys, botocore, defaultdict
@@ -36,7 +46,7 @@ def _ensure_cluster_deps():
3646
global TOTAL_ACCELERATOR_DEVICES_KEY, TEMP_KUBE_CONFIG_FILE, OutputFormat
3747
global get_user_agent_extra_suffix, ListPods, get_name_from_arn
3848
global get_sagemaker_client, setup_logger, set_logging_level
39-
global store_current_hyperpod_context, ClusterValidator, get_eks_cluster_name
49+
global store_current_hyperpod_context, get_eks_cluster_name
4050
global get_cluster_context_util, get_monitoring_config, is_observability_addon_enabled
4151
global _hyperpod_telemetry_emitter, Feature, RATE_LIMIT, RATE_LIMIT_PERIOD, logger
4252

@@ -66,7 +76,7 @@ def _ensure_cluster_deps():
6676
get_name_from_arn, get_sagemaker_client, setup_logger, set_logging_level,
6777
store_current_hyperpod_context, get_eks_cluster_name,
6878
)
69-
from sagemaker.hyperpod.cli.validators.cluster_validator import ClusterValidator
79+
# ClusterValidator already imported at module level, no need to reimport
7080
from sagemaker.hyperpod.common.utils import get_cluster_context as get_cluster_context_util
7181
from sagemaker.hyperpod.observability.utils import get_monitoring_config, is_observability_addon_enabled
7282
from sagemaker.hyperpod.common.telemetry.telemetry_logging import _hyperpod_telemetry_emitter

src/sagemaker/hyperpod/cli/commands/inference.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import click
22
from typing import Optional
33

4+
# Import heavy dependencies at module level for test compatibility
5+
# These will be available for mocking but won't impact startup performance
6+
# since they're only used when commands are actually executed
7+
json = None
8+
boto3 = None
9+
tabulate = None
10+
HPJumpStartEndpoint = None
11+
HPEndpoint = None
12+
Endpoint = None
13+
generate_click_command = None
14+
JS_REG = None
15+
C_REG = None
16+
_hyperpod_telemetry_emitter = None
17+
Feature = None
18+
419
# Lazy import function for ALL heavy dependencies
520
def _get_inference_dependencies():
621
"""Lazy load ALL heavy inference dependencies"""

src/sagemaker/hyperpod/cli/commands/training.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import click
22

3+
# Import heavy dependencies at module level for test compatibility
4+
# These will be available for mocking but won't impact startup performance
5+
HyperPodPytorchJob = None
6+
Metadata = None
7+
generate_click_command = None
8+
SCHEMA_REGISTRY = None
9+
_hyperpod_telemetry_emitter = None
10+
Feature = None
11+
312
# Lazy import function for ALL heavy dependencies
413
def _get_training_dependencies():
514
"""Lazy load ALL heavy training dependencies"""
@@ -60,9 +69,9 @@ def _pytorch_create(version, debug, config):
6069
if "run_policy" in spec:
6170
job_kwargs["run_policy"] = spec.get("run_policy")
6271

63-
# Create job
64-
job = HyperPodPytorchJob(**job_kwargs)
65-
job.create(debug=debug)
72+
# Create job
73+
job = HyperPodPytorchJob(**job_kwargs)
74+
job.create(debug=debug)
6675

6776
except Exception as e:
6877
raise click.UsageError(f"Failed to create job: {str(e)}")

0 commit comments

Comments
 (0)