Skip to main content

Data Cloud Custom Code SDK

Project description

Data Cloud Custom Code SDK

license

This package provides a development kit for creating custom data transformations in Data Cloud. It allows you to write your own data processing logic in Python while leveraging Data Cloud's infrastructure for data access and running data transformations, mapping execution into Data Cloud data structures like Data Model Objects and Data Lake Objects.

More specifically, this codebase gives you ability to test code locally before pushing to Data Cloud's remote execution engine, greatly reducing how long it takes to develop.

Use of this project with Salesforce is subject to the TERMS OF USE

Installation

The SDK can be downloaded directly from PyPI with pip:

pip install salesforce-data-customcode

You can verify it was properly installed via CLI:

datacustomcode version

Development Setup

We offer two built-in development interfaces: devcontainers and Jupyter, but you can set up any tool you would like manually.

To get started, use the CLI to initialize a new development environment:

datacustomcode init [DIRECTORY TO DUMP NEW REPO]

This will yield all necessary files to get started:

.
├── Dockerfile
├── README.md
├── requirements.txt
├── requirements-dev.txt
├── payload
│   ├── config.json
│   ├── entrypoint.py
├── jupyterlab.sh
└── requirements.txt
  • Dockerfile (Do not update) – Development container emulating the remote execution environment.
  • requirements-dev.txt (Do not update) – These are the dependencies for the development environment.
  • jupyterlab.sh (Do not update) – Helper script for setting up Jupyter.
  • requirements.txt – Here you define the requirements that you will need remotely
  • payload – This folder will be compressed and deployed to the remote execution environment.
    • config.json – This config defines permissions on the back and can be generated programmatically with scan CLI method.
    • entrypoint.py – The script that defines the data transformation logic.

API

You entry point script will define logic using the Client object which wraps data access layers.

You should only need the following methods:

  • read_dlo(name) – Read from a Data Lake Object by name
  • read_dmo(name) – Read from a Data Model Object by name
  • write_to_dlo(name, spark_dataframe, write_mode) – Write to a Data Model Object by name with a Spark dataframe
  • write_to_dmo(name, spark_dataframe, write_mode) – Write to a Data Lake Object by name with a Spark dataframe

For example:

from datacustomcode import Client

client = Client()

sdf = client.read_dlo('my_DLO')
# some transformations
# ...
client.write_to_dlo('output_DLO')

[!WARNING] Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.

CLI

The Data Cloud Custom Code SDK provides a command-line interface (CLI) with the following commands:

Global Options

  • --debug: Enable debug-level logging

Commands

datacustomcode version

Display the current version of the package.

datacustomcode configure

Configure credentials for connecting to Data Cloud.

Options:

  • --profile TEXT: Credential profile name (default: "default")
  • --username TEXT: Salesforce username
  • --password TEXT: Salesforce password
  • --client-id TEXT: Connected App Client ID
  • --client-secret TEXT: Connected App Client Secret
  • --login-url TEXT: Salesforce login URL

datacustomcode deploy

Deploy a transformation job to Data Cloud.

Options:

  • --profile TEXT: Credential profile name (default: "default")
  • --path TEXT: Path to the code directory (default: ".")
  • --name TEXT: Name of the transformation job [required]
  • --version TEXT: Version of the transformation job (default: "0.0.1")
  • --description TEXT: Description of the transformation job (default: "")

datacustomcode init

Initialize a new development environment with a template.

Argument:

  • DIRECTORY: Directory to create project in (default: ".")

datacustomcode scan

Scan a Python file to generate a Data Cloud configuration.

Argument:

  • FILENAME: Python file to scan

Options:

  • --config TEXT: Path to save the configuration file (default: same directory as FILENAME)
  • --dry-run: Preview the configuration without saving to a file

datacustomcode run

Run an entrypoint file locally for testing.

Argument:

  • ENTRYPOINT: Path to entrypoint Python file

Options:

  • --config-file TEXT: Path to configuration file
  • --dependencies TEXT: Additional dependencies (can be specified multiple times)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

salesforce_data_customcode-0.1.4.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salesforce_data_customcode-0.1.4-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file salesforce_data_customcode-0.1.4.tar.gz.

File metadata

  • Download URL: salesforce_data_customcode-0.1.4.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1012-azure

File hashes

Hashes for salesforce_data_customcode-0.1.4.tar.gz
Algorithm Hash digest
SHA256 46de427b4d1d9b47a14b517e45babcf922bbe4c79ad8595509a2142a48eb99b4
MD5 adeb3d8410c7f4dcf2a223e667f0d68e
BLAKE2b-256 a68306d36c71d993185e2ba3929da2532bfcbfbe53696c9554a21adbc087f9d5

See more details on using hashes here.

File details

Details for the file salesforce_data_customcode-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for salesforce_data_customcode-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c4f2774c03c610dd932551186f57e959a88e06cd8a0528e843c012258680bc09
MD5 7d171cacb049071c1de85c887433b54a
BLAKE2b-256 dc5f4a05728f4e6d672415a503662037ca7c0adbc14d43814547da4530c3364b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page