salesforce-data-customcode 6.1.0.dev2__tar.gz → 6.1.0.dev4__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.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/PKG-INFO +40 -3
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/README.md +39 -2
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/pyproject.toml +1 -1
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/__init__.py +5 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/cli.py +29 -4
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/client.py +212 -94
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/config.py +5 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/constants.py +8 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/deploy.py +55 -16
- salesforce_data_customcode-6.1.0.dev4/src/datacustomcode/io/reader/base.py +85 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/writer/base.py +33 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/__init__.py +2 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/direct/transport.py +6 -6
- salesforce_data_customcode-6.1.0.dev4/src/datacustomcode/named_credential/errors.py +36 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/run.py +11 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/scan.py +164 -29
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/template.py +13 -1
- salesforce_data_customcode-6.1.0.dev4/src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py +49 -0
- salesforce_data_customcode-6.1.0.dev2/src/datacustomcode/io/reader/base.py +0 -43
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/LICENSE.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/auth.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/cmd.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/common_config.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/config.yaml +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/credentials.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_platform_client.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_platform_config.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/errors.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/impl/default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/spark_base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/spark_default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions/types.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/einstein_predictions_config.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/file/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/file/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/file/path/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/file/path/default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function/feature_types/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function/feature_types/chunking.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function/runtime.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/function_utils.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/reader/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/reader/query_api.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/reader/sf_cli.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/reader/utils.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/writer/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/writer/csv.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/io/writer/print.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/errors.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/spark_base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/spark_default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/types/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/types/generate_text_request.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/types/generate_text_request_builder.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/types/generate_text_response.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway/types/generate_text_response_builder.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/llm_gateway_config.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/mixin.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/direct/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/direct/auth.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/direct/credentials.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/direct/url_resolver.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/spark_base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/spark_default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/http_method.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/http_request.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/http_request_builder.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/http_response.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential/types/http_response_builder.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/named_credential_config.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/py.typed +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/spark/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/spark/base.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/spark/default.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/__init__.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/.devcontainer/devcontainer.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/Dockerfile.dependencies +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/README.md +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/build_native_dependencies.sh +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/chunking/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/chunking/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/chunking/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_external_callout/README.md +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_external_callout/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_llm/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_llm/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_llm/files/chunking_prompt.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_llm/tests/test.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_prediction/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_prediction/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/example/chunking_with_prediction/tests/test.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/payload/utility.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/requirements-dev.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/function/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/.devcontainer/devcontainer.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/Dockerfile +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/Dockerfile.dependencies +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/README.md +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/account.ipynb +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/build_native_dependencies.sh +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/examples/employee_hierarchy/employee_data.csv +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/examples/employee_hierarchy/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/jupyterlab.sh +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/payload/config.json +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/payload/entrypoint.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/requirements-dev.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/templates/script/requirements.txt +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/token_provider.py +0 -0
- {salesforce_data_customcode-6.1.0.dev2 → salesforce_data_customcode-6.1.0.dev4}/src/datacustomcode/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: salesforce-data-customcode
|
|
3
|
-
Version: 6.1.0.
|
|
3
|
+
Version: 6.1.0.dev4
|
|
4
4
|
Summary: Data Cloud Custom Code SDK
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE.txt
|
|
@@ -170,15 +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
179
|
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
|
|
180
180
|
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
|
|
181
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
|
+
|
|
187
|
+
`find_file_path`, `llm_gateway_generate_text`, and `einstein_predict` are available on both clients.
|
|
188
|
+
|
|
182
189
|
For example:
|
|
183
190
|
```python
|
|
184
191
|
from datacustomcode import Client
|
|
@@ -194,6 +201,36 @@ client.write_to_dlo('output_DLO')
|
|
|
194
201
|
> [!WARNING]
|
|
195
202
|
> Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.
|
|
196
203
|
|
|
204
|
+
### Streaming (delta) transforms
|
|
205
|
+
|
|
206
|
+
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:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from pyspark.sql.functions import col, upper
|
|
210
|
+
|
|
211
|
+
from datacustomcode import StreamingClient
|
|
212
|
+
|
|
213
|
+
client = StreamingClient()
|
|
214
|
+
|
|
215
|
+
# read_dlo_deltas returns a *streaming* DataFrame over the change feed.
|
|
216
|
+
# The runtime resolves the single streaming source, so no name is passed.
|
|
217
|
+
deltas = client.read_dlo_deltas()
|
|
218
|
+
|
|
219
|
+
# Ordinary PySpark transform.
|
|
220
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
221
|
+
|
|
222
|
+
# write_dlo_deltas starts a streaming query and returns the StreamingQuery.
|
|
223
|
+
# The runtime owns the trigger and checkpoint location; you
|
|
224
|
+
# choose only the target table.
|
|
225
|
+
query = client.write_dlo_deltas("Output__dll", transformed)
|
|
226
|
+
query.awaitTermination()
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Notes:
|
|
230
|
+
|
|
231
|
+
- 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.
|
|
232
|
+
- A complete runnable entry point is provided in [`examples/streaming_deltas/entrypoint.py`](src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py).
|
|
233
|
+
|
|
197
234
|
### Bundled file resolution
|
|
198
235
|
|
|
199
236
|
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:
|
|
@@ -145,15 +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
154
|
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
|
|
155
155
|
* `write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
|
|
156
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
|
+
|
|
162
|
+
`find_file_path`, `llm_gateway_generate_text`, and `einstein_predict` are available on both clients.
|
|
163
|
+
|
|
157
164
|
For example:
|
|
158
165
|
```python
|
|
159
166
|
from datacustomcode import Client
|
|
@@ -169,6 +176,36 @@ client.write_to_dlo('output_DLO')
|
|
|
169
176
|
> [!WARNING]
|
|
170
177
|
> Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.
|
|
171
178
|
|
|
179
|
+
### Streaming (delta) transforms
|
|
180
|
+
|
|
181
|
+
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:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from pyspark.sql.functions import col, upper
|
|
185
|
+
|
|
186
|
+
from datacustomcode import StreamingClient
|
|
187
|
+
|
|
188
|
+
client = StreamingClient()
|
|
189
|
+
|
|
190
|
+
# read_dlo_deltas returns a *streaming* DataFrame over the change feed.
|
|
191
|
+
# The runtime resolves the single streaming source, so no name is passed.
|
|
192
|
+
deltas = client.read_dlo_deltas()
|
|
193
|
+
|
|
194
|
+
# Ordinary PySpark transform.
|
|
195
|
+
transformed = deltas.withColumn("description__c", upper(col("description__c")))
|
|
196
|
+
|
|
197
|
+
# write_dlo_deltas starts a streaming query and returns the StreamingQuery.
|
|
198
|
+
# The runtime owns the trigger and checkpoint location; you
|
|
199
|
+
# choose only the target table.
|
|
200
|
+
query = client.write_dlo_deltas("Output__dll", transformed)
|
|
201
|
+
query.awaitTermination()
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Notes:
|
|
205
|
+
|
|
206
|
+
- 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.
|
|
207
|
+
- A complete runnable entry point is provided in [`examples/streaming_deltas/entrypoint.py`](src/datacustomcode/templates/script/examples/streaming_deltas/entrypoint.py).
|
|
208
|
+
|
|
172
209
|
### Bundled file resolution
|
|
173
210
|
|
|
174
211
|
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:
|
|
@@ -23,6 +23,7 @@ __all__ = [
|
|
|
23
23
|
"QueryAPIDataCloudReader",
|
|
24
24
|
"SparkEinsteinPredictions",
|
|
25
25
|
"SparkLLMGateway",
|
|
26
|
+
"StreamingClient",
|
|
26
27
|
"einstein_predict_col",
|
|
27
28
|
"llm_gateway_generate_text_col",
|
|
28
29
|
]
|
|
@@ -34,6 +35,10 @@ def __getattr__(name: str):
|
|
|
34
35
|
from datacustomcode.client import Client
|
|
35
36
|
|
|
36
37
|
return Client
|
|
38
|
+
elif name == "StreamingClient":
|
|
39
|
+
from datacustomcode.client import StreamingClient
|
|
40
|
+
|
|
41
|
+
return StreamingClient
|
|
37
42
|
elif name == "AuthType":
|
|
38
43
|
from datacustomcode.credentials import AuthType
|
|
39
44
|
|
|
@@ -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
|
|
|
@@ -21,7 +21,9 @@ from typing import (
|
|
|
21
21
|
ClassVar,
|
|
22
22
|
Dict,
|
|
23
23
|
Optional,
|
|
24
|
+
TypeVar,
|
|
24
25
|
Union,
|
|
26
|
+
cast,
|
|
25
27
|
)
|
|
26
28
|
|
|
27
29
|
from datacustomcode.config import config
|
|
@@ -35,7 +37,12 @@ from datacustomcode.spark.default import DefaultSparkSessionProvider
|
|
|
35
37
|
if TYPE_CHECKING:
|
|
36
38
|
from pathlib import Path
|
|
37
39
|
|
|
38
|
-
from pyspark.sql import
|
|
40
|
+
from pyspark.sql import (
|
|
41
|
+
Column,
|
|
42
|
+
DataFrame as PySparkDataFrame,
|
|
43
|
+
SparkSession,
|
|
44
|
+
)
|
|
45
|
+
from pyspark.sql.streaming import StreamingQuery
|
|
39
46
|
|
|
40
47
|
from datacustomcode.einstein_predictions.spark_base import SparkEinsteinPredictions
|
|
41
48
|
from datacustomcode.einstein_predictions.types import PredictionType
|
|
@@ -48,6 +55,40 @@ if TYPE_CHECKING:
|
|
|
48
55
|
from datacustomcode.spark.base import BaseSparkSessionProvider
|
|
49
56
|
|
|
50
57
|
|
|
58
|
+
def _streaming_source_name() -> str:
|
|
59
|
+
"""Return the streaming transform's read-source name.
|
|
60
|
+
|
|
61
|
+
Resolved from ``config.streaming_source``, which ``run_entrypoint``
|
|
62
|
+
populates from config.json's ``streamingSource`` field.
|
|
63
|
+
|
|
64
|
+
Raises:
|
|
65
|
+
RuntimeError: If no ``streaming_source`` has been configured (e.g. the
|
|
66
|
+
transform's config.json has no ``streamingSource`` field).
|
|
67
|
+
"""
|
|
68
|
+
source = config.streaming_source
|
|
69
|
+
if not source:
|
|
70
|
+
raise RuntimeError(
|
|
71
|
+
"No streaming source configured. A streaming transform must declare "
|
|
72
|
+
"its read source in config.json under 'streamingSource'."
|
|
73
|
+
)
|
|
74
|
+
return source
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _active_client() -> "_BaseClient":
|
|
78
|
+
"""Return the client backing the module-level Spark column helpers.
|
|
79
|
+
|
|
80
|
+
Prefers an already-initialized singleton so a streaming job reuses its
|
|
81
|
+
:class:`StreamingClient` (and a batch job its :class:`Client`) rather than
|
|
82
|
+
forcing an unrelated client into existence. Falls back to building the
|
|
83
|
+
batch :class:`Client` when neither has been created yet.
|
|
84
|
+
"""
|
|
85
|
+
if Client._instance is not None:
|
|
86
|
+
return Client._instance
|
|
87
|
+
if StreamingClient._instance is not None:
|
|
88
|
+
return StreamingClient._instance
|
|
89
|
+
return Client()
|
|
90
|
+
|
|
91
|
+
|
|
51
92
|
def _build_spark_llm_gateway() -> "SparkLLMGateway":
|
|
52
93
|
"""Instantiate the SDK-configured :class:`SparkLLMGateway`.
|
|
53
94
|
|
|
@@ -103,7 +144,7 @@ def llm_gateway_generate_text_col(
|
|
|
103
144
|
the generated text; on failure, ``status == "ERROR"`` and the
|
|
104
145
|
``error_*`` fields carry diagnostic detail.
|
|
105
146
|
"""
|
|
106
|
-
gateway =
|
|
147
|
+
gateway = _active_client()._get_spark_llm_gateway()
|
|
107
148
|
return gateway.llm_gateway_generate_text_col(template, values, model_id=model_id)
|
|
108
149
|
|
|
109
150
|
|
|
@@ -180,7 +221,7 @@ def einstein_predict_col(
|
|
|
180
221
|
the JSON-serialized prediction payload; on failure, ``status ==
|
|
181
222
|
"ERROR"`` and the ``error_*`` fields carry diagnostic detail.
|
|
182
223
|
"""
|
|
183
|
-
predictions =
|
|
224
|
+
predictions = _active_client()._get_spark_einstein_predictions()
|
|
184
225
|
return predictions.einstein_predict_col(
|
|
185
226
|
model_api_name, prediction_type, features, settings=settings
|
|
186
227
|
)
|
|
@@ -258,26 +299,22 @@ class DataCloudAccessLayerException(Exception):
|
|
|
258
299
|
return msg
|
|
259
300
|
|
|
260
301
|
|
|
261
|
-
|
|
262
|
-
|
|
302
|
+
_ClientT = TypeVar("_ClientT", bound="_BaseClient")
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
class _BaseClient:
|
|
306
|
+
"""Shared machinery for the Data Cloud client singletons.
|
|
263
307
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
can read from DLOs and write to DLOs, read from DMOs and write to DMOs, but you
|
|
267
|
-
cannot read from DLOs and write to DMOs or read from DMOs and write to DLOs.
|
|
268
|
-
Furthermore you cannot mix during merging tables. This class is a singleton to
|
|
269
|
-
prevent accidental mixing of DLOs and DMOs.
|
|
308
|
+
Holds the wiring common to :class:`Client` (batch) and
|
|
309
|
+
:class:`StreamingClient`
|
|
270
310
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
behavior once deployed to Data Cloud. By default, the client intercepts all
|
|
274
|
-
read/write operations and mocks access to Data Cloud. For example, during
|
|
275
|
-
writing, we print to the console instead of writing to Data Cloud.
|
|
311
|
+
This base class is not meant to be instantiated directly; use
|
|
312
|
+
:class:`Client` or :class:`StreamingClient`.
|
|
276
313
|
|
|
277
314
|
Args:
|
|
278
|
-
finder: Find a file path
|
|
279
315
|
reader: A custom reader to use for reading Data Cloud objects.
|
|
280
316
|
writer: A custom writer to use for writing Data Cloud objects.
|
|
317
|
+
spark_provider: Optional custom :class:`BaseSparkSessionProvider`.
|
|
281
318
|
spark_llm_gateway: Optional custom :class:`SparkLLMGateway`.
|
|
282
319
|
spark_einstein_predictions: Optional custom
|
|
283
320
|
:class:`SparkEinsteinPredictions`.
|
|
@@ -291,7 +328,18 @@ class Client:
|
|
|
291
328
|
>>> answer = client.llm_gateway_generate_text("Generate a greeting message")
|
|
292
329
|
"""
|
|
293
330
|
|
|
294
|
-
_instance:
|
|
331
|
+
# Each concrete subclass gets its own ``_instance`` slot: reads fall through
|
|
332
|
+
# to this base default of ``None``, but ``cls._instance = ...`` in __new__
|
|
333
|
+
# always writes to the subclass, so ``Client`` and ``StreamingClient`` never
|
|
334
|
+
# share an instance.
|
|
335
|
+
_instance: ClassVar[Optional[_BaseClient]] = None
|
|
336
|
+
# Process-wide Spark session shared across BOTH client types. Unlike
|
|
337
|
+
# ``_instance``, this is written via ``_BaseClient._shared_spark`` (never
|
|
338
|
+
# ``cls._shared_spark``), so the slot lives on the base class and a
|
|
339
|
+
# ``Client`` and a ``StreamingClient`` in the same process reuse one session
|
|
340
|
+
# — and therefore one underlying connection — instead of opening two
|
|
341
|
+
# containing differing state
|
|
342
|
+
_shared_spark: ClassVar[Optional[SparkSession]] = None
|
|
295
343
|
_reader: BaseDataCloudReader
|
|
296
344
|
_writer: BaseDataCloudWriter
|
|
297
345
|
_file: DefaultFindFilePath
|
|
@@ -302,7 +350,7 @@ class Client:
|
|
|
302
350
|
_code_type: str
|
|
303
351
|
|
|
304
352
|
def __new__(
|
|
305
|
-
cls,
|
|
353
|
+
cls: type[_ClientT],
|
|
306
354
|
reader: Optional[BaseDataCloudReader] = None,
|
|
307
355
|
writer: Optional[BaseDataCloudWriter] = None,
|
|
308
356
|
spark_provider: Optional[BaseSparkSessionProvider] = None,
|
|
@@ -310,31 +358,38 @@ class Client:
|
|
|
310
358
|
spark_einstein_predictions: Optional[SparkEinsteinPredictions] = None,
|
|
311
359
|
spark_named_credential: Optional[SparkNamedCredential] = None,
|
|
312
360
|
code_type: str = "script",
|
|
313
|
-
) ->
|
|
361
|
+
) -> _ClientT:
|
|
314
362
|
|
|
315
363
|
if cls._instance is None:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
364
|
+
instance = super().__new__(cls)
|
|
365
|
+
instance._spark_llm_gateway = spark_llm_gateway
|
|
366
|
+
instance._spark_einstein_predictions = spark_einstein_predictions
|
|
367
|
+
instance._spark_named_credential = spark_named_credential
|
|
320
368
|
# Initialize Readers and Writers from config
|
|
321
369
|
# and/or provided reader and writer
|
|
322
370
|
if reader is None or writer is None:
|
|
323
|
-
# We need a spark because we will initialize readers and writers
|
|
324
|
-
if
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
provider: BaseSparkSessionProvider
|
|
330
|
-
if spark_provider is not None:
|
|
331
|
-
provider = spark_provider
|
|
332
|
-
elif config.spark_provider_config is not None:
|
|
333
|
-
provider = config.spark_provider_config.to_object()
|
|
371
|
+
# We need a spark because we will initialize readers and writers.
|
|
372
|
+
# Reuse the process-wide session if one client already built it,
|
|
373
|
+
# so a Client and a StreamingClient share a single connection.
|
|
374
|
+
if _BaseClient._shared_spark is not None:
|
|
375
|
+
spark = _BaseClient._shared_spark
|
|
334
376
|
else:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
377
|
+
if config.spark_config is None:
|
|
378
|
+
raise ValueError(
|
|
379
|
+
"Spark config is required when reader/writer is not "
|
|
380
|
+
"provided"
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
provider: BaseSparkSessionProvider
|
|
384
|
+
if spark_provider is not None:
|
|
385
|
+
provider = spark_provider
|
|
386
|
+
elif config.spark_provider_config is not None:
|
|
387
|
+
provider = config.spark_provider_config.to_object()
|
|
388
|
+
else:
|
|
389
|
+
provider = DefaultSparkSessionProvider()
|
|
390
|
+
|
|
391
|
+
spark = provider.get_session(config.spark_config)
|
|
392
|
+
_BaseClient._shared_spark = spark
|
|
338
393
|
|
|
339
394
|
if config.reader_config is None and reader is None:
|
|
340
395
|
raise ValueError(
|
|
@@ -357,66 +412,17 @@ class Client:
|
|
|
357
412
|
else:
|
|
358
413
|
writer_init = writer
|
|
359
414
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
415
|
+
instance._reader = reader_init
|
|
416
|
+
instance._writer = writer_init
|
|
417
|
+
instance._file = DefaultFindFilePath()
|
|
418
|
+
instance._data_layer_history = {
|
|
364
419
|
DataCloudObjectType.DLO: set(),
|
|
365
420
|
DataCloudObjectType.DMO: set(),
|
|
366
421
|
}
|
|
367
|
-
|
|
422
|
+
cls._instance = instance
|
|
423
|
+
elif reader is not None or writer is not None:
|
|
368
424
|
raise ValueError("Cannot set reader or writer after client is initialized")
|
|
369
|
-
return cls._instance
|
|
370
|
-
|
|
371
|
-
def read_dlo(self, name: str) -> PySparkDataFrame:
|
|
372
|
-
"""Read a DLO from Data Cloud.
|
|
373
|
-
|
|
374
|
-
Args:
|
|
375
|
-
name: The name of the DLO to read.
|
|
376
|
-
|
|
377
|
-
Returns:
|
|
378
|
-
A PySpark DataFrame containing the DLO data.
|
|
379
|
-
"""
|
|
380
|
-
self._record_dlo_access(name)
|
|
381
|
-
return self._reader.read_dlo(name) # type: ignore[no-any-return]
|
|
382
|
-
|
|
383
|
-
def read_dmo(self, name: str) -> PySparkDataFrame:
|
|
384
|
-
"""Read a DMO from Data Cloud.
|
|
385
|
-
|
|
386
|
-
Args:
|
|
387
|
-
name: The name of the DMO to read.
|
|
388
|
-
|
|
389
|
-
Returns:
|
|
390
|
-
A PySpark DataFrame containing the DMO data.
|
|
391
|
-
"""
|
|
392
|
-
self._record_dmo_access(name)
|
|
393
|
-
return self._reader.read_dmo(name) # type: ignore[no-any-return]
|
|
394
|
-
|
|
395
|
-
def write_to_dlo(
|
|
396
|
-
self, name: str, dataframe: PySparkDataFrame, write_mode: WriteMode, **kwargs
|
|
397
|
-
) -> None:
|
|
398
|
-
"""Write a PySpark DataFrame to a DLO in Data Cloud.
|
|
399
|
-
|
|
400
|
-
Args:
|
|
401
|
-
name: The name of the DLO to write to.
|
|
402
|
-
dataframe: The PySpark DataFrame to write.
|
|
403
|
-
write_mode: The write mode to use for writing to the DLO.
|
|
404
|
-
"""
|
|
405
|
-
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DMO)
|
|
406
|
-
return self._writer.write_to_dlo(name, dataframe, write_mode, **kwargs) # type: ignore[no-any-return]
|
|
407
|
-
|
|
408
|
-
def write_to_dmo(
|
|
409
|
-
self, name: str, dataframe: PySparkDataFrame, write_mode: WriteMode, **kwargs
|
|
410
|
-
) -> None:
|
|
411
|
-
"""Write a PySpark DataFrame to a DMO in Data Cloud.
|
|
412
|
-
|
|
413
|
-
Args:
|
|
414
|
-
name: The name of the DMO to write to.
|
|
415
|
-
dataframe: The PySpark DataFrame to write.
|
|
416
|
-
write_mode: The write mode to use for writing to the DMO.
|
|
417
|
-
"""
|
|
418
|
-
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DLO)
|
|
419
|
-
return self._writer.write_to_dmo(name, dataframe, write_mode, **kwargs) # type: ignore[no-any-return]
|
|
425
|
+
return cast(_ClientT, cls._instance)
|
|
420
426
|
|
|
421
427
|
def find_file_path(self, file_name: str) -> Path:
|
|
422
428
|
"""Resolve a bundled file shipped in the package to an absolute path.
|
|
@@ -579,3 +585,115 @@ class Client:
|
|
|
579
585
|
|
|
580
586
|
def _record_dmo_access(self, name: str) -> None:
|
|
581
587
|
self._data_layer_history[DataCloudObjectType.DMO].add(name)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
class Client(_BaseClient):
|
|
591
|
+
"""Entrypoint for batch access to Data Cloud objects.
|
|
592
|
+
|
|
593
|
+
This is the object used to read and write bounded snapshots of Data Cloud
|
|
594
|
+
DLOs and DMOs.
|
|
595
|
+
"""
|
|
596
|
+
|
|
597
|
+
_instance: ClassVar[Optional[Client]] = None
|
|
598
|
+
|
|
599
|
+
def read_dlo(self, name: str) -> PySparkDataFrame:
|
|
600
|
+
"""Read a DLO from Data Cloud.
|
|
601
|
+
|
|
602
|
+
Args:
|
|
603
|
+
name: The name of the DLO to read.
|
|
604
|
+
|
|
605
|
+
Returns:
|
|
606
|
+
A PySpark DataFrame containing the DLO data.
|
|
607
|
+
"""
|
|
608
|
+
self._record_dlo_access(name)
|
|
609
|
+
return self._reader.read_dlo(name) # type: ignore[no-any-return]
|
|
610
|
+
|
|
611
|
+
def read_dmo(self, name: str) -> PySparkDataFrame:
|
|
612
|
+
"""Read a DMO from Data Cloud.
|
|
613
|
+
|
|
614
|
+
Args:
|
|
615
|
+
name: The name of the DMO to read.
|
|
616
|
+
|
|
617
|
+
Returns:
|
|
618
|
+
A PySpark DataFrame containing the DMO data.
|
|
619
|
+
"""
|
|
620
|
+
self._record_dmo_access(name)
|
|
621
|
+
return self._reader.read_dmo(name) # type: ignore[no-any-return]
|
|
622
|
+
|
|
623
|
+
def write_to_dlo(
|
|
624
|
+
self, name: str, dataframe: PySparkDataFrame, write_mode: WriteMode, **kwargs
|
|
625
|
+
) -> None:
|
|
626
|
+
"""Write a PySpark DataFrame to a DLO in Data Cloud.
|
|
627
|
+
|
|
628
|
+
Args:
|
|
629
|
+
name: The name of the DLO to write to.
|
|
630
|
+
dataframe: The PySpark DataFrame to write.
|
|
631
|
+
write_mode: The write mode to use for writing to the DLO.
|
|
632
|
+
"""
|
|
633
|
+
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DMO)
|
|
634
|
+
return self._writer.write_to_dlo(name, dataframe, write_mode, **kwargs) # type: ignore[no-any-return]
|
|
635
|
+
|
|
636
|
+
def write_to_dmo(
|
|
637
|
+
self, name: str, dataframe: PySparkDataFrame, write_mode: WriteMode, **kwargs
|
|
638
|
+
) -> None:
|
|
639
|
+
"""Write a PySpark DataFrame to a DMO in Data Cloud.
|
|
640
|
+
|
|
641
|
+
Args:
|
|
642
|
+
name: The name of the DMO to write to.
|
|
643
|
+
dataframe: The PySpark DataFrame to write.
|
|
644
|
+
write_mode: The write mode to use for writing to the DMO.
|
|
645
|
+
"""
|
|
646
|
+
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DLO)
|
|
647
|
+
return self._writer.write_to_dmo(name, dataframe, write_mode, **kwargs) # type: ignore[no-any-return]
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
class StreamingClient(_BaseClient):
|
|
651
|
+
"""Entrypoint for streaming (``DELTA_SYNC``) access to Data Cloud objects.
|
|
652
|
+
|
|
653
|
+
This is the streaming counterpart to :class:`Client`. Instead of reading and
|
|
654
|
+
writing bounded snapshots, it reads a DLO/DMO change feed as a streaming
|
|
655
|
+
DataFrame and writes the transformed stream back via a ``StreamingQuery``.
|
|
656
|
+
"""
|
|
657
|
+
|
|
658
|
+
_instance: ClassVar[Optional[StreamingClient]] = None
|
|
659
|
+
|
|
660
|
+
def read_dlo_deltas(self) -> PySparkDataFrame:
|
|
661
|
+
"""Read the streaming change feed (deltas) for a DLO from Data Cloud.
|
|
662
|
+
|
|
663
|
+
For use in a streaming (``DELTA_SYNC``) BYOC transform. Returns a
|
|
664
|
+
streaming DataFrame whose rows carry the change-feed metadata columns
|
|
665
|
+
(``_record_type``, ``_commit_*``) alongside the source columns.
|
|
666
|
+
|
|
667
|
+
Returns:
|
|
668
|
+
A streaming PySpark DataFrame over the DLO change feed.
|
|
669
|
+
"""
|
|
670
|
+
self._record_dlo_access(_streaming_source_name())
|
|
671
|
+
return self._reader.read_dlo_deltas() # type: ignore[no-any-return]
|
|
672
|
+
|
|
673
|
+
def read_dmo_deltas(self) -> PySparkDataFrame:
|
|
674
|
+
"""Read the streaming change feed (deltas) for a DMO from Data Cloud.
|
|
675
|
+
|
|
676
|
+
Returns:
|
|
677
|
+
A streaming PySpark DataFrame over the DMO change feed.
|
|
678
|
+
"""
|
|
679
|
+
self._record_dmo_access(_streaming_source_name())
|
|
680
|
+
return self._reader.read_dmo_deltas() # type: ignore[no-any-return]
|
|
681
|
+
|
|
682
|
+
def write_dlo_deltas(
|
|
683
|
+
self, name: str, dataframe: PySparkDataFrame, **kwargs
|
|
684
|
+
) -> StreamingQuery:
|
|
685
|
+
"""Write a streaming DataFrame of deltas to a DLO in Data Cloud.
|
|
686
|
+
|
|
687
|
+
Starts a streaming query that writes each micro-batch to the
|
|
688
|
+
target DLO and returns the ``StreamingQuery`` handle; the caller
|
|
689
|
+
typically calls ``query.awaitTermination()``.
|
|
690
|
+
|
|
691
|
+
Args:
|
|
692
|
+
name: The name of the DLO to write to.
|
|
693
|
+
dataframe: The streaming PySpark DataFrame to write.
|
|
694
|
+
|
|
695
|
+
Returns:
|
|
696
|
+
The started ``StreamingQuery``.
|
|
697
|
+
"""
|
|
698
|
+
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DMO)
|
|
699
|
+
return self._writer.write_dlo_deltas(name, dataframe, **kwargs) # type: ignore[no-any-return]
|
|
@@ -89,6 +89,9 @@ class ClientConfig(BaseConfig):
|
|
|
89
89
|
spark_provider_config: Union[
|
|
90
90
|
SparkProviderConfig[BaseSparkSessionProvider], None
|
|
91
91
|
] = None
|
|
92
|
+
# Source object name for a streaming (DELTA_SYNC) transform, populated by
|
|
93
|
+
# ``run_entrypoint`` from config.json's ``streamingSource`` field
|
|
94
|
+
streaming_source: Union[str, None] = None
|
|
92
95
|
|
|
93
96
|
def update(self, other: ClientConfig) -> ClientConfig:
|
|
94
97
|
"""Merge this ClientConfig with another, respecting force flags.
|
|
@@ -116,6 +119,8 @@ class ClientConfig(BaseConfig):
|
|
|
116
119
|
self.spark_provider_config = merge(
|
|
117
120
|
self.spark_provider_config, other.spark_provider_config
|
|
118
121
|
)
|
|
122
|
+
if other.streaming_source is not None:
|
|
123
|
+
self.streaming_source = other.streaming_source
|
|
119
124
|
return self
|
|
120
125
|
|
|
121
126
|
|
|
@@ -38,6 +38,14 @@ USE_IN_FEATURE_MAPPING_FOR_CONNECT_API = {
|
|
|
38
38
|
"SearchIndexChunking": "UnstructuredChunking",
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
# Script (data transform) invoke options
|
|
42
|
+
SCRIPT_USE_IN_FEATURE_BATCH = "BatchTransform"
|
|
43
|
+
SCRIPT_USE_IN_FEATURE_STREAMING = "StreamingTransform"
|
|
44
|
+
SCRIPT_USE_IN_FEATURE_OPTIONS = [
|
|
45
|
+
SCRIPT_USE_IN_FEATURE_BATCH,
|
|
46
|
+
SCRIPT_USE_IN_FEATURE_STREAMING,
|
|
47
|
+
]
|
|
48
|
+
|
|
41
49
|
# Pydantic request/response type names to feature names
|
|
42
50
|
REQUEST_TYPE_TO_FEATURE = {
|
|
43
51
|
"SearchIndexChunkingV1Request": "SearchIndexChunking",
|