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
2 changes: 1 addition & 1 deletion commands/cat/get_asset_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def asset_viewer(asset_guid: str, output_format: str = "TABLE", view_server: str
render_table: bool = False, table_caption: str | None = None, use_pager: bool = True):
try:
list_generic(report_spec="Asset-Graph", output_format=output_format, view_server=view_server,
view_url=view_url, user=user, user_pass=user_pass, params={"asset_guid": asset_guid},
view_url=view_url, user=user, user_pass=user_pass, params={"guid": asset_guid},
render_table=render_table, write_file = write_file, table_caption=table_caption, use_pager=use_pager,
width=width, jupyter=jupyter, prompt_missing=prompt_missing)

Expand Down
17 changes: 15 additions & 2 deletions docs/output-formats-and-report-specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ Check 1 on a report spec that names a dotted path says, for example: *Report spe

- **Runnable:** a `ResolvedSpec`. Its `notes` say which checks did not run and why; its `warnings` are defects that bite only when a caller uses an optional parameter.
- **Unrunnable:** an `Unrunnable` with `words` and `checks`. It failed at least one check.
- **Format-only:** an `Unrunnable` of `kind="format_only"` with `checks=[1]`: the spec has no `action`, so it formats elements another call fetched (a detail view, or a command's output format). **This is not broken**: the words say `it has no action, so it formats elements another call fetched`. On the registry as of 6.2.27 there are 374 runnable, 61 format-only and 2 unrunnable specs.
- **Format-only:** an `Unrunnable` of `kind="format_only"` with `checks=[1]`: the spec has no `action`, so it formats elements another call fetched (a detail view, or a command's output format). **This is not broken**: the words say `it has no action, so it formats elements another call fetched`. On the registry as of 6.2.28 there are 376 runnable, 61 format-only and no unrunnable specs (6.2.27 had 374 runnable and 2 unrunnable; see below).

**Listing them.**

Expand All @@ -1249,13 +1249,26 @@ for name, spec in unrunnable_specs().items(): # format-only left out; p
- `load_egeria_report_specs()` (the Egeria question-spec load);
- `commands/tech/refresh_specs.py`, which resolves everything after regenerating and logs the count.

**Reading the words: the two specs that are unrunnable today.** Both fail check 1, both are `find` specs, and both name a find method that does not exist, so the words tell you exactly what to fix:
**Reading the words: the two specs that were unrunnable in 6.2.27.** Both failed check 1, both were `find` specs, and both named a find method that no longer existed, so the words said exactly what to fix:

- `Spec 'Asset-Graph' cannot run (check 1): its find method 'ServerClient.get_asset_graph' does not exist: EgeriaTech or any client it proxies to has no '_async_get_asset_graph'.`
- `Spec 'Data-Classes' cannot run (check 1): its find method 'DataDesigner.find_data_classes' does not exist: client class DataDesigner has no '_async_find_data_classes'.`

Read it left to right: *the check* (1, names), *the thing named* (`ServerClient.get_asset_graph`), *where the resolver looked* (the client class the executor would use for that name, here EgeriaTech and everything it proxies to), and *what was missing* (an `_async_` method of that name). They are listed with these words by `list_report_specs(with_status=True)` rather than being left to fail when someone runs them.

6.2.28 fixed both, as the words pointed: `Asset-Graph` now calls `AssetCatalog.get_asset_graph_by_guid` (parameter `guid`), and `Data-Classes` calls `DataDesigner.find_data_value_specifications` with `metadata_element_subtypes=["DataClass"]` (a DataClass is a DataValueSpecification subtype and shares its search).

**What `Asset-Graph` returns (6.2.28).** It declares DICT and JSON for code, and REPORT, HTML and MERMAID for people:

| Output format | Shape |
|---|---|
| `DICT` | One row: the asset itself, with its own fields and its graph fields (`Mermaid Graph`, `Anchor Graph`, `Action Graph`, `Field Level Lineage Graph`) as text. |
| `JSON` | The full graph response. |
| `REPORT`, `HTML` | The asset's fields, with the asset, anchor and action graphs rendered as mermaid. A fetch by GUID is not a search, so the report does not say "found from the search string". |
| `MERMAID` | The asset graph. |

`TABLE`, `LIST`, `MD`, `FORM` and `ALL` are not declared, and asking for them is an error that names the declared formats. `Asset-Graph` is in `NO_TABLE_FALLBACK`, so `TABLE` does not fall back to the DICT row: a table of a graph is its edges, and that edge table is planned as its own spec in Wave 3, built by a processor stage (`pyegeria/view/asset_graph.py` holds the edge helper it will use).

> **Planned, not shipped.** Report specs held in Egeria itself (synced, cached and addressed as `egeria:...`) are being built in a first stage; see `portal-docs/Internals/report-spec-pipeline-model.md` (v5.5) in egeria-workspaces. This section describes only specs loaded from files, entry points and the runtime registry.


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

## Fixed

- **The two unrunnable built-in report specs run again.** `Asset-Graph` named
`ServerClient.get_asset_graph`, which no longer exists; it now calls
`AssetCatalog.get_asset_graph_by_guid`, and its required parameter is `guid` (was `asset_guid`; the
`hey_egeria` asset graph command passes the new name).
`Data-Classes` named `DataDesigner.find_data_classes`, which no longer exists; it now calls
`DataDesigner.find_data_value_specifications` restricted to the `DataClass` subtype
(`metadata_element_subtypes=["DataClass"]`). The load-time census is now 437 specs: 376 runnable,
61 format-only, none unrunnable (6.2.27: 374 runnable, 2 unrunnable).
- **`Asset-Graph` renders the asset graph.** It declares DICT and JSON for code, and REPORT,
HTML and MERMAID for people. DICT is one row, the asset itself with its own fields and its graph
fields. JSON is the full graph response. REPORT and HTML show the asset's fields with its
asset, anchor and action graphs rendered as mermaid. MERMAID is the asset graph. The anchor
graph's misspelt column key (`anchorMermaidGRaph`) is corrected, and an Action Graph column is
added. TABLE, LIST, MD, FORM and ALL are not declared; asking for them is an error that names
the declared formats, and TABLE does not fall back to the DICT row (`NO_TABLE_FALLBACK`). A table
of a graph is its edges; that edge table is planned as its own spec in Wave 3.
- **A REPORT names a search string only when there was one.** A fetch by GUID, or a find with no
search string, no longer says "found from the search string: `All`" (or `Members`).
- **HTML output renders markdown tables.** The HTML renderer had GFM tables switched off, so a
markdown table in a REPORT came out as text, although the page's CSS styles tables; it is now
a table.
- **`exec_report_spec` no longer returns `None` when a find method raises `ValueError`.** It logs
the error and raises it, so the caller sees the words.
10 changes: 9 additions & 1 deletion pyegeria/omvs/asset_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ def _generate_asset_output(self, elements: dict | list[dict], filter_string: Opt
**kwargs
)

def _generate_asset_graph_output(self, elements: dict | list[dict], filter_string: Optional[str] = None,
element_type_name: Optional[str] = None, output_format: str = "DICT",
report_spec: dict | str | None = None, **kwargs) -> str | list[dict]:
"""Output for get_asset_graph_by_guid: the generic asset output, without a search string. A fetch
by GUID is not a search, so its REPORT does not say "found from the search string" (6.2.28)."""
return self._generate_asset_output(elements, None, element_type_name, output_format, report_spec,
**kwargs)

@dynamic_catch
async def _async_find_in_asset_domain(
self,
Expand Down Expand Up @@ -408,7 +416,7 @@ async def _async_get_asset_graph_by_guid(
response = await self._async_get_results_body_request(
url=url,
_type="Asset",
_gen_output=self._generate_asset_output,
_gen_output=self._generate_asset_graph_output,
start_from=start_from,
page_size=page_size,
output_format=output_format,
Expand Down
6 changes: 6 additions & 0 deletions pyegeria/view/_output_format_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ def _drop_deprecated_binders(cls, values, handler):
one is dropped with a DeprecationWarning and a log warning naming the parameters: the
routine must declare them as `inputs` instead, or its call will lack them. The names are
kept on the model (`_dropped_binders`) so the spec resolver can report them as a warning.

The marker is a private attribute: it survives `model_copy`, but NOT `model_dump` and a
reload (`model_validate_json(fs.model_dump_json())` has no marker and so no warning), since
the dump no longer holds the key. Resolve the loaded spec, not a serialised copy of it. The
EGERIA tier rebuilds its specs from the cached micro-flow text, which keeps the key, so
its marker is set afresh on every load.
"""
names: List[str] = []
if isinstance(values, dict) and "analytic_binders" in values:
Expand Down
132 changes: 132 additions & 0 deletions pyegeria/view/asset_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"""
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the ODPi Egeria project.

Edges and nodes of an Egeria asset graph (the response of AssetCatalog.get_asset_graph_by_guid).

A helper kept for the planned Wave 3 edge-table spec (a processor stage that turns a graph into one
row per edge). No report spec uses it yet: `Asset-Graph` declares DICT and JSON for code and REPORT,
HTML and MERMAID for people (6.2.28).

How the response holds edges: `relationships` lists the edges among the asset and its anchored
elements, each with `startingElementGUID` (one end), `relatedElement` (the other end) and
`relatedElementAtEnd1` (which end that is). The asset's own relationships are keyed lists at the
top level (for example `governedBy`, `requestedActions`), each item a `relatedElement` with
`relatedElementAtEnd1`, the asset being the other end. An edge reported twice (the same
relationship GUID) is listed once, and rows are sorted, so the order never depends on Egeria's.

Pure functions: no I/O, no client.
"""
from __future__ import annotations

from typing import Any, Dict, List, Optional, Tuple

#: Edge row keys, in column order.
EDGE_COLUMNS: List[Tuple[str, str]] = [
("From Display Name", "from_display_name"),
("From Type", "from_type"),
("From GUID", "from_guid"),
("Relationship", "relationship_type"),
("To Display Name", "to_display_name"),
("To Type", "to_type"),
("To GUID", "to_guid"),
]

#: Node keys, in column order.
NODE_COLUMNS: List[Tuple[str, str]] = [
("Display Name", "display_name"),
("Type", "type_name"),
("GUID", "guid"),
("Role", "role"),
]

def _dig(obj: Any, path) -> Any:
for key in path:
if not isinstance(obj, dict):
return None
obj = obj.get(key)
return obj


def _node(element: Dict[str, Any]) -> Dict[str, str]:
header = element.get("elementHeader") or {}
props = element.get("properties") or {}
return {"guid": header.get("guid") or "",
"type_name": _dig(header, ("type", "typeName")) or "",
"display_name": (props.get("displayName") or props.get("name") or props.get("qualifiedName")
or element.get("uniqueName") or "")}


def _is_edge(item: Any) -> bool:
return isinstance(item, dict) and "relationshipHeader" in item and isinstance(item.get("relatedElement"), dict)


def _asset_edge_lists(graph: Dict[str, Any]) -> List[List[Dict[str, Any]]]:
"""The asset's own relationships: every top-level list (other than `relationships`) of edges."""
return [v for k, v in graph.items()
if k != "relationships" and isinstance(v, list) and v and all(_is_edge(i) for i in v)]


def graph_nodes(graph: Dict[str, Any]) -> List[Dict[str, str]]:
"""Every node: the asset first, then anchored elements, then other related elements, by name."""
asset = _node(graph)
asset["role"] = "asset"
seen = {asset["guid"]: asset}
anchored, related = [], []
for el in graph.get("anchoredElements") or []:
n = _node(el)
if n["guid"] and n["guid"] not in seen:
n["role"] = "anchored"
seen[n["guid"]] = n
anchored.append(n)
for edges in [graph.get("relationships") or []] + _asset_edge_lists(graph):
for item in edges:
if not _is_edge(item):
continue
n = _node(item["relatedElement"])
if n["guid"] and n["guid"] not in seen:
n["role"] = "related"
seen[n["guid"]] = n
related.append(n)
order = lambda n: (n["display_name"].lower(), n["type_name"], n["guid"]) # noqa: E731
return [asset] + sorted(anchored, key=order) + sorted(related, key=order)


def graph_edges(graph: Dict[str, Any]) -> List[Dict[str, str]]:
"""One row per edge (keys: the labels of EDGE_COLUMNS), sorted, each relationship once."""
nodes = {n["guid"]: n for n in graph_nodes(graph)}
asset_guid = _node(graph)["guid"]
rows: Dict[str, Dict[str, str]] = {}

def add(item: Dict[str, Any], starting_guid: Optional[str]) -> None:
header = item["relationshipHeader"]
rel_guid = header.get("guid") or ""
related = _node(item["relatedElement"])
start = nodes.get(starting_guid or "") or {"guid": starting_guid or "", "type_name": "", "display_name": ""}
if item.get("relatedElementAtEnd1"):
end1, end2 = related, start
else:
end1, end2 = start, related
key = rel_guid or f"{end1['guid']}|{_dig(header, ('type', 'typeName'))}|{end2['guid']}"
if key in rows:
return
values = {"from_display_name": end1["display_name"], "from_type": end1["type_name"],
"from_guid": end1["guid"], "relationship_type": _dig(header, ("type", "typeName")) or "",
"to_display_name": end2["display_name"], "to_type": end2["type_name"], "to_guid": end2["guid"]}
rows[key] = {label: values[k] for label, k in EDGE_COLUMNS} | {"_relationship_guid": rel_guid}

for item in graph.get("relationships") or []:
if _is_edge(item):
add(item, item.get("startingElementGUID") or asset_guid)
for edges in _asset_edge_lists(graph):
for item in edges:
add(item, asset_guid)

def order(r):
return (r["From Display Name"].lower(), r["Relationship"], r["To Display Name"].lower(),
r["From GUID"], r["To GUID"], r["_relationship_guid"])

out = sorted(rows.values(), key=order)
for r in out:
r.pop("_relationship_guid")
return out
Loading
Loading