Skip to main content

Resolve Databricks config variables from literals, environment variables, and Azure Key Vault secrets, and substitute them into JSON config files.

Project description

brickvar

Resolve configuration variables for Databricks jobs from literals, environment variables, and Azure Key Vault secrets, and substitute them into JSON config files.

brickvar reads a JSON "variables" file in which each entry is one of:

  • a literal string (which may reference other variables with ${VAR}),
  • an environment variable reference — {"env": "NAME"}, or
  • a Databricks / Azure Key Vault secret{"scope": ..., "key": ..., "base"?: ...}, read through the Databricks dbutils.secrets API.

Resolution is two-pass, so a secret's scope/key can themselves reference already-resolved literal or environment values. It can also substitute ${VAR} placeholders into any JSON file, leaving unknown placeholders intact.

Install

pip install brickvar

Usage

from brickvar import configure_json

# Read a JSON file and substitute its ${VAR} placeholders from a variables file,
# in one call. dbutils is provided by the Databricks runtime and is required only
# when the variables file contains Key Vault secret entries.
spec = configure_json("spec.json", dbutils=dbutils, var_filepath="variables.json")

For finer-grained control, use the ConfigManager class directly:

from brickvar import ConfigManager

cfg = ConfigManager(dbutils=dbutils)

# Resolve a variables file to a dict.
variables = cfg.read_variables("variables.json")

# Read a JSON file and substitute its ${VAR} placeholders from a variables file.
spec = cfg.read_json("spec.json", "variables.json")

Example variables.json:

{
  "SECRET_SCOPE": { "env": "SECRET_SCOPE" },
  "HOST": "example.documents.azure.us",
  "CLIENT_ID": { "scope": "${SECRET_SCOPE}", "key": "SP-CLIENT-ID" },
  "STORAGE": { "scope": "kv", "key": "ACCOUNT", "base": "abfss://data@{}/curated" }
}
  • HOST is a literal.
  • SECRET_SCOPE comes from the SECRET_SCOPE environment variable.
  • CLIENT_ID is a secret whose scope is filled from the resolved SECRET_SCOPE.
  • STORAGE is a secret wrapped by its base format string.

Development

python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest

License

Apache-2.0

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

brickvar-0.0.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

brickvar-0.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file brickvar-0.0.2.tar.gz.

File metadata

  • Download URL: brickvar-0.0.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brickvar-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f0275e1476539f7f79ea13884f2490f774f52bbe13d2ec800ba7c9791ff747a0
MD5 40c94f75d87fcec2bd9bf2f229df57de
BLAKE2b-256 5626ec38c3bd3d8a190e964555d0ec0b5cc719998d8d8f1c69f586e3001ad68d

See more details on using hashes here.

Provenance

The following attestation bundles were made for brickvar-0.0.2.tar.gz:

Publisher: release.yml on amida-tech/brickvar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brickvar-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: brickvar-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brickvar-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f248516e53610469c8544fe4f3a7e9a029119fe42ebf53a04b9841a0f9d2ec8e
MD5 ee43ac4bbe7ab9d1a3c5e805a6ddc5f7
BLAKE2b-256 ae213c125ae76ad0f1112be8565aafe8b3523c1400d997a1acc5c4e65571df1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for brickvar-0.0.2-py3-none-any.whl:

Publisher: release.yml on amida-tech/brickvar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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