Skip to content

Commit 759dacd

Browse files
committed
Add computeType argument
1 parent 9cba6e6 commit 759dacd

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ datacustomcode run ./payload/entrypoint.py
7171
After modifying the `entrypoint.py` as needed, using any dependencies you add in the `.venv` virtual environment, you can run this script in Data Cloud:
7272
```zsh
7373
datacustomcode scan ./payload/entrypoint.py
74-
datacustomcode deploy --path ./payload --name my_custom_script
74+
datacustomcode deploy --path ./payload --name my_custom_script --compute-type CPU_L
7575
```
7676

7777
> [!TIP]
7878
> The `deploy` process can take several minutes. If you'd like more feedback on the underlying process, you can add `--debug` to the command like `datacustomcode --debug deploy --path ./payload --name my_custom_script`
79+
>
80+
> [!NOTE]
81+
> **Compute Types**: Choose the appropriate compute type based on your workload requirements:
82+
> - **CPU_L/CPU_XL/CPU_2XL/CPU_4XL**: Large, X-Large, 2X-Large and 4X-Large CPU instances for data processing
83+
> - Default is `CPU_2XL` which provides a good balance of performance and cost for most use cases
7984
8085
You can now use the Salesforce Data Cloud UI to find the created Data Transform and use the `Run Now` button to run it.
8186
Once the Data Transform run is successful, check the DLO your script is writing to and verify the correct records were added.
@@ -139,6 +144,7 @@ Options:
139144
- `--name TEXT`: Name of the transformation job [required]
140145
- `--version TEXT`: Version of the transformation job (default: "0.0.1")
141146
- `--description TEXT`: Description of the transformation job (default: "")
147+
- `--compute-type TEXT`: Compute type for the deployment (default: "CPU_M"). Available options: CPU_XS (extra-small), CPU_S (small), CPU_M (medium), CPU_L (large)
142148

143149
#### `datacustomcode init`
144150
Initialize a new development environment with a template.

src/datacustomcode/cli.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,30 @@ 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-
def deploy(path: str, name: str, version: str, description: str):
86+
@click.option("--compute-type", default="CPU_M")
87+
def deploy(path: str, name: str, version: str, description: str, compute_type: str):
8788
from datacustomcode.credentials import Credentials
8889
from datacustomcode.deploy import TransformationJobMetadata, deploy_full
8990

9091
logger.debug("Deploying project")
92+
93+
# Validate compute type
94+
from datacustomcode.deploy import COMPUTE_TYPES
95+
if compute_type not in COMPUTE_TYPES:
96+
click.secho(
97+
f"Error: Invalid compute type '{compute_type}'. "
98+
f"Available options: {', '.join(COMPUTE_TYPES.keys())}",
99+
fg="red",
100+
)
101+
raise click.Abort()
91102

103+
logger.info(f"Deploying with compute type: {compute_type}")
104+
92105
metadata = TransformationJobMetadata(
93106
name=name,
94107
version=version,
95108
description=description,
109+
computeType=compute_type,
96110
)
97111
try:
98112
credentials = Credentials.from_available()

src/datacustomcode/deploy.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,25 @@
4444
AUTH_PATH = "services/oauth2/token"
4545
WAIT_FOR_DEPLOYMENT_TIMEOUT = 3000
4646

47+
# Available compute types for Data Cloud deployments
48+
COMPUTE_TYPES = {
49+
"CPU_XS": "CPU_XS", # Extra Small CPU instance
50+
"CPU_S": "CPU_S", # Small CPU instance
51+
"CPU_M": "CPU_M", # Medium CPU instance (default)
52+
"CPU_L": "CPU_L" # Large CPU instance
53+
}
54+
4755

4856
class TransformationJobMetadata(BaseModel):
4957
name: str
5058
version: str
5159
description: str
60+
computeType: str = "CPU_M" # Default to CPU_M for backward compatibility
61+
62+
def __init__(self, **data):
63+
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())}")
5266

5367

5468
def _join_strip_url(*args: str) -> str:
@@ -123,7 +137,7 @@ def create_deployment(
123137
"name": metadata.name,
124138
"description": metadata.description,
125139
"version": metadata.version,
126-
"computeType": "CPU_M",
140+
"computeType": metadata.computeType,
127141
}
128142
logger.debug(f"Creating deployment {metadata.name}...")
129143
try:

0 commit comments

Comments
 (0)