Skip to main content

Zipher SDK

The Zipher SDK is a Python library for interacting with Zipher's APIs.

Package Installation

You can install the Zipher SDK using pip:

pip install zipher-sdk

Supported environments

  • Python 3.9+, databricks-sdk 0.30+, requests 2.31+ and pydantic 2.4+.
  • Installs alongside the packages preinstalled in Databricks Runtime 16.4 LTS and newer and serverless environment 3 and newer, without upgrading any of them. On older runtimes pip upgrades databricks-sdk (and its protobuf).
  • Compatible with the official Airflow constraints files from Airflow 2.7.2 onward. CI checks this (.github/workflows/airflow-compat.yml).

Security note

We recommend certifi>=2026.10.19 in the environment you run the SDK in. Older certifi versions trust emSign intermediate certificates whose keys were compromised (eMudhra CA compromise, GHSA-6q48-6c7w-9gw2). On Databricks, run this in a notebook:

%pip install -U certifi

zipher-sdk does not require it, because that would make the package impossible to install with the official Airflow constraints files, which pin older certifi versions.

Upgrading to 0.6.0

Breaking change: zipher remove now asks for confirmation. It lists the Zipher group, service principal, secrets scope and workspace directory it found, and deletes them only after you answer y.

  • Scripts and CI: zipher remove now waits for an answer. Without one (no terminal input), it deletes nothing: it prints Unexpected error: EOF when reading a line and exits with status 0. Add --skip-approval to keep today's behaviour: zipher remove --skip-approval.
  • Python: ZipherInstaller.clean_resources() still deletes without asking by default (skip_approval=True). This default may change in a future release; pass skip_approval=False to get the list and the prompt.

Also in 0.6.0, zipher setup no longer overwrites resources you already have:

  • With --existing-sp-id, your service principal is only added to the Zipher group. Its entitlements and roles are kept (before, they were wiped).
  • If the workspace directory (/zipher_script) already exists, Zipher's permissions are added to it instead of replacing the ones you set.

Providing Zipher with access to Databricks workspace

After installing zipher-sdk package a cli tool to automatically create all necessary resources for Zipher is available.

Setting up credentials

You need to provide credentials that will be used to create all necessary resources and permissions for Zipher.

Here are ways to set up credentials:

  • .databrickscfg config (cli tool supports profile choice as an argument)
  • ZIPHER_DATABRICKS_HOST and ZIPHER_DATABRICKS_TOKEN or ZIPHER_DATABRICKS_CLIENT_ID, ZIPHER_DATABRICKS_CLIENT_SECRET environment variables
  • providing credentials as arguments to cli tool

Cli tool usage examples

Providing Zipher with access to a list of jobs

zipher setup --jobs-list 12345678,87654321,12344321,21436587

Providing Zipher with access to n jobs from the workspace

zipher setup --max-jobs 50

Providing Zipher with readonly access to a list of jobs

zipher setup --readonly --jobs-list 12345678,87654321,12344321,21436587

Removing the Zipher resources from the workspace

zipher remove

zipher remove lists the Zipher group, service principal, secrets scope and workspace directory that it will delete and asks for confirmation (since 0.6.0). Use --skip-approval to skip the confirmation, for example in scripts.

Full cli tool specification

usage: zipher setup [-h] [--workspace-host WORKSPACE_HOST] [--access-token ACCESS_TOKEN] [--client-id CLIENT_ID] [--client-secret CLIENT_SECRET] [--profile PROFILE] [--verbose] [--jobs-list JOBS_LIST] [--max-jobs MAX_JOBS] [--max-runs MAX_RUNS]
                    [--days-back DAYS_BACK] [--readonly] [--pat] [--skip-approval] [--existing-sp-id EXISTING_SP_ID]

options:
  -h, --help            show this help message and exit
  --workspace-host WORKSPACE_HOST
                        Databricks workspace host URL.
  --access-token ACCESS_TOKEN
                        Databricks workspace access token.
  --client-id CLIENT_ID
                        Databricks workspace OAuth client id.
  --client-secret CLIENT_SECRET
                        Databricks workspace OAuth client secret.
  --profile PROFILE     Profile name from .databrickscfg.
  --verbose             Print full error message on fail.
  --jobs-list JOBS_LIST
                        Comma-separated list of jobs ids to provide access to.
  --max-jobs MAX_JOBS   Maximum number of jobs to consider when iterating over jobs to grant permissions (default: 2000).
  --max-runs MAX_RUNS   Maximum number of runs to consider when iterating over runs to grant permissions to relative jobs (default: 2000).
  --days-back DAYS_BACK
                        How many days back to fetch relevant job runs for permission updates (default: 7).
  --readonly            Provide Zipher with only CAN_VIEW permissions on listed jobs. When not provided will default to CAN_MANAGE permissions.
  --pat                 Generate Personal Access Token for Zipher instead of default OAuth client creds.
  --skip-approval       Skip user input approval.
  --existing-sp-id EXISTING_SP_ID
                        Use existing service principal by Application ID (UUID) instead of creating a new one.

usage: zipher remove [-h] [--workspace-host WORKSPACE_HOST] [--access-token ACCESS_TOKEN] [--client-id CLIENT_ID] [--client-secret CLIENT_SECRET] [--profile PROFILE] [--verbose] [--skip-approval]

options:
  -h, --help            show this help message and exit
  --workspace-host WORKSPACE_HOST
                        Databricks workspace host URL.
  --access-token ACCESS_TOKEN
                        Databricks workspace access token.
  --client-id CLIENT_ID
                        Databricks workspace OAuth client id.
  --client-secret CLIENT_SECRET
                        Databricks workspace OAuth client secret.
  --profile PROFILE     Profile name from .databrickscfg.
  --verbose             Print full error message on fail.
  --skip-approval       Skip user input approval.

SDK Usage

Here are some basic examples of how you can use the Zipher SDK to optimize your databricks clusters using Zipher's ML-powered optimization engine:

Update Existing Configuration

You can update an existing configuration by initializing a zipher Client and sending a JSON payload to the update_existing_conf function. Here's how you can do it:

from zipher import Client

# Assuming the zipher API key is stored in the ZIPHER_API_KEY environment variable
client = Client(customer_id="my_customer_id")

# Your existing cluster config:
config_payload = {
    "new_cluster": {
        "autoscale": {"min_workers": 1, "max_workers": 30},
        "cluster_name": "my-cluster",
        "spark_version": "10.4.x-scala2.12",
        "spark_conf": {"spark.driver.maxResultSize": "4g"},
        "aws_attributes": {
            "first_on_demand": 0,
            "availability": "SPOT",
            "zone_id": "auto",
            "spot_bid_price_percent": 100,
            "ebs_volume_count": 0,
        },
        "node_type_id": "rd-fleet.2xlarge",
        "driver_node_type_id": "rd-fleet.xlarge",
        "spark_env_vars": {},
        "enable_elastic_disk": "false",
    }
}

# Update configuration
optimized_cluster = client.update_existing_conf(job_id="my-job-id", existing_conf=config_payload)

# Continue with sending the optimized configuration to Databricks via the Databricks python SDK, Airflow operator, etc.

Optional: passing per-run parameters

You can specify run-level parameters that Zipher will take into consideration. This is useful for parametrized jobs, where Zipher can explicitly learn the different usage patterns of different parametes.

optimized_cluster = client.update_existing_conf(
    job_id="my-job-id",
    existing_conf=config_payload,
    run_params={"customer_ids": ["c1", "c2"], "lookback_days": "30"},
)

Update Existing Multiple Tasks Configuration

You can update multiple databricks tasks by initializing a zipher Client and sending a JSON representing a list of dbx SubmitTask objects to the get_optimized_tasks function.

from zipher import Client

# Assuming the zipher API key is stored in the ZIPHER_API_KEY environment variable
client = Client(customer_id="my_customer_id")

tasks_to_optimize = [
    {
        "task_key": "task_1",
        "description": "Test notebook task",
        "notebook_task": {
            "notebook_path": "/path/to/your/notebook",
            "base_parameters": {"param1": "value1"},
        },
        "new_cluster": {
            "spark_version": "14.3.x-scala2.12",
            "node_type_id": "m6id.large",
            "driver_node_type_id": "m6id.large",
            "num_workers": 2,
            "aws_attributes": {
                "first_on_demand": 0,
                "availability": "SPOT",
                "zone_id": "auto",
                "spot_bid_price_percent": 100,
                "ebs_volume_count": 0,
            },
            "spark_conf": {"spark.driver.maxResultSize": "4g"},
        },
    },
    {
        "task_key": "task_2",
        "description": "Test Python task",
        "spark_python_task": {
            "python_file": "/path/to/your/python_file.py",
        },
        "new_cluster": {
            "spark_version": "14.3.x-scala2.12",
            "node_type_id": "m6id.large",
            "driver_node_type_id": "m6id.large",
            "num_workers": 2,
            "spark_conf": {"spark.driver.maxResultSize": "4g"},
        },
        "timeout_seconds": 3600,
        "depends_on": [{"task_key": "task_1"}],
    },
]

# Update tasks
optimized_tasks = client.get_optimized_tasks(job_id="my-job-id", tasks=tasks_to_optimize)

# Continue with sending the optimized tasks to Databricks via the Databricks python SDK, Airflow operator, etc.

Limits

  • Timeout: each call to Zipher's API gives up after 5 seconds without connecting, or 30 seconds without receiving data. update_existing_conf then falls back to returning your original config; the other methods raise requests.exceptions.Timeout.
  • Request size: the config, run params and tasks are sent URL-encoded in the query string of a GET request. Zipher's proxies accept URLs of about 8 KB at most, counted after URL-encoding (which makes JSON noticeably larger, e.g. every " becomes %22). A larger request is rejected with HTTP 414, with the same semantics as above: update_existing_conf returns your original config, the other methods raise. For very large configs or many tasks, prefer per-task calls.
  • Secrets: don't put plain-text secrets in the config (for example in spark_env_vars). Use Databricks secret references such as {{secrets/<scope>/<key>}} instead, because request URLs can appear in access logs.

Telemetry

Every request the SDK sends to Zipher's APIs carries your API key and two headers:

  • User-Agent: zipher-sdk/<version> identifies the SDK. It is always sent and is not part of the opt-out telemetry below.
  • X-Zipher-Client-Info is the opt-out telemetry: a compact JSON object describing the environment the SDK runs in, for example {"airflow":"2.10.1","arch":"x86_64","databricks_sdk":"0.102.0","os":"linux","pydantic":"2.9.0","python":"3.11.4","python_impl":"CPython","requests":"2.32.3","sdk":"0.4.7"}. We collect it to know which Python, Airflow and databricks-sdk versions our customers run, so we know what to support.

You can stop the SDK from sending X-Zipher-Client-Info (and from collecting it) by passing send_client_info=False in the client config:

from zipher import Client, Config

client = Client(customer_id="...", config=Config(send_client_info=False))

or by setting DO_NOT_TRACK=1 (true and yes also work) in the environment.

Fields of X-Zipher-Client-Info (a field is left out when it does not apply, e.g. Airflow is not installed, and set to "error" when it applies but could not be read):

Field Contents
sdk Version of zipher-sdk (unknown when running from a source checkout)
python Python version, e.g. 3.11.4
python_impl Python implementation, e.g. CPython
os Operating system name, e.g. linux, darwin, windows
arch CPU architecture, e.g. x86_64, arm64
databricks_sdk Installed databricks-sdk version
requests Installed requests version
pydantic Installed pydantic version
airflow Installed apache-airflow version, when Airflow is installed
dbr Databricks Runtime version (the DATABRICKS_RUNTIME_VERSION environment variable), when running on Databricks

Package versions are read from the installed package metadata; the packages themselves are not imported. No hostnames, usernames, workspace IDs, job contents or credentials are sent. Values are limited to 64 ASCII characters.

Metadata

Release files for zipher-sdk 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zipher-sdk 0.6.0
File Size Uploaded Provenance Actions
zipher_sdk-0.6.0.tar.gz 28.1 kB With provenance Details for zipher_sdk-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zipher-sdk 0.6.0
File Interpreter ABI Platform Actions
zipher_sdk-0.6.0-py3-none-any.whl Python 3 none any Details for zipher_sdk-0.6.0-py3-none-any.whl

Total release size: 53.6 kB

Release files / zipher_sdk-0.6.0.tar.gz

Download URL zipher_sdk-0.6.0.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d28b0fa60fd279b9af5f633428c8b8416714a879114c1fb4299c5db2e82a90c
BLAKE2b-256 checksum
How to use checksums
90af4cc35125a8cad6a0d13110dd43cc07bdf4affa5d3ace0e20145ab07ed89e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / zipher_sdk-0.6.0-py3-none-any.whl

Download URL zipher_sdk-0.6.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
241ecf5b5545a6e9c9a32c57ecdd443a27300e815e46091b3673202401e36038
BLAKE2b-256 checksum
How to use checksums
633c95899e82b2c4f10a42a234efb7204740aee2bd64ad9ed7fec09b3df911a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for zipher-sdk 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zipher_sdk-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page