From d2b879cec8bd8fb05e5837c99a2edfd6a2f26501 Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 19:59:19 +0000 Subject: [PATCH 1/2] fix: DCAT Catalog runs with a search string; My Egeria domain selection passes the GUID (6.2.38) Post-release findings from the 6.2.37 live check: - F-DCAT1: the seed "DCAT Catalog" specs named their file "{scope}-dcat.*", so a search_string run was refused ("needs parameter 'scope'") before the exporter ran. fill_document_file_name now accepts alternatives in a field, {scope|search_string}: the first supplied parameter wins, made file-name safe as before; neither is refused in words. Both seed specs use it (descriptions mention search_string); seed rebuilt. Tests: both seed specs run with a search string on the real clinical-trial capture, the JSON-LD spec with a scope, neither refused, and the alternatives syntax. - F-ME1: SelectionOverviewScreen passed a domain node's whole [type name, GUID] data as the GUID. node_identifier() takes the GUID from a list, the string itself otherwise, and a data-less leaf's qualified-name label (domain members, glossary folder terms, root-collection folders previously passed None). Tests drive handle_tree_node_selected with Textual trees built as Shop for Data builds them, for every node kind. - docs/release-notes/6.2.38.md. Signed-off-by: Dan Wolfson --- docs/release-notes/6.2.38.md | 16 ++++++ .../my_egeria/SelectionOverviewScreen.py | 24 +++++++-- pyegeria/view/base_report_formats.py | 11 ++-- pyegeria/view/format_set_executor.py | 36 +++++++------ pyegeria/view/seed/Standard Documents.json | 8 +-- .../test_my_egeria_node_identifier.py | 50 +++++++++++++++++++ tests/micro-tests/test_sd2_export_dcat.py | 35 +++++++++++++ 7 files changed, 152 insertions(+), 28 deletions(-) create mode 100644 docs/release-notes/6.2.38.md create mode 100644 tests/micro-tests/test_my_egeria_node_identifier.py diff --git a/docs/release-notes/6.2.38.md b/docs/release-notes/6.2.38.md new file mode 100644 index 00000000..c3cb485e --- /dev/null +++ b/docs/release-notes/6.2.38.md @@ -0,0 +1,16 @@ +# pyegeria 6.2.38 + +pyegeria 6.2.38 fixes two bugs found in the 6.2.37 live check. + +## Fixed + +- **The "DCAT Catalog" spec could not run a search-scoped catalog** (F-DCAT1, new in 6.2.37). Its file name was + `{scope}-dcat.jsonld`, so a run with `search_string` instead of `scope` was refused with "needs parameter 'scope'" + before the exporter ran. A DOCUMENT file-name field can now name alternatives, `{scope|search_string}`: the first + parameter the run supplies is used, made file-name safe as before. Both built-in specs ("DCAT Catalog" and + "DCAT Catalog (Turtle)") use it; a run with neither parameter is refused with "needs one of the parameters + 'scope', 'search_string'". +- **My Egeria: selecting a business domain showed "No business domain data returned for GUID: ['BusinessCapability', + '…']"** (F-ME1). The domain tree stores `[type name, GUID]` on each node and the whole list was passed as the GUID. + The selection screen now passes the GUID; a leaf that stores nothing (domain members, glossary folder terms, + root-collection folders) passes its qualified-name label instead of `None`. diff --git a/my_egeria/my_egeria/SelectionOverviewScreen.py b/my_egeria/my_egeria/SelectionOverviewScreen.py index f0e6dd97..617778f2 100644 --- a/my_egeria/my_egeria/SelectionOverviewScreen.py +++ b/my_egeria/my_egeria/SelectionOverviewScreen.py @@ -20,6 +20,25 @@ from profile_utils import set_screen_heading + +def node_identifier(data, label=None): + """The GUID or qualified name a selected tree node stands for (6.2.38, F-ME1). + + Shop for Data's trees store it three ways: the domain tree stores `[type name, GUID]` (passing the + whole list as the GUID read "No business domain data returned for GUID: ['BusinessCapability', ...]"), + other leaves store the GUID or qualified name itself, and some leaves (domain members, glossary folder + terms, root-collection folders) store nothing and are named by their qualified name. A list gives its + last non-empty string; nothing gives the label's text.""" + if isinstance(data, (list, tuple)): + strings = [d for d in data if isinstance(d, str) and d.strip()] + return strings[-1] if strings else None + if isinstance(data, str) and data.strip(): + return data + if label is None: + return None + text = getattr(label, "plain", label) + return str(text) if str(text).strip() else None + class SelectionOverviewScreen(ModalScreen): """Screen to display the selection of the user's data sources.""" BINDINGS = [("escape", "back", "Back"), @@ -110,9 +129,8 @@ def handle_tree_node_selected(self, event: Tree.NodeSelected): # self.log(f"Node selected: {self.node_selected}") self.node_label = self.node_selected.label self.node_data = self.node_selected.data - # the provided id can be either a GUID or a qualified name! - # the variable is labeled guid but it could contain a qualified name, both guid and qualified name are strings. - self.node_GUID = self.node_selected.data + # the provided id can be either a GUID or a qualified name (both strings); see node_identifier. + self.node_GUID = node_identifier(self.node_selected.data, self.node_label) # self.log(f"Node label: {self.node_label}, GUID: {self.node_GUID}") if self.category == "glossary": self.display_selected_term_details(self.node_GUID) diff --git a/pyegeria/view/base_report_formats.py b/pyegeria/view/base_report_formats.py index 1103e059..87bf0eb8 100644 --- a/pyegeria/view/base_report_formats.py +++ b/pyegeria/view/base_report_formats.py @@ -4718,26 +4718,27 @@ def list_report_specs(*, with_status: bool = False) -> list: # analytic function export_dcat. Run with output_format "DOCUMENT" and a `scope` parameter. "DCAT Catalog": FormatSet( heading="DCAT Catalog", - description="A DCAT-AP 3 catalog (JSON-LD) of the Assets in a collection or folder, read as you. Give " - "`scope`: the collection's qualifiedName or GUID. DigitalProducts and Agreements are Bitol's " + description="A DCAT-AP 3 catalog (JSON-LD) of the Assets in a collection or folder (or of the assets matching a search), read as you. Give " + "`scope`: the collection's qualifiedName or GUID, or `search_string`. DigitalProducts and Agreements are Bitol's " "and are named in the notes, not exported; validated against the vendored DCAT-AP 3.0.1 " "SHACL shapes. Run with output_format DOCUMENT.", family="Standard Documents", target_type="Collection", formats=[Format(types=["DOCUMENT"], document={ "standard": "dcat-ap-3", "media_type": "application/ld+json", - "file_name": "{scope}-dcat.jsonld", "validator": "dcat-ap-3-shacl"})], + "file_name": "{scope|search_string}-dcat.jsonld", "validator": "dcat-ap-3-shacl"})], action=ActionParameter(analytic_function="export_dcat", analytic_spec_params={"format": "jsonld"}), ), "DCAT Catalog (Turtle)": FormatSet( heading="DCAT Catalog (Turtle)", description="The DCAT Catalog document as Turtle: a DCAT-AP 3 catalog of the Assets in a collection or " - "folder, read as you. Give `scope`. Run with output_format DOCUMENT.", + "folder (or of the assets matching a search), read as you. Give `scope` or " + "`search_string`. Run with output_format DOCUMENT.", family="Standard Documents", target_type="Collection", formats=[Format(types=["DOCUMENT"], document={ "standard": "dcat-ap-3", "media_type": "text/turtle", - "file_name": "{scope}-dcat.ttl", "validator": "dcat-ap-3-shacl"})], + "file_name": "{scope|search_string}-dcat.ttl", "validator": "dcat-ap-3-shacl"})], action=ActionParameter(analytic_function="export_dcat", analytic_spec_params={"format": "turtle"}), ), }) diff --git a/pyegeria/view/format_set_executor.py b/pyegeria/view/format_set_executor.py index a1d30958..ded83245 100644 --- a/pyegeria/view/format_set_executor.py +++ b/pyegeria/view/format_set_executor.py @@ -1306,28 +1306,32 @@ def _document_spec_struct(format_set_name: Any) -> Optional[Dict[str, Any]]: def fill_document_file_name(template: str, params: Dict[str, Any]) -> str: """Fill a DOCUMENT file-name template from the run's parameters. - Only plain `{name}` fields are allowed (no attribute or index access). Each value is made - file-name safe (anything but letters, digits and `._+-` becomes `_`, and `..` is broken up), - so a qualifiedName such as `Folder::Sales/EU` cannot become a path. The result is checked - again; a template that still names a path, or a parameter the run did not supply, is refused - with a sentence.""" - values: Dict[str, str] = {} - for _literal, field, spec, conversion in string.Formatter().parse(template): + A field is a plain parameter name, or alternatives separated by `|` (6.2.38): `{scope|search_string}` + takes the first one the run supplies, so one template serves an exporter that takes either. Nothing + else is allowed (no attribute or index access, no format spec). Each value is made file-name safe + (anything but letters, digits and `._+-` becomes `_`, and `..` is broken up), so a qualifiedName such + as `Folder::Sales/EU` cannot become a path. The result is checked again; a template that still names + a path, or a field none of whose parameters the run supplied, is refused with a sentence.""" + out: List[str] = [] + for literal, field, spec, conversion in string.Formatter().parse(template): + out.append(literal) if field is None: continue - if not field.isidentifier(): + names = field.split("|") + if not all(n.isidentifier() for n in names): raise ValueError(f"DOCUMENT file_name template '{template}' has field '{{{field}}}'; only plain " - f"parameter names are allowed") + f"parameter names (or alternatives a|b) are allowed") if spec or conversion: raise ValueError(f"DOCUMENT file_name template '{template}' formats field '{field}'; only plain " f"parameter names are allowed") - raw = params.get(field) - if raw in (None, ""): - raise ValueError(f"DOCUMENT file_name template '{template}' needs parameter '{field}', which this " - f"run did not supply") - safe = _FILE_NAME_UNSAFE.sub("_", str(raw)).replace("..", "_").strip("._") or "_" - values[field] = safe - file_name = template.format(**values) + raw = next((params.get(n) for n in names if params.get(n) not in (None, "")), None) + if raw is None: + wanted = f"parameter '{names[0]}'" if len(names) == 1 else "one of the parameters " + ", ".join( + f"'{n}'" for n in names) + raise ValueError(f"DOCUMENT file_name template '{template}' needs {wanted}, which this run did not " + f"supply") + out.append(_FILE_NAME_UNSAFE.sub("_", str(raw)).replace("..", "_").strip("._") or "_") + file_name = "".join(out) reason = check_document_file_name(file_name) if reason: raise ValueError(f"DOCUMENT file_name refused: {reason}") diff --git a/pyegeria/view/seed/Standard Documents.json b/pyegeria/view/seed/Standard Documents.json index b5c1b82f..2aee7344 100644 --- a/pyegeria/view/seed/Standard Documents.json +++ b/pyegeria/view/seed/Standard Documents.json @@ -6,7 +6,7 @@ "label": "DCAT Catalog", "envelope": { "heading": "DCAT Catalog", - "description": "A DCAT-AP 3 catalog (JSON-LD) of the Assets in a collection or folder, read as you. Give `scope`: the collection's qualifiedName or GUID. DigitalProducts and Agreements are Bitol's and are named in the notes, not exported; validated against the vendored DCAT-AP 3.0.1 SHACL shapes. Run with output_format DOCUMENT.", + "description": "A DCAT-AP 3 catalog (JSON-LD) of the Assets in a collection or folder (or of the assets matching a search), read as you. Give `scope`: the collection's qualifiedName or GUID, or `search_string`. DigitalProducts and Agreements are Bitol's and are named in the notes, not exported; validated against the vendored DCAT-AP 3.0.1 SHACL shapes. Run with output_format DOCUMENT.", "family": "Standard Documents", "target_type_name": "Collection", "aliases": [] @@ -24,7 +24,7 @@ "formatters": { "DOCUMENT": { "columns": [], - "document": {"standard": "dcat-ap-3", "media_type": "application/ld+json", "file_name": "{scope}-dcat.jsonld", "validator": "dcat-ap-3-shacl"} + "document": {"standard": "dcat-ap-3", "media_type": "application/ld+json", "file_name": "{scope|search_string}-dcat.jsonld", "validator": "dcat-ap-3-shacl"} } } } @@ -33,7 +33,7 @@ "label": "DCAT Catalog (Turtle)", "envelope": { "heading": "DCAT Catalog (Turtle)", - "description": "The DCAT Catalog document as Turtle: a DCAT-AP 3 catalog of the Assets in a collection or folder, read as you. Give `scope`. Run with output_format DOCUMENT.", + "description": "The DCAT Catalog document as Turtle: a DCAT-AP 3 catalog of the Assets in a collection or folder (or of the assets matching a search), read as you. Give `scope` or `search_string`. Run with output_format DOCUMENT.", "family": "Standard Documents", "target_type_name": "Collection", "aliases": [] @@ -51,7 +51,7 @@ "formatters": { "DOCUMENT": { "columns": [], - "document": {"standard": "dcat-ap-3", "media_type": "text/turtle", "file_name": "{scope}-dcat.ttl", "validator": "dcat-ap-3-shacl"} + "document": {"standard": "dcat-ap-3", "media_type": "text/turtle", "file_name": "{scope|search_string}-dcat.ttl", "validator": "dcat-ap-3-shacl"} } } } diff --git a/tests/micro-tests/test_my_egeria_node_identifier.py b/tests/micro-tests/test_my_egeria_node_identifier.py new file mode 100644 index 00000000..da7c1f3d --- /dev/null +++ b/tests/micro-tests/test_my_egeria_node_identifier.py @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. +"""6.2.38 F-ME1: selecting a node in My Egeria's SelectionOverviewScreen passes the node's GUID (or +qualified name), never the domain tree's whole [type, GUID] list.""" +from types import SimpleNamespace + +import pytest +from textual.widgets import Tree + +from my_egeria.SelectionOverviewScreen import SelectionOverviewScreen, node_identifier + +DOMAIN_GUID = "8dc3ff8d-0000-4000-8000-000000000001" + + +def _select(category, node): + calls = [] + record = lambda kind: (lambda ident: calls.append((kind, ident))) + fake = SimpleNamespace(category=category, + display_selected_term_details=record("glossary"), + display_selected_digital_product=record("catalog"), + display_selected_data_dictionary=record("dictionary"), + display_selected_business_domain=record("domain"), + display_selected_root_collection=record("collection")) + SelectionOverviewScreen.handle_tree_node_selected(fake, SimpleNamespace(node=node)) + return calls + + +def test_a_domain_node_passes_its_guid_not_the_list(): + tree = Tree("Domains") # built as shop_for_data_handler.build_domain_details builds it + branch = tree.root.add("BusinessCapability::Finance", data=["BusinessCapability", DOMAIN_GUID]) + assert _select("domain", branch) == [("domain", DOMAIN_GUID)] + + +@pytest.mark.parametrize("category, data, label, expected", [ + ("catalog", "a1b2-guid", "Product summary", "a1b2-guid"), # leaf data is the GUID + ("dictionary", "DataDictionary::Sales::Term", "Summary", "DataDictionary::Sales::Term"), + ("collection", None, "CollectionFolder::Portal", "CollectionFolder::Portal"), # no data: its QN label + ("domain", None, "BusinessCapability::Finance::Payroll", "BusinessCapability::Finance::Payroll"), + ("glossary", None, "GlossaryTerm::Customer", "GlossaryTerm::Customer"), +]) +def test_other_node_kinds(category, data, label, expected): + tree = Tree("T") + leaf = tree.root.add_leaf(label, data=data) + assert _select(category, leaf) == [(category, expected)] + + +def test_node_identifier(): + assert node_identifier(["BusinessCapability", DOMAIN_GUID]) == DOMAIN_GUID + assert node_identifier(("x", "")) == "x" + assert node_identifier(None) is None and node_identifier("") is None diff --git a/tests/micro-tests/test_sd2_export_dcat.py b/tests/micro-tests/test_sd2_export_dcat.py index 4bc11b89..5474de34 100644 --- a/tests/micro-tests/test_sd2_export_dcat.py +++ b/tests/micro-tests/test_sd2_export_dcat.py @@ -453,3 +453,38 @@ def test_a_held_document_spec_that_refuses_to_load_is_skipped_with_words(bad, wo esc._build(_held_spec(bad), folders=[], identity="erinoverview", registry_names=set()) assert caught.value.who == "Held DCAT" assert caught.value.reason.startswith("the spec does not load:") and words in caught.value.reason + + +# ── 6.2.38 F-DCAT1: the seed spec runs with scope or with search_string ── + +@pytest.mark.parametrize("spec_name, ext", [("DCAT Catalog", "jsonld"), ("DCAT Catalog (Turtle)", "ttl")]) +def test_seed_spec_runs_with_a_search_string(spec_name, ext): + fx = _fixture("clinical_trial_files") + out = fse.exec_report_spec(spec_name, output_format="DOCUMENT", params=dict(fx["params"]), + supply=PlainSupply(Replay(fx)), view_server="vs", view_url="https://x", + user="u", user_pass="p") + assert out["kind"] == "document" + assert out["file_name"] == f"DataLake_PROJ-CT-TBDF_WeeklyMeasurements_Oak_Dene_Hospital_PROJ-CT-TBDF_00002-dcat.{ext}" + assert len(_graph(out["text"], "json-ld" if ext == "jsonld" else "turtle")) > 0 + assert out["validation"]["findings"] == EXPECTED_FINDINGS["clinical_trial_files"] + + +def test_seed_spec_still_runs_with_a_scope(): + fx = _fixture("portal_dashboards") + out = fse.exec_report_spec("DCAT Catalog", output_format="DOCUMENT", params={"scope": fx["params"]["scope"]}, + supply=PlainSupply(Replay(fx)), view_server="vs", view_url="https://x", + user="u", user_pass="p") + assert out["file_name"] == "DashboardFolder_Consumer_Portal-dcat.jsonld" + + +def test_seed_spec_with_neither_is_refused_in_words(): + with pytest.raises(ValueError, match="needs one of the parameters 'scope', 'search_string'"): + fse.exec_report_spec("DCAT Catalog", output_format="DOCUMENT", params={}, view_server="vs", + view_url="https://x", user="u", user_pass="p") + + +def test_file_name_alternatives(): + assert fse.fill_document_file_name("{scope|search_string}.json", {"search_string": "a b"}) == "a_b.json" + assert fse.fill_document_file_name("{scope|search_string}.json", {"scope": "S", "search_string": "x"}) == "S.json" + with pytest.raises(ValueError, match="only plain parameter names"): + fse.fill_document_file_name("{scope|x.y}.json", {"scope": "S"}) From 54708f623e9d4827b0c150031f3d6f1f884f895c Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Wed, 11 Nov 2026 20:11:34 +0000 Subject: [PATCH 2/2] chore(release): pyegeria 6.2.38 Signed-off-by: Dan Wolfson --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d9582462..8ff50178 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "pyegeria" -version = "6.2.37" +version = "6.2.38" license = 'Apache-2.0' license-files = ["LICENSE"] authors = [{name = "Dan Wolfson", email = "dan.wolfson@pdr-associates.com"},] diff --git a/uv.lock b/uv.lock index 9a7ed3c9..25f4407e 100644 --- a/uv.lock +++ b/uv.lock @@ -2271,7 +2271,7 @@ sdist = { url = "https://files.pythonhosted.org/packages/f8/f6/8f49005d581cff883 [[package]] name = "pyegeria" -version = "6.2.37" +version = "6.2.38" source = { editable = "." } dependencies = [ { name = "altair" },