salesforce-data-customcode 6.1.0rc1__tar.gz → 7.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/PKG-INFO +100 -7
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/README.md +99 -6
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/pyproject.toml +1 -1
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/__init__.py +20 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/cli.py +29 -4
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/client.py +387 -100
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/config.py +5 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/config.yaml +8 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/constants.py +8 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/deploy.py +65 -26
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function/runtime.py +16 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/cdf.py +34 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/reader/base.py +85 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/reader/local_deltas.py +164 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/reader/streaming_seeder.py +114 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/writer/base.py +136 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/writer/csv.py +8 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/io/writer/local_deltas.py +133 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/writer/print.py +7 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/lineage/__init__.py +137 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/lineage/_worker.py +97 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/lineage/capture.py +289 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/lineage/tracer.py +566 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/__init__.py +28 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/base.py +54 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/default.py +93 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/direct/__init__.py +19 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/direct/auth.py +191 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/direct/credentials.py +122 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/direct/transport.py +110 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/direct/url_resolver.py +112 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/errors.py +36 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/spark_base.py +93 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/spark_default.py +154 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/__init__.py +14 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/http_method.py +29 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/http_request.py +63 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/http_request_builder.py +88 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/http_response.py +43 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential/types/http_response_builder.py +24 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/named_credential_config.py +105 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/run.py +103 -1
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/scan.py +184 -29
- salesforce_data_customcode-7.0.0/src/datacustomcode/spark/column_hints.py +194 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/template.py +33 -1
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_external_callout/README.md +120 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py +162 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json +11 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json +16 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_prediction/config.json +3 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/script/examples/external_callout/README.md +169 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/script/examples/external_callout/entrypoint.py +144 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/script/examples/external_callout/external_callout_config.json +11 -0
- salesforce_data_customcode-7.0.0/src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py +62 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/jupyterlab.sh +18 -4
- salesforce_data_customcode-6.1.0rc1/src/datacustomcode/io/reader/base.py +0 -43
- salesforce_data_customcode-6.1.0rc1/src/datacustomcode/io/writer/base.py +0 -59
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/LICENSE.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/auth.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/cmd.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/common_config.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/credentials.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_platform_client.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_platform_config.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/errors.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/impl/default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/spark_base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/spark_default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions/types.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/einstein_predictions_config.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/file/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/file/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/file/path/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/file/path/default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function/feature_types/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function/feature_types/chunking.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/function_utils.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/reader/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/reader/query_api.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/reader/sf_cli.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/reader/utils.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/io/writer/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/errors.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/spark_base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/spark_default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/types/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/types/generate_text_request.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/types/generate_text_request_builder.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/types/generate_text_response.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway/types/generate_text_response_builder.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/llm_gateway_config.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/mixin.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/py.typed +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/spark/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/spark/base.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/spark/default.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/.devcontainer/devcontainer.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/Dockerfile.dependencies +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/README.md +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/build_native_dependencies.sh +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/chunking/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/chunking/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/chunking/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1/src/datacustomcode/templates/function/example/chunking_with_llm → salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_external_callout}/config.json +0 -0
- {salesforce_data_customcode-6.1.0rc1/src/datacustomcode/templates/function/example/chunking_with_prediction → salesforce_data_customcode-7.0.0/src/datacustomcode/templates/function/example/chunking_with_llm}/config.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/example/chunking_with_llm/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/example/chunking_with_llm/files/chunking_prompt.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/example/chunking_with_llm/tests/test.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/example/chunking_with_prediction/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/example/chunking_with_prediction/tests/test.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/payload/utility.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/requirements-dev.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/function/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/.devcontainer/devcontainer.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/Dockerfile +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/Dockerfile.dependencies +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/README.md +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/account.ipynb +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/build_native_dependencies.sh +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/examples/employee_hierarchy/employee_data.csv +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/examples/employee_hierarchy/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/requirements-dev.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/templates/script/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/token_provider.py +0 -0
- {salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: salesforce-data-customcode
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
4
4
|
Summary: Data Cloud Custom Code SDK
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -170,14 +170,22 @@ Your Python dependencies can be packaged as .py files, .zip archives (containing
|
|
|
170
170
|
|
|
171
171
|
## API
|
|
172
172
|
|
|
173
|
-
Your entry point script will define logic using the `Client` object which
|
|
173
|
+
Your entry point script will define logic using the `Client` object (for batch transforms) or the `StreamingClient` object (for streaming delta transforms), which wrap the data access layers. Both are singletons; a single transform should use one or the other, not both.
|
|
174
174
|
|
|
175
|
-
You should only need the following methods:
|
|
175
|
+
For a batch transform, use `Client`. You should only need the following methods:
|
|
176
176
|
* `find_file_path(file_name)` – Resolve a bundled file (placed under `payload/files/`) to a `pathlib.Path` that exists. Works the same locally and inside Data Cloud — see [Bundled file resolution](#bundled-file-resolution) below for the full lookup order. Raises `FileNotFoundError` if the file isn't found.
|
|
177
177
|
* `read_dlo(name)` – Read from a Data Lake Object by name
|
|
178
178
|
* `read_dmo(name)` – Read from a Data Model Object by name
|
|
179
|
-
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data
|
|
180
|
-
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data
|
|
179
|
+
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
|
|
180
|
+
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
|
|
181
|
+
|
|
182
|
+
For a streaming (delta) transform, use `StreamingClient`, which exposes the streaming counterparts:
|
|
183
|
+
* `read_dlo_deltas()` – Read the streaming change feed (deltas) of a Data Lake Object as a streaming DataFrame.
|
|
184
|
+
* `read_dmo_deltas()` – Read the streaming change feed (deltas) of a Data Model Object as a streaming DataFrame.
|
|
185
|
+
* `write_dlo_deltas(name, spark_dataframe)` – Write a streaming DataFrame of deltas to a Data Lake Object; returns the started `StreamingQuery`
|
|
186
|
+
* `write_dmo_deltas(name, spark_dataframe)` – Write a streaming DataFrame of deltas to a Data Model Object; returns the started `StreamingQuery`
|
|
187
|
+
|
|
188
|
+
`find_file_path`, `llm_gateway_generate_text`, and `einstein_predict` are available on both clients.
|
|
181
189
|
|
|
182
190
|
For example:
|
|
183
191
|
```python
|
|
@@ -194,6 +202,66 @@ client.write_to_dlo('output_DLO')
|
|
|
194
202
|
> [!WARNING]
|
|
195
203
|
> Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.
|
|
196
204
|
|
|
205
|
+
### Writing Currency fields
|
|
206
|
+
|
|
207
|
+
A DLO or DMO with a Currency field has a system field, `cdp_sys_record_currency__c`, that holds each record's ISO currency code. Data Explorer UI uses it to display currency values, and shows a blank value if it's null (Query Editor still shows it).
|
|
208
|
+
|
|
209
|
+
Code Extensions don't set `cdp_sys_record_currency__c` for you, since only your script knows what currency its amounts are in. When writing to an object with Currency fields, set it yourself:
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
from pyspark.sql.functions import lit
|
|
213
|
+
|
|
214
|
+
# Either source has Currency fields: keep its cdp_sys_record_currency__c in your output
|
|
215
|
+
df = source.select("id__c", "amount__c", "cdp_sys_record_currency__c")
|
|
216
|
+
|
|
217
|
+
# OR amounts are in a known currency
|
|
218
|
+
df = df.withColumn("cdp_sys_record_currency__c", lit("EUR"))
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- Use an ISO code that exists in your org's configured currency rates.
|
|
222
|
+
- When aggregating, group by the currency code so amounts in different currencies aren't summed together.
|
|
223
|
+
|
|
224
|
+
See [`docs/examples/script/currency_totals`](docs/examples/script/currency_totals) for a complete example.
|
|
225
|
+
|
|
226
|
+
### Streaming (delta) transforms
|
|
227
|
+
|
|
228
|
+
Streaming BYOC transforms process a Data Lake Object's Change Data Feed continuously instead of reading a bounded snapshot. Use a `StreamingClient` and its `*_deltas` methods in place of the batch `Client` read/write methods:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
from pyspark.sql.functions import col, upper
|
|
232
|
+
|
|
233
|
+
from datacustomcode import StreamingClient
|
|
234
|
+
|
|
235
|
+
client = StreamingClient()
|
|
236
|
+
|
|
237
|
+
# read_dlo_deltas returns a *streaming* DataFrame over the change feed.
|
|
238
|
+
# The runtime resolves the single streaming source, so no name is passed.
|
|
239
|
+
deltas = client.read_dlo_deltas()
|
|
240
|
+
|
|
241
|
+
# Ordinary PySpark transform.
|
|
242
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
243
|
+
|
|
244
|
+
# write_dlo_deltas starts a streaming query and returns the StreamingQuery.
|
|
245
|
+
# The runtime owns the trigger and checkpoint location; you
|
|
246
|
+
# choose only the target table.
|
|
247
|
+
query = client.write_dlo_deltas("Output__dll", transformed)
|
|
248
|
+
query.awaitTermination()
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A streaming transform can also read and write Data Model Objects with `read_dmo_deltas()` and `write_dmo_deltas()`:
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
deltas = client.read_dmo_deltas()
|
|
255
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
256
|
+
query = client.write_dmo_deltas("Output__dlm", transformed)
|
|
257
|
+
query.awaitTermination()
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Notes:
|
|
261
|
+
|
|
262
|
+
- These methods only run inside the Data Cloud streaming (`DELTA_SYNC`) runtime. Locally (`datacustomcode run`) they raise `NotImplementedError`, since there is no change feed to stream.
|
|
263
|
+
- A complete runnable entry point is provided in [`examples/streaming_deltas/entrypoint.py`](src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py).
|
|
264
|
+
|
|
197
265
|
### Bundled file resolution
|
|
198
266
|
|
|
199
267
|
Place bundled files (CSVs, prompt files, etc.) under `payload/files/`. The same `client.find_file_path("data.csv")` call resolves consistently across all three runtimes:
|
|
@@ -212,6 +280,29 @@ If none of these exist, `find_file_path` raises `FileNotFoundError` with the lis
|
|
|
212
280
|
|
|
213
281
|
`$LIBRARY_PATH` is set automatically to the root of the package at runtime inside Data Cloud.
|
|
214
282
|
|
|
283
|
+
### Generating lineage
|
|
284
|
+
|
|
285
|
+
`generate_lineage` runs a script entry point locally and derives the field-level `dataLineage` section of `config.json` from the Spark plans of the DataFrames it writes:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
from datacustomcode.lineage import generate_lineage
|
|
289
|
+
|
|
290
|
+
result = generate_lineage("payload/entrypoint.py", sf_cli_org="my-org")
|
|
291
|
+
print(result.to_dict()["dataLineage"])
|
|
292
|
+
# [{"targetField": "Output__dll.name__c",
|
|
293
|
+
# "sourceFields": ["Input__dll.first__c", "Input__dll.last__c"]}, ...]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
The entry point runs exactly as it would locally (same config, reader, and credentials), except that writes are traced and validated against the target DLO instead of being performed. It runs in a separate Python process, which inherits your working directory, environment, and `sys.path`; errors raised by the script are re-raised from `generate_lineage`. Reads use the reader's `default_row_limit` (1000 by default; set it in your `config.yaml`).
|
|
297
|
+
|
|
298
|
+
> **Review the output before you use it.** The generated lineage is a starting point for review, not a guarantee. It reflects only the code paths and data your local run exercised, and it can't see inside UDFs. Accurate and complete `dataLineage` in your package is your responsibility as the package author.
|
|
299
|
+
|
|
300
|
+
- A target field's sources are the fields its *value* is computed from. Fields that only decide which rows, groups or branch are used aren't sources, however the logic is written: filter conditions, join keys, `groupBy` keys, sort keys, window `partitionBy`/`orderBy` keys, `when()`/`if()` conditions, and aggregate `FILTER (WHERE …)` clauses. For example, `groupBy("region").agg(sum("amount"))` and `sum("amount").over(Window.partitionBy("region"))` both trace to `amount` only.
|
|
301
|
+
- Fields computed only from literals are listed in `noSources`. So are fields whose value doesn't come from any input field's value, such as `row_number()`, `rank()`, `count("*")`, or `sum(when(cond, 1))`.
|
|
302
|
+
- Fields that can't be traced are listed in `unresolved` with a reason and get no lineage. This covers data that didn't come from `read_dlo`/`read_dmo` (for example a `toPandas()` → `createDataFrame` round trip), `mapInPandas`, and subqueries.
|
|
303
|
+
- `pairCount` is the total number of (target, source) field pairs.
|
|
304
|
+
- Only batch script packages are supported.
|
|
305
|
+
|
|
215
306
|
|
|
216
307
|
## CLI
|
|
217
308
|
|
|
@@ -327,6 +418,8 @@ Options:
|
|
|
327
418
|
#### `datacustomcode zip`
|
|
328
419
|
Zip a transformation job in preparation to upload to Data Cloud. Make sure to change directory into your code package folder (e.g., `my_package`) before running this command.
|
|
329
420
|
|
|
421
|
+
Symlinks inside the payload folder are not followed or packaged. Each symlinked file that is skipped is reported with a warning, and symlinked directories are not included. `datacustomcode deploy` zips the same way.
|
|
422
|
+
|
|
330
423
|
Arguments:
|
|
331
424
|
- `PATH`: Path to the code directory i.e. the payload folder (default: "payload")
|
|
332
425
|
|
|
@@ -497,7 +590,7 @@ exploration. Instead of running an entire script, one can run one code cell at
|
|
|
497
590
|
|
|
498
591
|
You can read more about Jupyter Notebooks here: https://jupyter.org/
|
|
499
592
|
|
|
500
|
-
1. Within the root project of your package folder, run `./jupyterlab.sh start`
|
|
593
|
+
1. Within the root project of your package folder, run `./jupyterlab.sh start`. This prints an access token and opens an already-authenticated JupyterLab session in your browser. If the browser doesn't open automatically, copy the printed `http://localhost:8888/?token=...` URL into your browser.
|
|
501
594
|
1. Double-click on "account.ipynb" file, which provides a starting point for a notebook
|
|
502
595
|
1. Use shift+enter to execute each cell within the notebook. Add/edit/delete cells of code as needed for your data exploration.
|
|
503
596
|
1. Don't forget to run `./jupyterlab.sh stop` to stop the docker container
|
|
@@ -588,5 +681,5 @@ If you're using OAuth Tokens authentication, the initial configure will retrieve
|
|
|
588
681
|
## Other docs
|
|
589
682
|
|
|
590
683
|
- [Troubleshooting](./docs/troubleshooting.md)
|
|
591
|
-
- [
|
|
684
|
+
- [Contributing](./CONTRIBUTING.md)
|
|
592
685
|
|
|
@@ -145,14 +145,22 @@ Your Python dependencies can be packaged as .py files, .zip archives (containing
|
|
|
145
145
|
|
|
146
146
|
## API
|
|
147
147
|
|
|
148
|
-
Your entry point script will define logic using the `Client` object which
|
|
148
|
+
Your entry point script will define logic using the `Client` object (for batch transforms) or the `StreamingClient` object (for streaming delta transforms), which wrap the data access layers. Both are singletons; a single transform should use one or the other, not both.
|
|
149
149
|
|
|
150
|
-
You should only need the following methods:
|
|
150
|
+
For a batch transform, use `Client`. You should only need the following methods:
|
|
151
151
|
* `find_file_path(file_name)` – Resolve a bundled file (placed under `payload/files/`) to a `pathlib.Path` that exists. Works the same locally and inside Data Cloud — see [Bundled file resolution](#bundled-file-resolution) below for the full lookup order. Raises `FileNotFoundError` if the file isn't found.
|
|
152
152
|
* `read_dlo(name)` – Read from a Data Lake Object by name
|
|
153
153
|
* `read_dmo(name)` – Read from a Data Model Object by name
|
|
154
|
-
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data
|
|
155
|
-
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data
|
|
154
|
+
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
|
|
155
|
+
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
|
|
156
|
+
|
|
157
|
+
For a streaming (delta) transform, use `StreamingClient`, which exposes the streaming counterparts:
|
|
158
|
+
* `read_dlo_deltas()` – Read the streaming change feed (deltas) of a Data Lake Object as a streaming DataFrame.
|
|
159
|
+
* `read_dmo_deltas()` – Read the streaming change feed (deltas) of a Data Model Object as a streaming DataFrame.
|
|
160
|
+
* `write_dlo_deltas(name, spark_dataframe)` – Write a streaming DataFrame of deltas to a Data Lake Object; returns the started `StreamingQuery`
|
|
161
|
+
* `write_dmo_deltas(name, spark_dataframe)` – Write a streaming DataFrame of deltas to a Data Model Object; returns the started `StreamingQuery`
|
|
162
|
+
|
|
163
|
+
`find_file_path`, `llm_gateway_generate_text`, and `einstein_predict` are available on both clients.
|
|
156
164
|
|
|
157
165
|
For example:
|
|
158
166
|
```python
|
|
@@ -169,6 +177,66 @@ client.write_to_dlo('output_DLO')
|
|
|
169
177
|
> [!WARNING]
|
|
170
178
|
> Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.
|
|
171
179
|
|
|
180
|
+
### Writing Currency fields
|
|
181
|
+
|
|
182
|
+
A DLO or DMO with a Currency field has a system field, `cdp_sys_record_currency__c`, that holds each record's ISO currency code. Data Explorer UI uses it to display currency values, and shows a blank value if it's null (Query Editor still shows it).
|
|
183
|
+
|
|
184
|
+
Code Extensions don't set `cdp_sys_record_currency__c` for you, since only your script knows what currency its amounts are in. When writing to an object with Currency fields, set it yourself:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from pyspark.sql.functions import lit
|
|
188
|
+
|
|
189
|
+
# Either source has Currency fields: keep its cdp_sys_record_currency__c in your output
|
|
190
|
+
df = source.select("id__c", "amount__c", "cdp_sys_record_currency__c")
|
|
191
|
+
|
|
192
|
+
# OR amounts are in a known currency
|
|
193
|
+
df = df.withColumn("cdp_sys_record_currency__c", lit("EUR"))
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
- Use an ISO code that exists in your org's configured currency rates.
|
|
197
|
+
- When aggregating, group by the currency code so amounts in different currencies aren't summed together.
|
|
198
|
+
|
|
199
|
+
See [`docs/examples/script/currency_totals`](docs/examples/script/currency_totals) for a complete example.
|
|
200
|
+
|
|
201
|
+
### Streaming (delta) transforms
|
|
202
|
+
|
|
203
|
+
Streaming BYOC transforms process a Data Lake Object's Change Data Feed continuously instead of reading a bounded snapshot. Use a `StreamingClient` and its `*_deltas` methods in place of the batch `Client` read/write methods:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from pyspark.sql.functions import col, upper
|
|
207
|
+
|
|
208
|
+
from datacustomcode import StreamingClient
|
|
209
|
+
|
|
210
|
+
client = StreamingClient()
|
|
211
|
+
|
|
212
|
+
# read_dlo_deltas returns a *streaming* DataFrame over the change feed.
|
|
213
|
+
# The runtime resolves the single streaming source, so no name is passed.
|
|
214
|
+
deltas = client.read_dlo_deltas()
|
|
215
|
+
|
|
216
|
+
# Ordinary PySpark transform.
|
|
217
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
218
|
+
|
|
219
|
+
# write_dlo_deltas starts a streaming query and returns the StreamingQuery.
|
|
220
|
+
# The runtime owns the trigger and checkpoint location; you
|
|
221
|
+
# choose only the target table.
|
|
222
|
+
query = client.write_dlo_deltas("Output__dll", transformed)
|
|
223
|
+
query.awaitTermination()
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
A streaming transform can also read and write Data Model Objects with `read_dmo_deltas()` and `write_dmo_deltas()`:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
deltas = client.read_dmo_deltas()
|
|
230
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
231
|
+
query = client.write_dmo_deltas("Output__dlm", transformed)
|
|
232
|
+
query.awaitTermination()
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Notes:
|
|
236
|
+
|
|
237
|
+
- These methods only run inside the Data Cloud streaming (`DELTA_SYNC`) runtime. Locally (`datacustomcode run`) they raise `NotImplementedError`, since there is no change feed to stream.
|
|
238
|
+
- A complete runnable entry point is provided in [`examples/streaming_deltas/entrypoint.py`](src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py).
|
|
239
|
+
|
|
172
240
|
### Bundled file resolution
|
|
173
241
|
|
|
174
242
|
Place bundled files (CSVs, prompt files, etc.) under `payload/files/`. The same `client.find_file_path("data.csv")` call resolves consistently across all three runtimes:
|
|
@@ -187,6 +255,29 @@ If none of these exist, `find_file_path` raises `FileNotFoundError` with the lis
|
|
|
187
255
|
|
|
188
256
|
`$LIBRARY_PATH` is set automatically to the root of the package at runtime inside Data Cloud.
|
|
189
257
|
|
|
258
|
+
### Generating lineage
|
|
259
|
+
|
|
260
|
+
`generate_lineage` runs a script entry point locally and derives the field-level `dataLineage` section of `config.json` from the Spark plans of the DataFrames it writes:
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
from datacustomcode.lineage import generate_lineage
|
|
264
|
+
|
|
265
|
+
result = generate_lineage("payload/entrypoint.py", sf_cli_org="my-org")
|
|
266
|
+
print(result.to_dict()["dataLineage"])
|
|
267
|
+
# [{"targetField": "Output__dll.name__c",
|
|
268
|
+
# "sourceFields": ["Input__dll.first__c", "Input__dll.last__c"]}, ...]
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The entry point runs exactly as it would locally (same config, reader, and credentials), except that writes are traced and validated against the target DLO instead of being performed. It runs in a separate Python process, which inherits your working directory, environment, and `sys.path`; errors raised by the script are re-raised from `generate_lineage`. Reads use the reader's `default_row_limit` (1000 by default; set it in your `config.yaml`).
|
|
272
|
+
|
|
273
|
+
> **Review the output before you use it.** The generated lineage is a starting point for review, not a guarantee. It reflects only the code paths and data your local run exercised, and it can't see inside UDFs. Accurate and complete `dataLineage` in your package is your responsibility as the package author.
|
|
274
|
+
|
|
275
|
+
- A target field's sources are the fields its *value* is computed from. Fields that only decide which rows, groups or branch are used aren't sources, however the logic is written: filter conditions, join keys, `groupBy` keys, sort keys, window `partitionBy`/`orderBy` keys, `when()`/`if()` conditions, and aggregate `FILTER (WHERE …)` clauses. For example, `groupBy("region").agg(sum("amount"))` and `sum("amount").over(Window.partitionBy("region"))` both trace to `amount` only.
|
|
276
|
+
- Fields computed only from literals are listed in `noSources`. So are fields whose value doesn't come from any input field's value, such as `row_number()`, `rank()`, `count("*")`, or `sum(when(cond, 1))`.
|
|
277
|
+
- Fields that can't be traced are listed in `unresolved` with a reason and get no lineage. This covers data that didn't come from `read_dlo`/`read_dmo` (for example a `toPandas()` → `createDataFrame` round trip), `mapInPandas`, and subqueries.
|
|
278
|
+
- `pairCount` is the total number of (target, source) field pairs.
|
|
279
|
+
- Only batch script packages are supported.
|
|
280
|
+
|
|
190
281
|
|
|
191
282
|
## CLI
|
|
192
283
|
|
|
@@ -302,6 +393,8 @@ Options:
|
|
|
302
393
|
#### `datacustomcode zip`
|
|
303
394
|
Zip a transformation job in preparation to upload to Data Cloud. Make sure to change directory into your code package folder (e.g., `my_package`) before running this command.
|
|
304
395
|
|
|
396
|
+
Symlinks inside the payload folder are not followed or packaged. Each symlinked file that is skipped is reported with a warning, and symlinked directories are not included. `datacustomcode deploy` zips the same way.
|
|
397
|
+
|
|
305
398
|
Arguments:
|
|
306
399
|
- `PATH`: Path to the code directory i.e. the payload folder (default: "payload")
|
|
307
400
|
|
|
@@ -472,7 +565,7 @@ exploration. Instead of running an entire script, one can run one code cell at
|
|
|
472
565
|
|
|
473
566
|
You can read more about Jupyter Notebooks here: https://jupyter.org/
|
|
474
567
|
|
|
475
|
-
1. Within the root project of your package folder, run `./jupyterlab.sh start`
|
|
568
|
+
1. Within the root project of your package folder, run `./jupyterlab.sh start`. This prints an access token and opens an already-authenticated JupyterLab session in your browser. If the browser doesn't open automatically, copy the printed `http://localhost:8888/?token=...` URL into your browser.
|
|
476
569
|
1. Double-click on "account.ipynb" file, which provides a starting point for a notebook
|
|
477
570
|
1. Use shift+enter to execute each cell within the notebook. Add/edit/delete cells of code as needed for your data exploration.
|
|
478
571
|
1. Don't forget to run `./jupyterlab.sh stop` to stop the docker container
|
|
@@ -563,4 +656,4 @@ If you're using OAuth Tokens authentication, the initial configure will retrieve
|
|
|
563
656
|
## Other docs
|
|
564
657
|
|
|
565
658
|
- [Troubleshooting](./docs/troubleshooting.md)
|
|
566
|
-
- [
|
|
659
|
+
- [Contributing](./CONTRIBUTING.md)
|
|
@@ -13,16 +13,24 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
from datacustomcode.spark.column_hints import install_column_casing_hints
|
|
17
|
+
|
|
18
|
+
# Friendlier errors for wrong-case column references. Idempotent.
|
|
19
|
+
install_column_casing_hints()
|
|
20
|
+
|
|
16
21
|
__all__ = [
|
|
17
22
|
"AuthType",
|
|
18
23
|
"Client",
|
|
19
24
|
"Credentials",
|
|
20
25
|
"DefaultSparkEinsteinPredictions",
|
|
21
26
|
"DefaultSparkLLMGateway",
|
|
27
|
+
"LocalDeltasReader",
|
|
28
|
+
"LocalDeltasWriter",
|
|
22
29
|
"PrintDataCloudWriter",
|
|
23
30
|
"QueryAPIDataCloudReader",
|
|
24
31
|
"SparkEinsteinPredictions",
|
|
25
32
|
"SparkLLMGateway",
|
|
33
|
+
"StreamingClient",
|
|
26
34
|
"einstein_predict_col",
|
|
27
35
|
"llm_gateway_generate_text_col",
|
|
28
36
|
]
|
|
@@ -34,6 +42,10 @@ def __getattr__(name: str):
|
|
|
34
42
|
from datacustomcode.client import Client
|
|
35
43
|
|
|
36
44
|
return Client
|
|
45
|
+
elif name == "StreamingClient":
|
|
46
|
+
from datacustomcode.client import StreamingClient
|
|
47
|
+
|
|
48
|
+
return StreamingClient
|
|
37
49
|
elif name == "AuthType":
|
|
38
50
|
from datacustomcode.credentials import AuthType
|
|
39
51
|
|
|
@@ -50,6 +62,14 @@ def __getattr__(name: str):
|
|
|
50
62
|
from datacustomcode.io.reader.query_api import QueryAPIDataCloudReader
|
|
51
63
|
|
|
52
64
|
return QueryAPIDataCloudReader
|
|
65
|
+
elif name == "LocalDeltasReader":
|
|
66
|
+
from datacustomcode.io.reader.local_deltas import LocalDeltasReader
|
|
67
|
+
|
|
68
|
+
return LocalDeltasReader
|
|
69
|
+
elif name == "LocalDeltasWriter":
|
|
70
|
+
from datacustomcode.io.writer.local_deltas import LocalDeltasWriter
|
|
71
|
+
|
|
72
|
+
return LocalDeltasWriter
|
|
53
73
|
elif name == "SparkLLMGateway":
|
|
54
74
|
from datacustomcode.llm_gateway import SparkLLMGateway
|
|
55
75
|
|
{salesforce_data_customcode-6.1.0rc1 → salesforce_data_customcode-7.0.0}/src/datacustomcode/cli.py
RENAMED
|
@@ -283,10 +283,19 @@ def deploy(
|
|
|
283
283
|
)
|
|
284
284
|
@click.option(
|
|
285
285
|
"--use-in-feature",
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
"-u",
|
|
287
|
+
default=None,
|
|
288
|
+
help=(
|
|
289
|
+
"Invoke option for this package. For scripts: 'BatchTransform' "
|
|
290
|
+
"(default) or 'StreamingTransform'. For functions: 'SearchIndexChunking'."
|
|
291
|
+
),
|
|
288
292
|
)
|
|
289
293
|
def init(directory: str, code_type: str, use_in_feature: Optional[str]):
|
|
294
|
+
from datacustomcode.constants import (
|
|
295
|
+
SCRIPT_USE_IN_FEATURE_BATCH,
|
|
296
|
+
SCRIPT_USE_IN_FEATURE_OPTIONS,
|
|
297
|
+
SCRIPT_USE_IN_FEATURE_STREAMING,
|
|
298
|
+
)
|
|
290
299
|
from datacustomcode.scan import (
|
|
291
300
|
dc_config_json_from_file,
|
|
292
301
|
update_config,
|
|
@@ -294,9 +303,23 @@ def init(directory: str, code_type: str, use_in_feature: Optional[str]):
|
|
|
294
303
|
)
|
|
295
304
|
from datacustomcode.template import copy_function_template, copy_script_template
|
|
296
305
|
|
|
306
|
+
streaming = False
|
|
307
|
+
if code_type == "script":
|
|
308
|
+
use_in_feature = use_in_feature or SCRIPT_USE_IN_FEATURE_BATCH
|
|
309
|
+
if use_in_feature not in SCRIPT_USE_IN_FEATURE_OPTIONS:
|
|
310
|
+
click.secho(
|
|
311
|
+
f"Error: Invalid --use-in-feature '{use_in_feature}' for a "
|
|
312
|
+
f"script. Valid options: {', '.join(SCRIPT_USE_IN_FEATURE_OPTIONS)}.",
|
|
313
|
+
fg="red",
|
|
314
|
+
)
|
|
315
|
+
raise click.Abort()
|
|
316
|
+
streaming = use_in_feature == SCRIPT_USE_IN_FEATURE_STREAMING
|
|
317
|
+
else:
|
|
318
|
+
use_in_feature = use_in_feature or "SearchIndexChunking"
|
|
319
|
+
|
|
297
320
|
click.echo("Copying template to " + click.style(directory, fg="blue", bold=True))
|
|
298
321
|
if code_type == "script":
|
|
299
|
-
copy_script_template(directory)
|
|
322
|
+
copy_script_template(directory, streaming=streaming)
|
|
300
323
|
elif code_type == "function":
|
|
301
324
|
copy_function_template(directory, use_in_feature)
|
|
302
325
|
entrypoint_path = os.path.join(directory, PAYLOAD_DIR, ENTRYPOINT_FILE)
|
|
@@ -306,7 +329,9 @@ def init(directory: str, code_type: str, use_in_feature: Optional[str]):
|
|
|
306
329
|
sdk_config = {"type": code_type}
|
|
307
330
|
write_sdk_config(directory, sdk_config)
|
|
308
331
|
|
|
309
|
-
config_json = dc_config_json_from_file(
|
|
332
|
+
config_json = dc_config_json_from_file(
|
|
333
|
+
entrypoint_path, code_type, streaming=streaming
|
|
334
|
+
)
|
|
310
335
|
with open(config_location, "w") as f:
|
|
311
336
|
json.dump(config_json, f, indent=2)
|
|
312
337
|
|