Skip to content

Show blueprint source path in blueprint list - #64

Merged
jeremybeard merged 4 commits into
mainfrom
cli-list-location
Jun 22, 2026
Merged

Show blueprint source path in blueprint list#64
jeremybeard merged 4 commits into
mainfrom
cli-list-location

Conversation

@jeremybeard

@jeremybeard jeremybeard commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a Location column to blueprint list so users can immediately see which file each blueprint is defined in.

  • When --template-dir DIR is provided, the path is rendered relative to DIR.
  • Otherwise it is rendered relative to the current working directory.

This addresses feedback that it was unclear where a given blueprint actually lives — the registry already tracked locations, but blueprint list never surfaced them.

Example

$ blueprint list --template-dir examples/advanced/dags/

                              Available Blueprints
┏━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Name     ┃ Versions ┃ Description                   ┃ Class    ┃ Location       ┃
┡━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ analyze  │ 1        │ Run signal analysis ...       │ Analyze  │ blueprints.py  │
│ orbit    │ 1        │ Calculate and execute ...     │ Orbit    │ blueprints.py  │
│ scan     │ 1, 2     │ Multi-band scan with ...      │ ScanV2   │ blueprints.py  │
│ transmit │ 1        │ Transmit data to a ...        │ Transmit │ blueprints.py  │
└──────────┴──────────┴───────────────────────────────┴──────────┴────────────────┘

Here the locations are shown relative to the supplied --template-dir (so blueprints.py rather than examples/advanced/dags/blueprints.py). The shown path is the location of the latest version (matching the Class column).

How

  • The registry previously stored locations relative to an internal base directory, which is not meaningful when shown at the CLI. It now stores the resolved absolute path.
  • New blueprint/utils.py::display_path(path, base=None) renders a path relative to base (defaulting to the cwd), falling back to the absolute path when the file is not under base (e.g. a sibling tree, or a different drive on Windows). The list command passes the resolved --template-dir as base when one is given.
  • DuplicateBlueprintError / MultipleDagArgsError render their messages lazily in __str__, so locations are resolved relative to the cwd at display time rather than baked in when the error is raised. They pass their raw args to super().__init__() so repr() stays informative and the exceptions remain picklable.

Tests

  • tests/test_utils.py::TestDisplayPathdisplay_path under/outside the base, and the explicit-base override.
  • tests/test_registry.py::TestBlueprintLocationslist_blueprints() reports absolute locations.
  • tests/test_cli.py::test_list_location_is_relative_to_template_dir — the Location column renders relative to --template-dir.

All unit tests, ruff, and ty pass.

Add a Location column to `blueprint list` so users can see which file
each blueprint is defined in, rendered relative to the current working
directory.

The registry already tracked locations but stored them relative to an
internal base dir, which is not meaningful at the CLI. Store the resolved
absolute path instead and add `display_path()` to render paths relative
to cwd (falling back to absolute when outside the tree). Duplicate/multiple
DAG-args error messages now use the same cwd-relative rendering.
- Move display_path to a neutral blueprint/utils.py so the registry no
  longer owns a display concern and errors.py can reuse it without a cycle.
- Render DuplicateBlueprintError / MultipleDagArgsError lazily in __str__,
  so locations are resolved relative to cwd at display time rather than at
  raise time (avoids stale hints if cwd changes between discovery and print).
- Capture cwd once in 'blueprint list' and pass it as display_path(base=...).
- Make the CLI location assertion OS-separator agnostic.
- Add a docstring to _register_dag_args; split display_path tests into
  tests/test_utils.py and keep the absolute-location test in test_registry.
@astronomer astronomer deleted a comment from github-actions Bot Jun 22, 2026
- tests/test_utils.py: build expected paths via Path() instead of POSIX
  literals, and ground the under-cwd test on a real file.
- errors.py: pass raw constructor args to super().__init__ so repr() stays
  informative and the exceptions pickle correctly (round-trips reconstruct
  via __init__); __str__ still renders cwd-relative paths lazily.
- utils.display_path: return falsy input unchanged instead of '.'.
- MultipleDagArgsError: skip empty locations rather than rendering an empty
  bullet.
@astronomer astronomer deleted a comment from github-actions Bot Jun 22, 2026
@astronomer astronomer deleted a comment from github-actions Bot Jun 22, 2026
When 'blueprint list --template-dir DIR' is given, render each blueprint's
Location relative to DIR (so paths read as 'blueprints.py' or 'etl/bp.py'
rather than the full path from cwd). Falls back to cwd-relative when no
template dir is supplied.
@astronomer astronomer deleted a comment from github-actions Bot Jun 22, 2026
@jeremybeard
jeremybeard marked this pull request as ready for review June 22, 2026 18:04
@jeremybeard
jeremybeard merged commit 81a53a7 into main Jun 22, 2026
14 checks passed
@jeremybeard
jeremybeard deleted the cli-list-location branch June 22, 2026 18:04
@jlaneve jlaneve mentioned this pull request Jul 20, 2026
jlaneve added a commit that referenced this pull request Jul 20, 2026
New since v0.3.0: .airflowignore support for DAG YAML discovery and
blueprint lint (#67), build_all_airflow_dags rename for safe-mode
discovery (#65), source paths in blueprint list (#64), and -h/-v
shorthands (#63).


Claude-Session: https://claude.ai/code/session_01J44AEQ8KTvUWxf6GnVRW66

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant