Skip to content
Open
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
10 changes: 5 additions & 5 deletions scripts/mock_sf_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
Returns fake rows with the columns expected by the default script template
(Account_std__dll: description__c, sfdcorganizationid__c, kq_id__c).

POST /services/data/v63.0/ssot/data-custom-code
POST /services/data/v69.0/ssot/data-custom-code
Called by deploy_full() → create_deployment().
Returns a fake fileUploadUrl pointing back at this server.

GET /services/data/v63.0/ssot/data-custom-code/*
GET /services/data/v69.0/ssot/data-custom-code/*
Called by deploy_full() → wait_for_deployment() → get_deployments().
Returns deploymentStatus=Deployed immediately so the poll loop exits.

PUT /upload/*
The presigned fileUploadUrl target. Accepts the deployment.zip binary.

POST /services/data/v63.0/ssot/data-transforms
POST /services/data/v69.0/ssot/data-transforms
Called by deploy_full() → create_data_transform() for script packages.

GET /* (catch-all)
Expand Down Expand Up @@ -99,8 +99,8 @@
],
}

_DATA_CUSTOM_CODE_PATH = "/services/data/v63.0/ssot/data-custom-code"
_DATA_TRANSFORMS_PATH = "/services/data/v63.0/ssot/data-transforms"
_DATA_CUSTOM_CODE_PATH = "/services/data/v69.0/ssot/data-custom-code"
_DATA_TRANSFORMS_PATH = "/services/data/v69.0/ssot/data-transforms"


class MockSFHandler(BaseHTTPRequestHandler):
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
29 changes: 9 additions & 20 deletions src/datacustomcode/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,16 @@
)
from datacustomcode.scan import find_base_directory, get_package_type

DATA_CUSTOM_CODE_PATH = "services/data/v63.0/ssot/data-custom-code"
DATA_TRANSFORMS_PATH = "services/data/v63.0/ssot/data-transforms"
DATA_CUSTOM_CODE_INVOKE_OPTIONS_PATH = "services/data/v67.0/ssot/data-custom-code"
DATA_CUSTOM_CODE_PATH = "services/data/v69.0/ssot/data-custom-code"
DATA_TRANSFORMS_PATH = "services/data/v69.0/ssot/data-transforms"
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 Expand Up @@ -206,14 +202,7 @@ def create_deployment(
access_token: AccessTokenResponse, metadata: CodeExtensionMetadata
) -> CreateDeploymentResponse:
"""Create a custom code deployment in the DataCloud."""
# invokeOptions only binds at v67.0; route there when it is set so the
# option isn't silently dropped. Everything else stays on v63.0.
code_custom_code_path = (
DATA_CUSTOM_CODE_INVOKE_OPTIONS_PATH
if metadata.invokeOptions
else DATA_CUSTOM_CODE_PATH
)
url = _join_strip_url(access_token.instance_url, code_custom_code_path)
url = _join_strip_url(access_token.instance_url, DATA_CUSTOM_CODE_PATH)
body = dict[str, Any](
{
"label": metadata.name,
Expand Down
3 changes: 2 additions & 1 deletion tests/spark/test_column_hints_deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def _run(script: str) -> None:
[sys.executable, "-c", textwrap.dedent(script)],
capture_output=True,
text=True,
timeout=60, check=False,
timeout=60,
check=False,
)
if result.returncode != 0:
pytest.fail(
Expand Down
Loading
Loading