Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/sf_cli_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
--package-version 0.0.1 \
--description "Test script deploy" \
--package-dir testScript/payload \
--cpu-size CPU_2XL \
--cpu-size Standard_2XL \
-o dev1 || {
echo "::error::sf data-code-extension script deploy FAILED. Check mock server output above for which endpoint failed. The deploy command flags or API contract may have changed."
exit 1
Expand Down Expand Up @@ -303,7 +303,7 @@ jobs:
--package-version 0.0.1 \
--description "Test function deploy" \
--package-dir testFunction/payload \
--cpu-size CPU_2XL \
--cpu-size Standard_2XL \
-o dev1 || {
echo "::error::sf data-code-extension function deploy FAILED. Check mock server output above for which endpoint failed. The deploy command flags or API contract may have changed."
exit 1
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ After modifying the `entrypoint.py` as needed, using any dependencies you add in
```zsh
cd my_package
datacustomcode scan ./payload/entrypoint.py
datacustomcode deploy --path ./payload --name my_custom_script --cpu-size CPU_L --sf-cli-org myorg
datacustomcode deploy --path ./payload --name my_custom_script --cpu-size Standard_2XL --sf-cli-org myorg
```

> [!TIP]
> 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`

> [!NOTE]
> **CPU Size**: Choose the appropriate CPU/Compute Size based on your workload requirements:
> - **CPU_L / CPU_XL / CPU_2XL / CPU_4XL**: Large, X-Large, 2X-Large and 4X-Large CPU instances for data processing
> - Default is `CPU_2XL` which provides a good balance of performance and cost for most use cases
> **Compute Size**: Choose the appropriate Compute Size based on your workload requirements:
> - **Standard_L / Standard_XL / Standard_2XL / Standard_4XL**: Large, X-Large, 2X-Large and 4X-Large instances for data processing
> - Default is `Standard_2XL` which provides a good balance of performance and cost for most use cases

You can now use the Salesforce Data Cloud UI to find the created Data Transform and use the `Run Now` button to run it.
Once the Data Transform run is successful, check the DLO your script is writing to and verify the correct records were added.
Expand Down Expand Up @@ -356,7 +356,7 @@ Options:
- `--version TEXT`: Version of the transformation job (default: "0.0.1")
- `--description TEXT`: Description of the transformation job (default: "")
- `--network TEXT`: docker network (default: "default")
- `--cpu-size TEXT`: CPU size for the deployment (default: `CPU_2XL`). Available options: CPU_L(Large), CPU_XL(Extra Large), CPU_2XL(2X Large), CPU_4XL(4X Large)
- `--cpu-size TEXT`: Compute size for the deployment (default: `Standard_2XL`). Available options: Standard_L(Large), Standard_XL(Extra Large), Standard_2XL(2X Large), Standard_4XL(4X Large)
- `--sf-cli-org TEXT`: Salesforce CLI org alias or username (e.g. `myorg`). Fetches credentials via `sf org display` — no `datacustomcode configure` step needed. Takes precedence over `--profile` if both are supplied.
- `--function-invoke-opt TEXT`: Currently we support only `UnstructuredChunking` for functions.

Expand Down
22 changes: 11 additions & 11 deletions src/datacustomcode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ def zip(path: str, network: str):
@click.option("--network", default="default")
@click.option(
"--cpu-size",
default="CPU_2XL",
help="""CPU size for deployment. Available options:
default="Standard_2XL",
help="""Compute size for deployment. Available options:

\b
CPU_L - Large CPU instance
CPU_XL - X-Large CPU instance
CPU_2XL - 2X-Large CPU instance [DEFAULT]
CPU_4XL - 4X-Large CPU instance
Standard_L - Large instance
Standard_XL - X-Large instance
Standard_2XL - 2X-Large instance [DEFAULT]
Standard_4XL - 4X-Large instance

Choose based on your workload requirements.""",
)
Expand Down Expand Up @@ -224,22 +224,22 @@ def deploy(

logger.debug("Deploying project")

if cpu_size not in COMPUTE_TYPES.keys():
if cpu_size not in COMPUTE_TYPES:
click.secho(
f"Error: Invalid CPU size '{cpu_size}'. "
f"Available options: {', '.join(COMPUTE_TYPES.keys())}",
f"Error: Invalid compute size '{cpu_size}'. "
f"Available options: {', '.join(COMPUTE_TYPES)}",
fg="red",
)
raise click.Abort()

logger.debug(f"Deploying with CPU size: {cpu_size}")
logger.debug(f"Deploying with compute size: {cpu_size}")
base_directory = find_base_directory(path)
package_type = get_package_type(base_directory)
metadata = CodeExtensionMetadata(
name=name,
version=version,
description=description,
computeType=COMPUTE_TYPES[cpu_size],
computeType=cpu_size,
codeType=package_type,
)

Expand Down
2 changes: 1 addition & 1 deletion src/datacustomcode/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Default values
DEFAULT_PROFILE = "default"
DEFAULT_NETWORK = "default"
DEFAULT_CPU_SIZE = "CPU_2XL"
DEFAULT_CPU_SIZE = "Standard_2XL"

# Feature to template folder mapping
FEATURE_TEMPLATE_MAPPING = {
Expand Down
15 changes: 6 additions & 9 deletions src/datacustomcode/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,12 @@
DATA_CUSTOM_CODE_INVOKE_OPTIONS_PATH = "services/data/v67.0/ssot/data-custom-code"
WAIT_FOR_DEPLOYMENT_TIMEOUT = 3000

# Available compute types for Data Cloud deployments.
# Nomenclature used by COMPUTE_TYPES keys align with
# compute instances provisioned by Data Cloud.
COMPUTE_TYPES = {
"CPU_L": "CPU_XS", # Large CPU instance
"CPU_XL": "CPU_S", # X-Large CPU instance
"CPU_2XL": "CPU_M", # 2X-Large CPU instance (default)
"CPU_4XL": "CPU_L", # 4X-Large CPU instance
}
COMPUTE_TYPES = (
"Standard_L",
"Standard_XL",
"Standard_2XL",
"Standard_4XL",
)


def _sanitize_api_name(name: str) -> str:
Expand Down
50 changes: 25 additions & 25 deletions tests/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def test_create_deployment_success(self, mock_make_api_call):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand All @@ -633,7 +633,7 @@ def test_create_deployment_conflict(self, mock_make_api_call):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand All @@ -657,7 +657,7 @@ def test_create_deployment_function_invoke_options(self, mock_make_api_call):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
invokeOptions=["option1", "option2"],
codeType="function",
)
Expand All @@ -682,7 +682,7 @@ def test_create_deployment_default_path_no_invoke_options(self, mock_make_api_ca
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
mock_make_api_call.return_value = {
Expand All @@ -705,7 +705,7 @@ def test_create_deployment_invoke_options_routes_to_v67(self, mock_make_api_call
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
invokeOptions=["StreamingTransform"],
)
Expand Down Expand Up @@ -889,7 +889,7 @@ def test_get_deployments(self, mock_make_api_call):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -917,7 +917,7 @@ def test_wait_for_deployment_success(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
callback = MagicMock()
Expand Down Expand Up @@ -948,7 +948,7 @@ def test_wait_for_deployment_timeout(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1141,7 +1141,7 @@ def test_create_data_transform(self, mock_make_api_call, mock_get_config):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1190,7 +1190,7 @@ def test_create_data_transform_dmo(self, mock_make_api_call, mock_get_config):
name="dmo_job",
version="1.0.0",
description="DMO job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1252,7 +1252,7 @@ def test_create_data_transform_multiple_dmos(
name="dmo_multi",
version="1.0.0",
description="DMO multi",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1315,7 +1315,7 @@ def test_create_data_transform_dmo_emits_output_data_objects(
name="test_package",
version="1.0.0",
description="DMO with schema",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1409,7 +1409,7 @@ def test_create_data_transform_dlo_emits_output_data_objects(
name="test_package",
version="1.0.0",
description="DLO with schema",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1490,7 +1490,7 @@ def test_create_data_transform_dlo_omits_output_data_objects(
name="dlo_job",
version="1.0.0",
description="DLO job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1525,7 +1525,7 @@ def test_create_data_transform_dmo_missing_data_objects_raises(
name="dmo_no_schema",
version="1.0.0",
description="DMO no schema",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1557,7 +1557,7 @@ def test_create_data_transform_batch_type(
name="batch_job",
version="1.0.0",
description="Batch job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
data_transform_config = DataTransformConfig(
Expand Down Expand Up @@ -1591,7 +1591,7 @@ def test_create_data_transform_streaming_type(
name="streaming_job",
version="1.0.0",
description="Streaming job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
data_transform_config = DataTransformConfig(
Expand Down Expand Up @@ -1721,7 +1721,7 @@ def test_deploy_full(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
callback = MagicMock()
Expand Down Expand Up @@ -1778,7 +1778,7 @@ def test_deploy_full_client_credentials(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
callback = MagicMock()
Expand Down Expand Up @@ -1834,7 +1834,7 @@ def test_deploy_full_streaming_sets_invoke_options(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
access_token = AccessTokenResponse(
Expand Down Expand Up @@ -1878,7 +1878,7 @@ def test_deploy_full_batch_leaves_invoke_options_unset(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
access_token = AccessTokenResponse(
Expand All @@ -1904,7 +1904,7 @@ def test_run_data_transform(self, mock_make_api_call):
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down Expand Up @@ -1939,7 +1939,7 @@ def test_deploy_full_happy_path(
name="test_job",
version="1.0.0",
description="Test job",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
callback = MagicMock()
Expand Down Expand Up @@ -2006,7 +2006,7 @@ def test_deploy_full_with_access_token_response_skips_token_exchange(
name="test",
version="1.0.0",
description="desc",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)
mock_get_config.return_value = MagicMock(spec=[]) # not DataTransformConfig
Expand Down Expand Up @@ -2058,7 +2058,7 @@ def _make_metadata(self, name: str) -> CodeExtensionMetadata:
name=name,
version="1.0.0",
description="test",
computeType="CPU_M",
computeType="Standard_2XL",
codeType="script",
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sf_cli_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class TestDeployArgContract:
"--description", "My description",
"--path", "payload",
"--sf-cli-org", "my-org",
"--cpu-size", "CPU_2XL",
"--cpu-size", "Standard_2XL",
] # fmt: skip

@patch("datacustomcode.token_provider.SFCLITokenProvider")
Expand Down
Loading