Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
recursive-include md_processing/data *.json *.py
recursive-include md_processing/md_commands *.py
recursive-include md_processing/md_processing_utils/tests *.csv *.md *.txt
recursive-include tests *.py *.ini *.ipynb *.md *.txt
recursive-include tests *.py *.ini *.ipynb *.md *.txt
recursive-include pyegeria/view/schemas *.json
recursive-include pyegeria/view/seed *.json
6 changes: 6 additions & 0 deletions commands/tech/refresh_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
1. Markdown command templates generation (generate_md_cmd_templates)
2. Dr. Egeria help documentation generation (generate_dr_help)
3. Report FormatSet specifications generation (gen_report_specs)
4. The report-spec seed (python -m pyegeria.view.seed build), which the builtin tier loads

Usage:
uv run python refresh_specs.py [options]
Expand Down Expand Up @@ -99,6 +100,11 @@ def main():

run_command(cmd_reports, "Report Specifications Generation")

# 3b. Rebuild the report-spec seed (RS-EGERIA-TIER stage 2): the builtin tier loads from the packaged
# JSON in pyegeria/view/seed, generated from the Python constants. A fresh process, so it reads the
# generated section just written. Until stage 4 the constants stay the source.
run_command([python_exec, "-m", "pyegeria.view.seed", "build"], "Report Spec Seed Build")

# 4. Resolve every report spec (RS-W2-2 PR-B, note §2c) and say which cannot run, and why.
# Imported here, after the generation subprocess, so the freshly written specs are the ones read.
from pyegeria.view.spec_resolver import log_resolution_summary
Expand Down
43 changes: 33 additions & 10 deletions docs/output-formats-and-report-specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,37 @@ You can add report specs without changing pyegeria’s source. List them in conf

### Where pyegeria looks for user specs

Every report-spec lookup (`select_report_spec`, `get_report_spec_match`, `list_report_specs`, `hey_egeria`, Dr.Egeria, Egeria Explorer) goes through `get_report_registry()` in `pyegeria/view/base_report_formats.py`. It merges four tiers:
Every report-spec lookup (`select_report_spec`, `get_report_spec_match`, `list_report_specs`, `hey_egeria`, Dr.Egeria, Egeria Explorer) goes through `get_report_registry()` in `pyegeria/view/base_report_formats.py`. It merges three tiers, and
**a label held by a higher tier shadows the lower one: local > egeria > builtin** (6.2.29):

| Tier | Source |
|---|---|
| `BUILTINS` | `base_report_specs`, hand-maintained in `base_report_formats.py` |
| `GENERATED` | `generated_format_sets`, written by `refresh_specs` |
| `CONFIG` | Installed packages' entry points and your JSON files (below) |
| `RUNTIME` | Anything registered in code with `register_report_specs(...)`; survives `refresh_report_specs()` |
| `builtin` | **The seed** (6.2.29): pyegeria's shipped specs as packaged JSON in `pyegeria/view/seed/`, one file per family plus `manifest.json`. It holds the hand-maintained built-ins (`base_report_specs`), the generated Dr.Egeria specs (`generated_format_sets`, written by `refresh_specs`), the analytic demo specs and the question specs. The seed is generated from those Python constants by `python -m pyegeria.view.seed build` (which `refresh_specs` runs); `... seed check` fails when it is stale. Never edit it by hand. |
| `egeria` | Report specs held in Egeria, synced into a local cache (RS-EGERIA-TIER) |
| local: `CONFIG` | Installed packages' entry points and your JSON files (below) |
| local: `RUNTIME` | Anything registered in code with `register_report_specs(...)`; survives `refresh_report_specs()` |

**Overriding a built-in (6.2.29).** A local spec (a user-directory file, an entry point, or a runtime
registration) with a built-in's or an Egeria-held spec's label **wins**, with one warning per label per process:

```
Report spec 'Questions': the local copy shadows the builtin copy (they are the same); the builtin copy stays addressable as 'builtin:Questions'.
```

`builtin:<label>` (or `seed:<label>`) and `egeria:<label>` still reach the shadowed copy, and
`list_report_specs(with_status=True)` lists it under that address with `shadowed_by`. An alias of a local spec
that a built-in or Egeria-held spec already holds as its label or alias is dropped from the local copy, with one
warning, so a local spec never takes over another spec's name; a local copy keeps the aliases of the spec it
shadows. With no local specs, the registry is exactly the seed.

A local spec may shadow **any** built-in, including the bootstrap core (`Referenceable`, `Default`,
`Report-Types`, `Report-Specs`, `Report-Spec-DrE-Basic` and the like) and the Dr.Egeria display specs (the
`*-DrE`, `*-DrE-Basic` and `*-DrE-Advanced` specs, for example `Glossary-DrE-Basic`). Doing so changes what
Dr.Egeria and the Portal show for that label, everywhere that label is used. `builtin:<label>` still reaches the
original, and the shadow is logged once per label per process. To undo it, remove the local spec and refresh.

A stale `analytic_demos` entry point left in an editable install's metadata from before 6.2.29 is skipped by
name, with one log line, rather than loaded; reinstall pyegeria to drop it.

**Adding specs (the `CONFIG` tier).** There are two sources:

Expand All @@ -538,7 +561,7 @@ Every report-spec lookup (`select_report_spec`, `get_report_spec_match`, `list_r
[project.entry-points."pyegeria.report_specs"]
my_pkg = "my_pkg.specs:report_specs"
```
Entry points load first. pyegeria's own analytic demo specs load this way (`analytic_demos`), so an editable install needs `uv sync` (or `pip install -e .`) after a change to entry points.
Entry points load first. An editable install needs `uv sync` (or `pip install -e .`) after a change to entry points. pyegeria's own analytic demo specs loaded this way (`analytic_demos`) until 6.2.29; they now ship in the seed (`builtin` tier).

- **The user report specs directory.** Every `*.json` file in it is loaded, in alphabetical order, after the list above. Subdirectories and non-JSON files are ignored. The directory is resolved in this order:
1. the `PYEGERIA_USER_REPORT_SPECS_DIR` env var (or the older `PYEGERIA_USER_FORMAT_SETS_DIR`);
Expand All @@ -556,15 +579,15 @@ from pyegeria.view.base_report_formats import register_report_specs
register_report_specs(my_specs, source="my_app")
```

Registering a label again from the same `source` replaces it and is not an error, so it's safe on every handler load. A label that another source, or a built-in, generated or `CONFIG` spec, already holds raises `ReportFormatCollision`, and nothing from that call is registered. `unregister_report_spec(label)` releases a label.
Registering a label again from the same `source` replaces it and is not an error, so it's safe on every handler load. A label that another source or a `CONFIG` spec already holds raises `ReportFormatCollision`, and nothing from that call is registered. A built-in's or an Egeria-held spec's label is not a clash: the registration shadows it (above). `unregister_report_spec(label)` releases a label.

**When entries are loaded.** The `CONFIG` tier loads automatically the first time anything calls `get_report_registry()`, so no consumer needs to register anything. It loads once per process. If you add or edit a file while a process is running, call `refresh_report_specs()` to reload. `load_user_report_specs()` does the same reload and also copies the directory's files into the legacy `report_specs` dict, for older code that reads that dict directly.

**What happens when an entry is bad.** Each entry loads on its own, and a bad entry is skipped as a whole. Every other entry still loads, before and after it. An entry is skipped when:

- its file doesn't exist or isn't valid report-spec JSON;
- its entry point, module or function can't be imported, or the function raises an error;
- it defines a label that another source already defined (an earlier `CONFIG` entry, a built-in, a generated spec, or a `RUNTIME` registration). Labels must be unique across the registry, so nothing is silently overridden. The first entry to claim a label keeps it.
- it defines a label that another local source already defined (an earlier `CONFIG` entry or a `RUNTIME` registration). Labels must be unique within the local tier, so nothing local is silently overridden; the first entry to claim a label keeps it. A built-in's label is not a clash: since 6.2.29 the local entry shadows the built-in, with a warning (above).

Each skip is logged as a warning (`Skipping report spec source JSON:<path>: <reason>`). `refresh_report_specs()` also returns the skips as a list of `(source, reason)` pairs, with an empty list meaning everything loaded. Use that to check your configuration:

Expand All @@ -576,7 +599,7 @@ for source, reason in refresh_report_specs():

**Gotcha: `config.json` must be discoverable.** pyegeria only finds `config/config.json` if `PYEGERIA_CONFIG_DIRECTORY` (or `PYEGERIA_ROOT_PATH`) is set. Otherwise its `"Pyegeria User Report Specs Dir"` setting is silently ignored. If you're not sure, use `PYEGERIA_USER_REPORT_SPECS_DIR`.

**Changed behavior in the user specs directory.** Before, directory files could override a built-in spec, and a later file overwrote an earlier file's label. Neither is true any more, because the directory is now part of the `CONFIG` tier: a file that reuses an existing label is skipped with a warning. To change a built-in spec, save it under a new label. Also, before this fix the directory defaulted to `../`, the parent of the current working directory; it now defaults to `~/.pyegeria/report_specs`.
**Changed behavior in the user specs directory.** A later file no longer overwrites an earlier file's label: the directory is part of the `CONFIG` tier, and a file that reuses another local label is skipped with a warning. Before 6.2.29 a file with a built-in's label was skipped too; **since 6.2.29 it overrides the built-in** (local > egeria > builtin), with one warning, and `builtin:<label>` still reaches the original. Also, before this fix the directory defaulted to `../`, the parent of the current working directory; it now defaults to `~/.pyegeria/report_specs`.

Tip: You can also export the built‑in specs, edit them, and load the edited file as a `CONFIG` entry:

Expand Down Expand Up @@ -1087,7 +1110,7 @@ my_pkg = "my_pkg.manifests:ANALYTICS"

**Demo report specs** (`pyegeria/view/analytic_demo_specs.py`) — one real, executable `FormatSet` per registered analytic function, proving each is actually runnable as a report spec (not just documented in the registry). Named `Analytic Demo - <Heading>`, family `"Analytic Function Demo"`. Each spec's `description` states plainly whether the underlying function is generic or a fixed metric (pulled from the registry, not duplicated by hand).

**Making extra report specs visible everywhere** — the demo specs are loaded through the registry's `CONFIG` tier, by pyegeria's own `pyegeria.report_specs` entry point (`analytic_demos`, ISSUE-173). Any installed pyegeria therefore shows them to `dr_egeria`, `hey_egeria`, and every other consumer, with no config.json or env var. Another package's specs load the same way; one bad entry is skipped without affecting the rest. See [Where pyegeria looks for user specs](#where-pyegeria-looks-for-user-specs) and `refresh_report_specs()`/`get_report_registry()` in `base_report_formats.py`.
**Making extra report specs visible everywhere** — since 6.2.29 the demo specs ship in the report-spec seed (the `builtin` tier), so any installed pyegeria shows them to `dr_egeria`, `hey_egeria`, and every other consumer, with no config.json or env var. (From ISSUE-173 to 6.2.28 they loaded through pyegeria's own `pyegeria.report_specs` entry point, `analytic_demos`, in the `CONFIG` tier.) Another package's specs load through that entry-point group; one bad entry is skipped without affecting the rest. See [Where pyegeria looks for user specs](#where-pyegeria-looks-for-user-specs) and `refresh_report_specs()`/`get_report_registry()` in `base_report_formats.py`.

**Dashboard authoring** — a `Report` (a real Egeria asset naming a report spec plus default execution params, created via Dr.Egeria's `Create Report`) can be placed on a user-authored Dashboard Sheet (`Create Dashboard Sheet` / `Link Report to Dashboard Sheet`), alongside literal markdown text placements (`Add Text on Dashboard Sheet`) for section headers and explanations. See the "Report" family in `docs/dr_egeria_manual.md` and `pyegeria/view/_output_dashboard_sheet_models.py`.

Expand Down
45 changes: 45 additions & 0 deletions docs/release-notes/6.2.29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# pyegeria 6.2.29

## Changed

- **Built-in report specs ship as packaged JSON: the seed (RS-EGERIA-TIER stage 2).**
- The registry's `builtin` tier now loads from `pyegeria/view/seed/`: one JSON file per family (38) plus
`manifest.json`. It loads once per process, through `seed_report_specs()`. Before, it was built from the Python
constants.
- Each spec gives exactly the output it gave in 6.2.28. All 437 load equal to their 6.2.28 definitions, and the
census is unchanged: 437 specs, 376 runnable, 0 unrunnable, 61 format-only.
- The constants (`base_report_specs`, `generated_format_sets`, the analytic demos and the question specs) stay
only as the generator's input:
- `python -m pyegeria.view.seed build` writes the seed, and `refresh_specs` now runs it.
- `python -m pyegeria.view.seed check` fails when the seed is stale.
- A seed file that fails to load is skipped with a warning naming it, and the rest still load.
- **The analytic demo specs and `Questions`, `Report-Types` and `Question-Specs` are now `builtin`, not `local`.**
- They ship in the seed. `list_report_specs(with_status=True)` reports `source: "builtin"` for them, and a run's
`spec_source.tier` is `builtin`.
- pyegeria no longer declares its own `analytic_demos` entry point in the `pyegeria.report_specs` group, and the
question specs are no longer registered into the RUNTIME tier at import.
- **If you installed pyegeria from a checkout (editable), reinstall it so the removed `analytic_demos` entry point
drops out of the installed metadata** (`uv sync`, or `pip install -e .`). Until then a refresh skips that
stale entry point by name, with one log line, rather than loading the demos a second time as local specs.
- **A local spec now overrides a built-in of the same label: local > egeria > builtin.**
- "Local" means a file in the user report specs directory, an installed package's entry point, or
`register_report_specs()`.
- Before, such a spec was skipped (`refresh_report_specs()` listed it) or refused (`ReportFormatCollision`).
- It now wins, with one warning per label per process, worded as for an Egeria-held copy: `Report spec
'<label>': the local copy shadows the builtin copy (...); the builtin copy stays addressable as
'builtin:<label>'.`
- `builtin:<label>` (or `seed:<label>`) and `egeria:<label>` still reach the shadowed copy.
- An alias of a local spec that a built-in or Egeria-held spec already holds is dropped from the local copy, with
one warning.
- A local spec may shadow **any** built-in, including the bootstrap core and the Dr.Egeria display specs
(for example `Glossary-DrE-Basic`). That changes what Dr.Egeria and the Portal show for that label;
`builtin:<label>` still reaches the original, and the shadow is logged once per label.
- Two local sources still may not share a label.
- With no local specs, the registry is exactly the seed.
- **`spec_source` for a built-in spec names its seed file**, for example `{"tier": "builtin", "label":
"Search-Keywords", "version": None, "seed": "Feedback Manager.json"}`.
- **microflow/1 additions**, for specs held in Egeria. An older pyegeria refuses a spec that uses them.
- A format-only spec has `"stages": []`, no `params` and at least one formatter.
- A find stage's `additional_props` names the per-element hook (`FormatSet.get_additional_props`). Only the
functions on `ADDITIONAL_PROPS_HOOKS` are allowed.
- A formatter's `same_as` shares an earlier output format's formatter, as a `Format` with several types does.
10 changes: 5 additions & 5 deletions md_processing/dr_egeria.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Ensure compact command specs are loaded before any v2 processing
load_commands()

# Analytic Function Demo report specs (pyegeria.view.analytic_demo_specs) --
# and any other extra report-spec source -- are auto-loaded by
# get_report_registry() itself (CONFIG tier, through pyegeria's own
# `pyegeria.report_specs` entry point, ISSUE-173) the first time anything calls it. No explicit
# registration call needed here anymore.
# Analytic Function Demo report specs (pyegeria.view.analytic_demo_specs) ship in the
# report-spec seed (builtin tier, RS-EGERIA-TIER stage 2); any other extra report-spec
# source is auto-loaded by get_report_registry() itself (CONFIG tier, through
# `pyegeria.report_specs` entry points, ISSUE-173) the first time anything calls it. No
# explicit registration call needed here.
"""
This is an ongoing experiment in parsing and playing with Dr.Egeria docs
"""
Expand Down
4 changes: 3 additions & 1 deletion pyegeria/view/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ into MD/LIST/DICT/REPORT/MERMAID/chart output.

| File | Role |
|---|---|
| `base_report_formats.py` | Two dicts merged by `get_report_registry()`: `generated_format_sets` (auto-generated by `refresh_specs` — do not hand-edit) and `base_report_specs` (hand-maintained built-ins, e.g. `Referenceable` — `refresh_specs` never touches it). Also auto-loads a CONFIG tier from `pyegeria.report_specs` entry points and the user report specs directory; code that isn't an installed package uses `register_report_specs()`. `PYEGERIA_REPORT_SPEC_MODULES` and config.json's list were removed in 6.2.19 (ISSUE-173). |
| `base_report_formats.py` | Two dicts merged by `get_report_registry()`: `generated_format_sets` (auto-generated by `refresh_specs` — do not hand-edit) and `base_report_specs` (hand-maintained built-ins, e.g. `Referenceable` — `refresh_specs` never touches it). Since RS-EGERIA-TIER stage 2 these (with the analytic demos and the question specs) are only the input of the seed generator; the registry's builtin tier loads from `seed/`. Also auto-loads a CONFIG tier from `pyegeria.report_specs` entry points and the user report specs directory; code that isn't an installed package uses `register_report_specs()`. `PYEGERIA_REPORT_SPEC_MODULES` and config.json's list were removed in 6.2.19 (ISSUE-173). |
| `seed/` | The report-spec seed (RS-EGERIA-TIER stage 2): pyegeria's shipped specs as packaged JSON, one file per family plus `manifest.json` (format, files, label order, census). `get_report_registry()` loads the builtin tier from it through `seed_report_specs()`. Each entry is `{label, envelope, microflow}` (microflow/1). Generated from the Python constants by `python -m pyegeria.view.seed build` (run by `refresh_specs`); `... seed check` fails when it is stale (a micro-test runs it). Do not hand-edit. `BOOTSTRAP_CORE` names the specs that always come from it. |
| `microflow.py` | `microflow/1`: the stored micro-flow model, its JSON Schema (`schemas/microflow-1.json`), the conversions to and from `FormatSet`, and the allowlists (`FIND_METHOD_ALLOWLIST`, `ADDITIONAL_PROPS_HOOKS`). |
| `_output_format_models.py` | Pydantic models `Column`/`Format`/`FormatSet`/`ActionParameter` — define new report specs with these, not raw dicts. |
| `output_formatter.py` | `generate_output()` — materializes elements into MD/LIST/DICT/REPORT formats. |
| `format_set_executor.py` | `exec_report_spec()` — runs a `FormatSet`'s query/render path; dispatches `SERIES`/`BAR`/`PIE` output formats to Vega-Lite chart rendering before normal Format-row lookup. |
Expand Down
Loading
Loading