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
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ Deploy a Data Code Extension function package to a Salesforce org.
```
USAGE
$ sf data-code-extension function deploy -n <value> --package-version <value> -d <value> -p <value> -o <value> [--flags-dir <value>]
[--network <value>] [--cpu-size CPU_L|CPU_XL|CPU_2XL|CPU_4XL]
[--network <value>] [--cpu-size Standard_L|Standard_XL|Standard_2XL|Standard_4XL]

FLAGS
-d, --description=<value> (required) Description of the package.
-n, --name=<value> (required) Name of the package to deploy.
-o, --target-org=<value> (required) Target Salesforce org for deployment.
-p, --package-dir=<value> (required) Directory containing the packaged code.
--cpu-size=<option> [default: CPU_2XL] CPU size for the deployment.
<options: CPU_L|CPU_XL|CPU_2XL|CPU_4XL>
--cpu-size=<option> [default: Standard_2XL] Compute size for the deployment.
<options: Standard_L|Standard_XL|Standard_2XL|Standard_4XL>
--network=<value> Network configuration for Jupyter notebooks.
--package-version=<value> (required) Version of the package to deploy.

Expand All @@ -106,7 +106,7 @@ DESCRIPTION
Deploy a Data Code Extension function package to a Salesforce org.

Deploys an initialized and packaged Data Cloud code extension to a Salesforce org. The package must be initialized and
zipped before deployment. Supports both script and function packages with configurable CPU resources and network
zipped before deployment. Supports both script and function packages with configurable compute resources and network
settings. Run this command from within the package directory (e.g. cd ./my-script-package).

EXAMPLES
Expand All @@ -115,10 +115,10 @@ EXAMPLES
$ sf data-code-extension function deploy --name my-package --package-version 1.0.0 --description "My package" \
--package-dir ./payload --target-org myorg

Deploy with a specific CPU size:
Deploy with a specific compute size:

$ sf data-code-extension function deploy --name my-package --package-version 1.0.0 --description "My package" \
--package-dir ./payload --target-org myorg --cpu-size CPU_4XL
--package-dir ./payload --target-org myorg --cpu-size Standard_4XL

FLAG DESCRIPTIONS
-d, --description=<value> Description of the package.
Expand All @@ -141,10 +141,10 @@ FLAG DESCRIPTIONS
The path to the directory containing your initialized and zipped Data Cloud custom code package. This directory
contains the package files created by the 'zip' command.

--cpu-size=CPU_L|CPU_XL|CPU_2XL|CPU_4XL CPU size for the deployment.
--cpu-size=Standard_L|Standard_XL|Standard_2XL|Standard_4XL Compute size for the deployment.

The CPU allocation size for your deployed package. Options are: CPU_L (small), CPU_XL (large), CPU_2XL (extra large,
default), CPU_4XL (maximum). Higher CPU sizes provide more processing power but may have quota implications.
The compute size for your deployed package. Options are: Standard_L (large), Standard_XL (extra large), Standard_2XL (2X large,
default), Standard_4XL (4X large, maximum). Larger sizes provide more processing power but may have quota implications.

--network=<value> Network configuration for Jupyter notebooks.

Expand Down Expand Up @@ -380,15 +380,15 @@ Deploy a Data Code Extension script package to a Salesforce org.
```
USAGE
$ sf data-code-extension script deploy -n <value> --package-version <value> -d <value> -p <value> -o <value> [--flags-dir <value>]
[--network <value>] [--cpu-size CPU_L|CPU_XL|CPU_2XL|CPU_4XL]
[--network <value>] [--cpu-size Standard_L|Standard_XL|Standard_2XL|Standard_4XL]

FLAGS
-d, --description=<value> (required) Description of the package.
-n, --name=<value> (required) Name of the package to deploy.
-o, --target-org=<value> (required) Target Salesforce org for deployment.
-p, --package-dir=<value> (required) Directory containing the packaged code.
--cpu-size=<option> [default: CPU_2XL] CPU size for the deployment.
<options: CPU_L|CPU_XL|CPU_2XL|CPU_4XL>
--cpu-size=<option> [default: Standard_2XL] Compute size for the deployment.
<options: Standard_L|Standard_XL|Standard_2XL|Standard_4XL>
--network=<value> Network configuration for Jupyter notebooks.
--package-version=<value> (required) Version of the package to deploy.

Expand All @@ -399,7 +399,7 @@ DESCRIPTION
Deploy a Data Code Extension script package to a Salesforce org.

Deploys an initialized and packaged Data Cloud code extension to a Salesforce org. The package must be initialized and
zipped before deployment. Supports both script and function packages with configurable CPU resources and network
zipped before deployment. Supports both script and function packages with configurable compute resources and network
settings. Run this command from within the package directory (e.g. cd ./my-script-package).

EXAMPLES
Expand All @@ -408,10 +408,10 @@ EXAMPLES
$ sf data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" \
--package-dir ./payload --target-org myorg

Deploy with a specific CPU size:
Deploy with a specific compute size:

$ sf data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" \
--package-dir ./payload --target-org myorg --cpu-size CPU_4XL
--package-dir ./payload --target-org myorg --cpu-size Standard_4XL

FLAG DESCRIPTIONS
-d, --description=<value> Description of the package.
Expand All @@ -434,10 +434,10 @@ FLAG DESCRIPTIONS
The path to the directory containing your initialized and zipped Data Cloud custom code package. This directory
contains the package files created by the 'zip' command.

--cpu-size=CPU_L|CPU_XL|CPU_2XL|CPU_4XL CPU size for the deployment.
--cpu-size=Standard_L|Standard_XL|Standard_2XL|Standard_4XL Compute size for the deployment.

The CPU allocation size for your deployed package. Options are: CPU_L (small), CPU_XL (large), CPU_2XL (extra large,
default), CPU_4XL (maximum). Higher CPU sizes provide more processing power but may have quota implications.
The compute size for your deployed package. Options are: Standard_L (large), Standard_XL (extra large), Standard_2XL (2X large,
default), Standard_4XL (4X large, maximum). Larger sizes provide more processing power but may have quota implications.

--network=<value> Network configuration for Jupyter notebooks.

Expand Down
22 changes: 11 additions & 11 deletions messages/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ Deploy a Data Code Extension %s package to a Salesforce org.

# description

Deploys an initialized and packaged Data Cloud code extension to a Salesforce org. The package must be initialized and zipped before deployment. Supports both script and function packages with configurable CPU resources and network settings. Run this command from within the package directory (e.g. cd ./my-script-package).
Deploys an initialized and packaged Data Cloud code extension to a Salesforce org. The package must be initialized and zipped before deployment. Supports both script and function packages with configurable compute resources and network settings. Run this command from within the package directory (e.g. cd ./my-script-package).

# examples

- Deploy a %s package to the org with alias "myorg":

<%= config.bin %> data-code-extension %s deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg

- Deploy with a specific CPU size:
- Deploy with a specific compute size:

<%= config.bin %> data-code-extension %s deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size CPU_4XL
<%= config.bin %> data-code-extension %s deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size Standard_4XL

# examples.script

- Deploy a script package to the org with alias "myorg":

<%= config.bin %> data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg

- Deploy with a specific CPU size:
- Deploy with a specific compute size:

<%= config.bin %> data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size CPU_4XL
<%= config.bin %> data-code-extension script deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size Standard_4XL

# examples.function

- Deploy a function package to the org with alias "myorg":

<%= config.bin %> data-code-extension function deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg

- Deploy with a specific CPU size:
- Deploy with a specific compute size:

<%= config.bin %> data-code-extension function deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size CPU_4XL
<%= config.bin %> data-code-extension function deploy --name my-package --package-version 1.0.0 --description "My package" --package-dir ./payload --target-org myorg --cpu-size Standard_4XL

# info.checkingPython

Expand Down Expand Up @@ -130,11 +130,11 @@ The path to the directory containing your initialized and zipped Data Cloud cust

# flags.cpuSize.summary

CPU size for the deployment.
Compute size for the deployment.

# flags.cpuSize.description

The CPU allocation size for your deployed package. Options are: CPU_L (small), CPU_XL (large), CPU_2XL (extra large, default), CPU_4XL (maximum). Higher CPU sizes provide more processing power but may have quota implications.
The compute size for your deployed package. Options are: Standard_L (large), Standard_XL (extra large), Standard_2XL (2X large, default), Standard_4XL (4X large, maximum). Larger sizes provide more processing power but may have quota implications.

# flags.targetOrg.summary

Expand Down Expand Up @@ -174,7 +174,7 @@ inferred from the entrypoint signature

# info.cpuSize

CPU size: %s
Compute size: %s

# info.creatingDeployment

Expand Down Expand Up @@ -210,7 +210,7 @@ Creating data transform...

# error.invalidCpuSize

Invalid CPU size '%s'. Available options: %s.
Invalid compute size '%s'. Available options: %s.

# error.invalidApiName

Expand Down
8 changes: 4 additions & 4 deletions src/base/deployBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages, Org, SfError } from '@salesforce/core';
import { NativeDeployer } from '../utils/nativeDeploy.js';
import { COMPUTE_TYPES, DEFAULT_COMPUTE_TYPE, NativeDeployer } from '../utils/nativeDeploy.js';
import { type SharedResultProps } from './types.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand Down Expand Up @@ -105,8 +105,8 @@ export abstract class DeployBase<TFlags extends BaseDeployFlags = BaseDeployFlag
'cpu-size': Flags.string({
summary: messages.getMessage('flags.cpuSize.summary'),
description: messages.getMessage('flags.cpuSize.description'),
options: ['CPU_L', 'CPU_XL', 'CPU_2XL', 'CPU_4XL'],
default: 'CPU_2XL',
options: [...COMPUTE_TYPES],
default: DEFAULT_COMPUTE_TYPE,
}),
'target-org': Flags.requiredOrg({
char: 'o',
Expand All @@ -126,7 +126,7 @@ export abstract class DeployBase<TFlags extends BaseDeployFlags = BaseDeployFlag
const description = flags.description;
const packageDir = flags['package-dir'];
const targetOrg = flags['target-org'];
const cpuSize = flags['cpu-size'] || 'CPU_2XL';
const cpuSize = flags['cpu-size'] || DEFAULT_COMPUTE_TYPE;
const network = flags.network;

if (packageDir.length === 0) {
Expand Down
21 changes: 8 additions & 13 deletions src/utils/nativeDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,11 @@ const CONFIG_FILE = 'config.json';
const DEFAULT_NETWORK = 'default';

/**
* Maps the user-facing `--cpu-size` value to the Data Cloud wire compute type.
* The offset (e.g. CPU_2XL -> CPU_M) is intentional and must match exactly; it
* mirrors `COMPUTE_TYPES` in `datacustomcode/deploy.py`, so do not "correct" it.
* The approved compute sizes. The `--cpu-size` value is sent to Data Cloud as the
* wire compute type unchanged; it mirrors `COMPUTE_TYPES` in `datacustomcode/deploy.py`.
*/
export const COMPUTE_TYPES: Record<string, string> = {
CPU_L: 'CPU_XS',
CPU_XL: 'CPU_S',
CPU_2XL: 'CPU_M',
CPU_4XL: 'CPU_L',
};
export const COMPUTE_TYPES = ['Standard_L', 'Standard_XL', 'Standard_2XL', 'Standard_4XL'] as const;
export const DEFAULT_COMPUTE_TYPE = 'Standard_2XL';

// Mirror of the two lookup tables in `datacustomcode/constants.py` that the
// function-deploy path relies on.
Expand Down Expand Up @@ -123,7 +118,7 @@ export type NativeDeployOptions = {
description: string;
/** The `--package-dir` value (Python's `--path`, e.g. `payload`). */
packageDir: string;
/** One of the COMPUTE_TYPES keys (CPU_L | CPU_XL | CPU_2XL | CPU_4XL). */
/** One of COMPUTE_TYPES (Standard_L | Standard_XL | Standard_2XL | Standard_4XL). */
cpuSize: string;
/** Docker network passed through to the zip/dependency build. Defaults to `default`. */
network?: string;
Expand Down Expand Up @@ -818,10 +813,10 @@ export class NativeDeployer {
const log = opts.log ?? ((): void => {});
const warn = opts.warn ?? log;

const computeType = COMPUTE_TYPES[opts.cpuSize];
if (!computeType) {
const computeType = opts.cpuSize;
if (!(COMPUTE_TYPES as readonly string[]).includes(computeType)) {
throw new SfError(
messages.getMessage('error.invalidCpuSize', [opts.cpuSize, Object.keys(COMPUTE_TYPES).join(', ')]),
messages.getMessage('error.invalidCpuSize', [opts.cpuSize, COMPUTE_TYPES.join(', ')]),
'InvalidCpuSize'
);
}
Expand Down
35 changes: 29 additions & 6 deletions test/commands/data-code-extension/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ describe('data-code-extension deploy', () => {
expect(opts.version).to.equal('1.0.0');
expect(opts.description).to.equal('Test script deployment');
expect(opts.packageDir).to.equal(testDir);
expect(opts.cpuSize).to.equal('CPU_2XL'); // Default CPU size
expect(opts.cpuSize).to.equal('Standard_2XL'); // Default compute size
expect(opts.connection).to.equal(mockConnection);
});

it('should deploy with custom CPU size', async () => {
it('should deploy with custom compute size', async () => {
await ScriptDeploy.run([
'--name',
'test-script',
Expand All @@ -108,11 +108,11 @@ describe('data-code-extension deploy', () => {
'--target-org',
'[email protected]',
'--cpu-size',
'CPU_4XL',
'Standard_4XL',
]);

const opts = deployStub.firstCall.args[0] as Record<string, unknown>;
expect(opts.cpuSize).to.equal('CPU_4XL');
expect(opts.cpuSize).to.equal('Standard_4XL');
});

it('should deploy with network configuration', async () => {
Expand Down Expand Up @@ -206,7 +206,30 @@ describe('data-code-extension deploy', () => {
expect(opts.name).to.equal('test-function');
});

it('should validate CPU size options', async () => {
it('should reject retired CPU_* sizes', async () => {
try {
await FunctionDeploy.run([
'--name',
'test-function',
'--package-version',
'1.0.0',
'--description',
'Test function deployment',
'--package-dir',
testDir,
'--target-org',
'[email protected]',
'--cpu-size',
'CPU_2XL',
]);
expect.fail('Should have thrown an error');
} catch (error) {
expect(error).to.be.instanceOf(Error);
expect(deployStub.called).to.be.false;
}
});

it('should validate compute size options', async () => {
try {
await FunctionDeploy.run([
'--name',
Expand All @@ -224,7 +247,7 @@ describe('data-code-extension deploy', () => {
]);
expect.fail('Should have thrown an error');
} catch (error) {
// Flag validation should catch invalid CPU size before deploy runs.
// Flag validation should catch invalid compute size before deploy runs.
expect(error).to.be.instanceOf(Error);
expect(deployStub.called).to.be.false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/expected/function/requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "smoke_function",
"description": "Smoke test function",
"version": "1.0.0",
"computeType": "CPU_M",
"computeType": "Standard_2XL",
"codeType": "function",
"functionInvokeOptions": ["UnstructuredChunking"]
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/expected/script/requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "smoke_script",
"description": "Smoke test script",
"version": "1.0.0",
"computeType": "CPU_M",
"computeType": "Standard_2XL",
"codeType": "script"
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/expected/streaming/requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "smoke_streaming",
"description": "Smoke test streaming script",
"version": "1.0.0",
"computeType": "CPU_M",
"computeType": "Standard_2XL",
"codeType": "script",
"invokeOptions": ["StreamingTransform"]
}
Expand Down
Loading
Loading