Skip to main content

pydabs-genie-agent-retarget

Rewrite Unity Catalog references in Genie Agent (formerly Genie space) definitions when you deploy them with Declarative Automation Bundles (DABs).

A serialized Genie space hardcodes catalog.schema.table names in table identifiers, join specs, SQL snippets, example and benchmark SQL, and text instructions. genie_agent_retarget is a Python mutator for DABs that rewrites all of them per target with prefix rules:

Rule level Example
table main.intel.oss_iocs: ${var.catalog}.intel.iocs
schema main.gold: ${var.catalog}.${var.gold_schema}
catalog main: ${var.catalog}

The most specific rule wins, and each name is rewritten once (rules never chain). Matching is case-insensitive and handles backtick-quoted names, in the space and in the rules. A rule whose two sides have a different number of parts fails databricks bundle validate.

After a rewrite, the mutator sorts data_sources.tables by identifier, because the Genie API rejects an unsorted list. If a table rule renames a table, the mutator also renames the short table qualifiers in SQL fields: join specs, SQL snippets (filters, measures, expressions), example SQL, and benchmark SQL (oss_iocs.ioc_type = 'URL' becomes iocs.ioc_type = 'URL'). It skips a short name that another table of the space also has, because it is ambiguous.

Usage

  1. Add the package to the bundle's virtual environment (with uv):

    [dependency-groups]
    dev = [
        "databricks-bundles==1.19.0",
        "pydabs-genie-agent-retarget @ git+https://github.com/alexott/pydabs-genie-agent-retarget",
    ]
    

    Or copy src/genie_agent_retarget.py next to databricks.yml. It has no dependencies except databricks-bundles.

  2. Register the mutator and define the genie_table_mapping variable in databricks.yml:

    python:
      venv_path: .venv
      mutators:
        - 'genie_agent_retarget:retarget_genie_spaces'
    
    variables:
      genie_table_mapping:
        type: complex
        default:
          main.gold: ${var.catalog}.${var.gold_schema}
    
  3. Keep each space as src/<name>.geniespace.json (the output of databricks bundle generate genie-space) and reference it with file_path.

Use genie_table_mapping: {} in a target that needs no rewriting.

Command line

The same code works on a single file. This is useful when you export a space from an environment that is not the authoring one, and must convert it back to the authoring names:

python -m genie_agent_retarget src/x.geniespace.json --in-place \
  -m dev_catalog.gold_dev=main.gold

Example

example/ deploys 3 Genie spaces (CVE analysis, IoC analysis, and Lakewatch security operations over 22 OCSF gold tables). Each data source location is a variable (ocsf_schema, cve_schema, iocs_table):

  • dev moves the spaces to other schemas and renames one table.
  • azure deploys them to another workspace, where the data is in other catalogs and schemas.
  • prod keeps the names, so the files are deployed without changes.
cd example
uv sync
databricks bundle validate -t dev
databricks bundle deploy -t dev

The example uses names from our environments: the CLI profiles (lw-field, az-alexott), the catalogs and schemas of each target, and the warehouse name. The JSON files keep the names they were authored against (fe_lakewatch_catalog...), because the rules map from these names. To try the example in your workspace, change workspace.profile, warehouse_name, and the ocsf_schema, cve_schema, and iocs_table variables of a target to your tables. The tables must have the same columns, otherwise the instructions and example SQL of the spaces do not match the data.

The Genie API checks that all tables exist when it creates or updates a space, so the tables must exist before you deploy.

If the DATABRICKS_CONFIG_PROFILE environment variable is set, the CLI uses that profile instead of the target's workspace.profile. Unset it when you deploy targets that use different workspaces.

Tests

uv sync && uv run pytest

License

This project is licensed under the Databricks License.

Metadata

Release files for pydabs-genie-agent-retarget 0.1.1

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

Source distribution (sdist)

Source distribution for pydabs-genie-agent-retarget 0.1.1
File Size Uploaded
pydabs_genie_agent_retarget-0.1.1.tar.gz 42.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydabs-genie-agent-retarget 0.1.1
File Interpreter ABI Platform
pydabs_genie_agent_retarget-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 53.6 kB

Release files / pydabs_genie_agent_retarget-0.1.1.tar.gz

Download URL pydabs_genie_agent_retarget-0.1.1.tar.gz
Size 42.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2d1a7c65eca3069603c93aee52e39daa9043b0eb6173beceedc59997f63a5851
BLAKE2b-256 checksum
How to use checksums
d60136b7f55bbe75aec33a5047c421d5269852134e1dcb84c23874f2de4ce3db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 17, 2026.

Transparency log

Release files / pydabs_genie_agent_retarget-0.1.1-py3-none-any.whl

Download URL pydabs_genie_agent_retarget-0.1.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54ee2032539feb4dcd86e53a09c48dd9a6dbac1bff0f7a444a84d9d007ec56fe
BLAKE2b-256 checksum
How to use checksums
36e74c6d5970669d7927308efdf9f2dc78664d3694c4c182d1ccbef5123bad70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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