Skip to content

Commit f8cd99c

Browse files
committed
updates
1 parent ca30690 commit f8cd99c

3 files changed

Lines changed: 48 additions & 20 deletions

File tree

src/datacustomcode/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ def zip(path: str):
8383
@click.option("--name", required=True)
8484
@click.option("--version", default="0.0.1")
8585
@click.option("--description", default="Custom Data Transform Code")
86-
@click.option("--compute-type", default="CPU_XL")
86+
@click.option("--compute-type", default="CPU_2XL")
8787
def deploy(path: str, name: str, version: str, description: str, compute_type: str):
8888
from datacustomcode.credentials import Credentials
8989
from datacustomcode.deploy import TransformationJobMetadata, deploy_full
9090

9191
logger.debug("Deploying project")
92-
92+
9393
# Validate compute type
9494
from datacustomcode.deploy import COMPUTE_TYPES
95-
if compute_type not in COMPUTE_TYPES:
95+
96+
if compute_type not in COMPUTE_TYPES.keys():
9697
click.secho(
9798
f"Error: Invalid compute type '{compute_type}'. "
9899
f"Available options: {', '.join(COMPUTE_TYPES.keys())}",
@@ -101,7 +102,7 @@ def deploy(path: str, name: str, version: str, description: str, compute_type: s
101102
raise click.Abort()
102103

103104
logger.info(f"Deploying with compute type: {compute_type}")
104-
105+
105106
metadata = TransformationJobMetadata(
106107
name=name,
107108
version=version,

src/datacustomcode/deploy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@
4545
WAIT_FOR_DEPLOYMENT_TIMEOUT = 3000
4646

4747
# Available compute types for Data Cloud deployments.
48+
# Nomenclature used by COMPUTE_TYPES keys align with
49+
# compute instances provisioned by Data Cloud.
4850
COMPUTE_TYPES = {
49-
"CPU_L": "CPU_XS", # Large CPU instance
50-
"CPU_XL": "CPU_S", # X-Large CPU instance
51-
"CPU_2XL": "CPU_M", # 2X-Large CPU instance (default)
52-
"CPU_4XL": "CPU_L" # 4X-Large CPU instance
51+
"CPU_L": "CPU_XS", # Large CPU instance
52+
"CPU_XL": "CPU_S", # X-Large CPU instance
53+
"CPU_2XL": "CPU_M", # 2X-Large CPU instance (default)
54+
"CPU_4XL": "CPU_L", # 4X-Large CPU instance
5355
}
5456

5557

@@ -58,11 +60,9 @@ class TransformationJobMetadata(BaseModel):
5860
version: str
5961
description: str
6062
computeType: str
61-
63+
6264
def __init__(self, **data):
6365
super().__init__(**data)
64-
if self.computeType not in COMPUTE_TYPES:
65-
raise ValueError(f"Invalid compute type '{self.computeType}'. Available options: {', '.join(COMPUTE_TYPES.keys())}")
6666

6767

6868
def _join_strip_url(*args: str) -> str:

tests/test_deploy.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,10 @@ def test_create_deployment_success(self, mock_make_api_call):
434434
access_token="test_token", instance_url="https://instance.example.com"
435435
)
436436
metadata = TransformationJobMetadata(
437-
name="test_job", version="1.0.0", description="Test job"
437+
name="test_job",
438+
version="1.0.0",
439+
description="Test job",
440+
computeType="CPU_M",
438441
)
439442

440443
mock_make_api_call.return_value = {
@@ -454,7 +457,10 @@ def test_create_deployment_conflict(self, mock_make_api_call):
454457
access_token="test_token", instance_url="https://instance.example.com"
455458
)
456459
metadata = TransformationJobMetadata(
457-
name="test_job", version="1.0.0", description="Test job"
460+
name="test_job",
461+
version="1.0.0",
462+
description="Test job",
463+
computeType="CPU_M",
458464
)
459465

460466
# Mock HTTP error with 409 Conflict
@@ -571,7 +577,10 @@ def test_get_deployments(self, mock_make_api_call):
571577
access_token="test_token", instance_url="https://instance.example.com"
572578
)
573579
metadata = TransformationJobMetadata(
574-
name="test_job", version="1.0.0", description="Test job"
580+
name="test_job",
581+
version="1.0.0",
582+
description="Test job",
583+
computeType="CPU_M",
575584
)
576585

577586
mock_make_api_call.return_value = {"deploymentStatus": "Deployed"}
@@ -595,7 +604,10 @@ def test_wait_for_deployment_success(
595604
access_token="test_token", instance_url="https://instance.example.com"
596605
)
597606
metadata = TransformationJobMetadata(
598-
name="test_job", version="1.0.0", description="Test job"
607+
name="test_job",
608+
version="1.0.0",
609+
description="Test job",
610+
computeType="CPU_M",
599611
)
600612
callback = MagicMock()
601613

@@ -622,7 +634,10 @@ def test_wait_for_deployment_timeout(
622634
access_token="test_token", instance_url="https://instance.example.com"
623635
)
624636
metadata = TransformationJobMetadata(
625-
name="test_job", version="1.0.0", description="Test job"
637+
name="test_job",
638+
version="1.0.0",
639+
description="Test job",
640+
computeType="CPU_M",
626641
)
627642

628643
# Mock time to simulate timeout
@@ -699,7 +714,10 @@ def test_create_data_transform(self, mock_make_api_call, mock_get_config):
699714
access_token="test_token", instance_url="https://instance.example.com"
700715
)
701716
metadata = TransformationJobMetadata(
702-
name="test_job", version="1.0.0", description="Test job"
717+
name="test_job",
718+
version="1.0.0",
719+
description="Test job",
720+
computeType="CPU_M",
703721
)
704722

705723
mock_get_config.return_value = DataTransformConfig(
@@ -762,7 +780,10 @@ def test_deploy_full(
762780
login_url="https://example.com",
763781
)
764782
metadata = TransformationJobMetadata(
765-
name="test_job", version="1.0.0", description="Test job"
783+
name="test_job",
784+
version="1.0.0",
785+
description="Test job",
786+
computeType="CPU_M",
766787
)
767788
callback = MagicMock()
768789

@@ -799,7 +820,10 @@ def test_run_data_transform(self, mock_make_api_call):
799820
access_token="test_token", instance_url="https://instance.example.com"
800821
)
801822
metadata = TransformationJobMetadata(
802-
name="test_job", version="1.0.0", description="Test job"
823+
name="test_job",
824+
version="1.0.0",
825+
description="Test job",
826+
computeType="CPU_M",
803827
)
804828

805829
mock_make_api_call.return_value = {"status": "Running"}
@@ -839,7 +863,10 @@ def test_deploy_full_happy_path(
839863
login_url="https://example.com",
840864
)
841865
metadata = TransformationJobMetadata(
842-
name="test_job", version="1.0.0", description="Test job"
866+
name="test_job",
867+
version="1.0.0",
868+
description="Test job",
869+
computeType="CPU_M",
843870
)
844871
callback = MagicMock()
845872

0 commit comments

Comments
 (0)