Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ds-common-placeholder-py-lib

Docs

The Python implementation of the standard placeholder dialect: parse, validate, resolve, and scrub @{…} placeholders in computing-block definitions.

The behaviour is defined by the placeholder contract (§ below). The calling service supplies the namespace values as plain JSON; the package reads secrets from ds-vault itself. Nothing resolved outlives the run: each run of a computing block builds its own context, and the vault client keeps no secret material between reads.

Documentation: https://grasp-labs.github.io/ds-common-placeholder-py-lib/, published on each release (source in docs/source/, build locally with make docs).

Install

uv add ds-common-placeholder-py-lib

Python 3.12+. Dependencies: ds-vault-py-sdk (secrets) and tzdata, so IANA time zones work on images without system zone data.

Use

The package knows the standard dialect, not the computing blocks. A service passes the namespace values it has as plain JSON; a namespace it does not pass does not exist.

from ds_common_placeholder_py_lib import Context, PlaceholderError, validate

# 1. Static check of the whole definition: syntax and dialect.
errors = validate(definition)

# 2. One context per run; ctx.set(name, value) adds to it as the run goes.
ctx = Context.from_values({
    "tenant_id": tenant_id,  # required
    "run": run, "owner": owner,
})
ctx.set("variables", ctx.resolve(declared_variables))  # resolved once, at the start
ctx.set("execution", execution)

# 3. Resolve each part right before using it.
try:
    settings = ctx.resolve(dataset_settings)
    sql = ctx.resolve_sql(sql_query)
except PlaceholderError as err:
    fail_execution(code=err.code, message=str(err))  # the message holds no values

# 4. Scrub anything that leaves the process.
log.error(ctx.scrub(str(some_exception)))

get_secret reads ds-vault through ds-vault-py-sdk, configured like the dispatchers: VAULT_DATABASE_URL and AWS credentials for KMS. In tests, ds_common_placeholder_py_lib.testing.fake_vault stands in for it.

A worker that cannot reach the vault gets its secrets from its dispatcher, through ctx.resolve_secrets(job) (details).

Examples

examples/ in the repository has one script per computing block. Each opens with a real (or, for the workflow, a realistic) definition and shows, as service code, which namespaces that block supplies:

Script Block Shows
01_pipeline.py Owner-input pipeline, many owners per run The stage-request mapping (§9.1), one bronze context per stage, the owner set per owner, bronze secrets, silver SQL in DuckDB
02_workflow.py Workflow Dispatcher to workflow manager: resolve_secrets, verbatim Python code, DataFrame task outputs read by path and by table functions
03_clone.py Clone The clone dispatcher resolves the secrets as plain text for ds-clone-service, tenant scope

Rules

Topic Rule
Whole vs embedded "@{x}" keeps the JSON type; "a-@{x}" renders text. Objects and arrays can't be embedded.
Missing null, "", blank, or no such path → missing_value. A default only with @{coalesce, …}.
@{ as text @{'@{'} → @{; escape(text) writes any string so. Resolved values are never scanned again.
Secrets The key's tenant segment must be the context's tenant. Secrets never go into SQL.
Protected No placeholders in id, name, type, version (the default list) outside settings.
SQL Values become SQL literals; placeholders inside quotes or comments are rejected.

The full rules, every function, and the error codes are in the documentation. Moving from the legacy dialect: migration notes.

Conformance vectors

src/ds_common_placeholder_py_lib/vectors/*.json ship with the package and are the conformance suite for every implementation (format in vectors/README.md). Any bug fix adds a vector first.

Development

uv sync --all-extras --dev
make lint type-check test-cov

Metadata

Release files for ds-common-placeholder-py-lib 0.1.0a8

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

Source distribution (sdist)

Source distribution for ds-common-placeholder-py-lib 0.1.0a8
File Size Uploaded Provenance Actions
ds_common_placeholder_py_lib-0.1.0a8.tar.gz 75.0 kB Without provenance Details for ds_common_placeholder_py_lib-0.1.0a8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ds-common-placeholder-py-lib 0.1.0a8
File Interpreter ABI Platform Actions
ds_common_placeholder_py_lib-0.1.0a8-py3-none-any.whl Python 3 none any Details for ds_common_placeholder_py_lib-0.1.0a8-py3-none-any.whl

Total release size: 140.8 kB

Release files / ds_common_placeholder_py_lib-0.1.0a8.tar.gz

Download URL ds_common_placeholder_py_lib-0.1.0a8.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0cef559f2fbd4c910f4cee2398ddfe56d7449dc8aa583ce971d8a73d0e5a93ad
BLAKE2b-256 checksum
How to use checksums
c94e05c804f091453c3f79d9f74a8705825454b740f5359304f856ab6e825b63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ds_common_placeholder_py_lib-0.1.0a8-py3-none-any.whl

Download URL ds_common_placeholder_py_lib-0.1.0a8-py3-none-any.whl
Size 65.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6eed0679ff9ab082cdb40352b8a95b0ee2d6e647c18bcfc73a54a0dfa2e7907a
BLAKE2b-256 checksum
How to use checksums
1827ae27ee13987d02812f3a9f731d0248d1fb81247bd6ca23333a1761b023f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ds-common-placeholder-py-lib 0.1.0a8

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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