Skip to content

Commit 5643df4

Browse files
committed
refactor run command
1 parent d0b9a15 commit 5643df4

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pip install salesforce-data-customcode
4040
datacustomcode init my_package
4141
```
4242

43+
To create a package of type function, pass the parameter `--code-type=function` with the init command.
44+
4345
This will yield all necessary files to get started:
4446
```
4547
.
@@ -244,6 +246,8 @@ Initialize a new development environment with a code package template.
244246

245247
Argument:
246248
- `DIRECTORY`: Directory to create project in (default: ".")
249+
Options:
250+
- `--code-type TEXT`: This can be either `function` or `script`. The default value is `script` if the argument is missing.
247251

248252

249253
#### `datacustomcode scan`
@@ -293,6 +297,7 @@ Options:
293297
- `--description TEXT`: Description of the transformation job (default: "")
294298
- `--network TEXT`: docker network (default: "default")
295299
- `--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)
300+
- `--function-invoke-opt TEXT`: Currently we support only `UnstructuredChunking` for functions.
296301

297302

298303
## Docker usage

src/datacustomcode/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ def run(
329329
):
330330
from datacustomcode.run import run_entrypoint
331331

332+
base_directory = find_base_directory(entrypoint)
333+
package_type = get_package_type(base_directory)
334+
332335
run_entrypoint(
333-
entrypoint, config_file, dependencies, profile, sf_cli_org=sf_cli_org
336+
entrypoint,
337+
config_file,
338+
dependencies,
339+
profile,
340+
package_type=package_type,
341+
sf_cli_org=sf_cli_org,
334342
)

src/datacustomcode/run.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
)
2626

2727
from datacustomcode.config import config
28-
from datacustomcode.scan import find_base_directory, get_package_type
2928

3029

3130
def _set_config_option(config_obj, key: str, value: str) -> None:
@@ -45,6 +44,7 @@ def run_entrypoint(
4544
config_file: Union[str, None],
4645
dependencies: List[str],
4746
profile: str,
47+
package_type: str = "script",
4848
sf_cli_org: Optional[str] = None,
4949
) -> None:
5050
"""Run the entrypoint script with the given config and dependencies.
@@ -54,6 +54,7 @@ def run_entrypoint(
5454
config_file: The config file to use.
5555
dependencies: The dependencies to import.
5656
profile: The credentials profile to use.
57+
package_type: The code type ("script" or "function").
5758
sf_cli_org: Optional SF CLI org alias or username. If provided, credentials
5859
are fetched via `sf org display` instead of from credentials.ini.
5960
"""
@@ -68,9 +69,6 @@ def run_entrypoint(
6869
f"config.json not found at {config_json_path}. config.json is required."
6970
)
7071

71-
base_directory = find_base_directory(entrypoint)
72-
package_type = get_package_type(base_directory)
73-
7472
try:
7573
with open(config_json_path, "r") as f:
7674
config_json = json.load(f)

0 commit comments

Comments
 (0)