Repository navigation
feat(ontology): add gm import-dataplex-glossary for Knowledge Catalog glossaries (issue #612, PR 1) - #613
Conversation
… glossaries (issue GoogleCloudPlatform#612, PR 1) Add a read-only importer, next to `gm import-owl`, that turns a Knowledge Catalog (Dataplex) Business Glossary into an ontology.yaml. Mapping: - The glossary becomes the root ontology and SKOS concept scheme (`dataplex:glossary`, `dataplex:uid`). - Every category and term becomes an abstract entity with `skos:prefLabel` (display name), `skos:notation` (raw resource ID), `dataplex:resource` (resource name) and `skos:inScheme`. Children of the glossary also get `skos:topConceptOf`. - A child of a category of the same glossary gets an abstract `skos_broader` relationship to it. Any other parent is kept as `dataplex:orphan_parent` and counted in the import summary. Names and determinism: - Entities are named `category_<id>` or `term_<id>`, so the separate category and term ID spaces cannot collide. Characters outside [A-Za-z0-9_] become `_`. Names of the same kind that still collide each get a `_<sha256(raw id)[:8]>` suffix, independent of API order. - Output is canonical (entities, relationships and annotations sorted, identical repeated records deduplicated), so re-importing an unchanged glossary gives byte-identical YAML and the same compile_fingerprint, whatever order or repetition the API returns pages in. - Records from another project, location or glossary, conflicting records for one resource ID, and empty glossaries fail the import. A project ID and a project number count as the same project. Structure: - `map_dataplex_glossary()` is a pure function over already-fetched records. `import_dataplex_glossary()` is a thin wrapper around GetGlossary, ListGlossaryCategories and ListGlossaryTerms. - New `[dataplex]` extra (google-cloud-dataplex>=2.12.0, also in `[all]`), imported only when the API is called. Not in this change: entry links (synonyms, related terms, asset definitions). The YAML still needs a companion binding for `gm compile` and OntologyRuntime; the user manual and docs/ontology/cli.md show the path from a small nested glossary to concept-index rows, including the bare CREATE PROPERTY GRAPH header that an entity-less binding produces. Unlike `gm import-owl`, this importer sanitizes and disambiguates names and reports orphan parents. Part of GoogleCloudPlatform#612.
caohy1988
left a comment
There was a problem hiding this comment.
Thanks for this. The mapper/API split, the shuffled-and-repeated page tests, and the companion-binding walkthrough all hold up well, and the importer and ontology tests pass locally at this head (169 passed / 9 skipped, and 434 passed / 11 skipped for tests/bigquery_ontology plus tests/test_ontology_runtime.py). One thing needs to change before this goes in.
Project ID vs. number matching accepts unrelated projects. _same_project (src/bigquery_ontology/dataplex_glossary_importer.py:210-220) returns true for any pair where one side is numeric and the other isn't. That same check gates record admission (around line 351) and parent resolution (around lines 443-450), so a category or term from a completely different project is accepted as long as one name uses an ID and the other a number. A foreign parent can likewise become a local skos:topConceptOf or skos_broader edge instead of dataplex:orphan_parent. A single project number can't be both project-a and project-b, yet the mapper accepts both:
import pytest
from bigquery_ontology import load_ontology_from_string
from bigquery_ontology.dataplex_glossary_importer import map_dataplex_glossary
def g(p): return f"projects/{p}/locations/us-central1/glossaries/retail"
@pytest.mark.parametrize("pid", ["project-a", "project-b"])
def test_unrelated_numeric_project_record_rejected(pid):
with pytest.raises(ValueError):
map_dataplex_glossary({"name": g(pid)}, [],
[{"name": g("123456789012") + "/terms/foreign", "parent": g("123456789012")}])
@pytest.mark.parametrize("pid", ["project-a", "project-b"])
def test_unrelated_numeric_parent_stays_orphan(pid):
foreign = g("123456789012") + "/categories/customer"
y, _ = map_dataplex_glossary({"name": g(pid)},
[{"name": g(pid) + "/categories/customer", "parent": g(pid)}],
[{"name": g(pid) + "/terms/churn", "parent": foreign}])
o = load_ontology_from_string(y)
assert o.relationships == []
assert next(e for e in o.entities if e.name == "term_churn").annotations["dataplex:orphan_parent"] == foreignBoth fail at this head. In the API path it's reachable too: import_dataplex_glossary swaps the requested name for the GetGlossary response name before checking scope, so a request by ID that comes back by number then admits records from any other project. Please make the pure mapper require exact project equality unless the caller supplies a verified ID↔number pair, and have the API layer establish that pair from the request/response (and validate the returned location and glossary ID before listing). Foreign records should still be rejected and foreign parents should stay orphans. test_an_id_and_a_number_are_one_project_but_two_of_a_kind_are_not currently locks in the broad rule, so it needs updating too.
Smaller things worth fixing here or in a follow-up:
- Partial list responses look like success.
list(pager)(around lines 830 and 838) drops each page'sunreachable_locations, so an import that lost a location still exits 0 with no warning. Iteratingpager.pagesand failing withDataplexImportErrorwhen it's non-empty would close that. - A failed
-ooverwrite destroys the previous file.Path.write_text(cli.py:1078) truncates first, so a mid-write failure leaves a partial file after acli-output-error. Writing to a temp file in the same directory and thenos.replaceavoids that. - Client-side
ValueErrors are reported as validation errors._call_apire-raises everyValueError, andrequests' JSON decode errors andgoogle.auth'sMalformedErrorare bothValueErrorsubclasses, so transport and credential failures come out asimport-validationinstead ofimport-api-error. - The hash-suffix loop can run out. Lengths 8-64 can all be taken by ordinary natural IDs (
a-b,a_b, plusa_b_<sha256("a-b")[:n]>for each n), which raisesRuntimeError. A deterministic counter fallback after the full digest would fix it, and the manual's "eight-character suffix" wording should mention that it can grow. --jsonstderr isn't always one JSON document. The success summary is printed before the output write, and the exit-3 handler prints plain text.- Smaller still: resource-name preflight accepts characters like
!in project and location segments, and the AST lazy-import test missesfrom google.cloud import dataplex_v1.
CI hasn't run yet: the fork workflows are waiting for maintainer approval.
Review follow-up for GoogleCloudPlatform#613. Project matching: - `map_dataplex_glossary()` now requires a record's project to equal the glossary's exactly. A project ID and a project number count as one project only when the caller passes the pair as the new `project_alias` argument. Records from another project, location or glossary still fail the import, and parents there stay orphans. - `import_dataplex_glossary()` checks that the GetGlossary response names the requested glossary (same location and glossary ID, and the same project or that project under its other form) before it lists anything, then passes the requested project as the verified `project_alias`. A response for another glossary fails with `import-validation` and nothing is listed. - A parent that names the glossary under the other, unverified form of its project stays an orphan and is counted on its own summary line. API results: - A list page that reports `unreachable_locations` now fails the import (`import-api-error`) instead of yielding a partial ontology. Pagers are read page by page. - Client-side `ValueError`s, such as JSON decoding errors and malformed credentials, are `import-api-error`, not `import-validation`. Names: - If the 8-hex-digit hash suffix is taken, it grows up to the full SHA-256 digest and then gains a `_2`, `_3`, ... counter, so naming cannot run out. It still does not depend on API order. CLI: - `-o` replaces a regular file atomically: the YAML goes to a temporary file in the same directory and `os.replace` moves it into place, so a failed write keeps the previous file. The file's permission bits are kept (a new file follows the umask), a symlinked destination keeps its link, and a read-only destination is refused. A destination that is not a regular file, such as `/dev/null` or a named pipe, is written directly. - The import summary is printed after the `-o` file is written, and an unexpected error (exit 3) is reported as one JSON document (`cli-internal-error`) with `--json`, so stderr holds exactly one JSON document on failure. - The resource-name check rejects characters such as `!` and `@` in the project and location segments. Project IDs (including domain-scoped ones such as `example.com:my-project`) and project numbers stay valid. Tests and docs: - Tests cover each case above, including a record and a parent in an unrelated project number, real GAPIC pagers, and the `-o` edge cases. The AST check for eager imports now also catches `from google.cloud import dataplex_v1`. - The user manual, docs/ontology/cli.md and CHANGELOG.md describe the new behavior. Part of GoogleCloudPlatform#612.
|
Thanks for the careful review. Everything in it is addressed in 98b8943. Project ID vs. number (blocking)
Smaller items
Verification (at 98b8943)
Caveats: no live Dataplex call was made, and only Python 3.13 was available locally (the changed files were checked statically for 3.10 syntax and API use). The The PR description is updated to match. The fork workflows still need maintainer approval to run. |
caohy1988
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. Most of the last round is fixed: exact project matching with verified aliases, foreign records and parents, unreachable pages, client ValueError mapping, the suffix counter, and the lazy-import guard all check out, and tests/bigquery_ontology plus tests/test_ontology_runtime.py pass locally (494 passed, 12 skipped). A few things still need changing before this goes in.
A nameless GetGlossary response still skips identity validation. canonical_name = _field(glossary, "name").strip() or glossary_name (dataplex_glossary_importer.py:1023) falls back to the requested name when the response is None, has no name, or has a blank or non-string one, so the project/location/glossary checks validate the request instead of the response and both list calls go ahead. Please require a non-empty string name and raise before listing when it's missing. test_blank_canonical_name_falls_back_to_the_requested_name locks in the fallback and will need to flip.
import pytest
from bigquery_ontology.dataplex_glossary_importer import import_dataplex_glossary
G = "projects/demo-project/locations/us-central1/glossaries/retail"
class Client:
def __init__(self, response): self.response, self.calls = response, []
def get_glossary(self, request=None, **kw):
self.calls.append("get"); return self.response
def list_glossary_categories(self, request=None, **kw):
self.calls.append("categories"); return iter(())
def list_glossary_terms(self, request=None, **kw):
self.calls.append("terms")
return iter(({"name": G + "/terms/churn", "parent": G, "display_name": "Churn"},))
@pytest.mark.parametrize("response", [None, {}, {"name": None}, {"name": ""}, {"name": " "}])
def test_missing_glossary_identity_is_rejected(response):
client = Client(response)
with pytest.raises(ValueError):
import_dataplex_glossary(G, glossary_client=client)
assert client.calls == ["get"]-o with a missing directory plus .. now overwrites the resolved file. A failed stat is treated as a new file (cli.py:965) and path.resolve() (cli.py:971) collapses missing/../retail.yaml to retail.yaml, so a path that can't actually be opened replaces an existing retail.yaml and exits 0. At 54df2f0 the file was kept and the command returned cli-output-error. Resolving the real parent strictly before creating the temp file (and doing the same when following a dangling symlink) would fix it.
Item-iterable list clients can lose a whole page. Any response with a pages attribute is now read page by page (dataplex_glossary_importer.py:915), and a page without a named categories/terms field contributes nothing (:932). A client that satisfies the iterable-of-items protocol but stores pages as plain lists loses all its categories, and the import succeeds with orphaned terms; this worked at the previous head. Please keep plain item iteration for non-GAPIC clients, or raise on a page shape you can't read rather than treating it as empty.
Smaller things, here or in a follow-up:
- An unexpected exception from
_write_text_atomicallyescapes the exit-3 /cli-internal-errorpath, since output handling only catchesOSError(cli.py:1158-1179). Stdout write failures and parser errors under--jsonalso still produce non-JSON stderr. unreachable_locations=[" "]is stripped to nothing before the presence check (:922), so a non-empty partial marker reads as a complete result.- Project preflight still accepts strings like
123abc,UPPER-project,demo-project-anda::b. - Writing to
/dev/fd/<n>backed by a regular file now takes the replace branch and fails; descriptor paths should be written through. - Creating a new output calls
os.umask(0)(cli.py:944), which briefly clears the mask for the whole process. - The test module docstring (
test_dataplex_glossary_importer.py:23-26) still says an ID and a number are one project.
Second review follow-up for GoogleCloudPlatform#613. GetGlossary: - A response without a usable resource name (None, no `name`, or a blank or non-string one) now fails with `import-validation` before anything is listed. It no longer falls back to the requested name, which made the project, location and glossary checks validate the request instead of the response. List results: - A list result is read item by item unless it is GAPIC-style: it exposes response fields itself, or its first page has the items field or `unreachable_locations`. Clients that iterate their items but keep `pages` as plain lists (or empty, or None) no longer lose them, and a one-shot `pages` iterator is read once. - A GAPIC-style result with a page that lacks its items field now fails with `import-api-error` instead of reading as empty. - Any `unreachable_locations` entry fails the import, including a blank one. -o destination: - The path is used as typed. Directories are resolved strictly, so `missing/../out.yaml` fails instead of replacing `out.yaml`, a path ending in `/` or `/.` names a directory, and a symlink, dangling or not, is followed to the file it names, as far as `open()` would follow it (40 links on Linux). - The temporary file is created exclusively (`O_CREAT|O_EXCL`) in the target's real directory and removed on any failure, an interrupt included. A new file gets 0o666 minus the umask from `open()`, so the process umask is no longer touched. - Descriptor paths such as `/dev/stdout`, `/dev/fd/<n>` and `/proc/self/fd/<n>` are written through, like other non-regular files, instead of being replaced. Output and exit codes: - An OSError while writing stdout or the `-o` file is a `cli-output-error` (exit 1). Any other error raised while writing is a `cli-internal-error` (exit 3, one JSON document with `--json`). - Argument-parsing errors keep the CLI framework's plain-text format under `--json`, as for every `gm` command; the CLI reference now says so. Resource names: - The glossary name check takes a project number or a lowercase project ID (letters, digits and hyphens, starting with a letter and not ending with a hyphen; legacy `example.com:my-project` stays valid) and a lowercase location. `123abc`, `UPPER-project`, `demo-project-` and `a::b` exit 2 before any API call. Tests and docs: - Tests cover each case above, including real GAPIC pagers (skipped when google-cloud-dataplex is not installed) and descriptor paths. The test module docstring now describes exact project matching. - The user manual, docs/ontology/cli.md and CHANGELOG.md describe the new behavior. Part of GoogleCloudPlatform#612.
|
Thanks for the second pass. The three blocking items and the smaller ones are addressed in 6ae0f61. Nameless
Item-iterable list clients (blocking)
Smaller items
Verification (at 6ae0f61)
Caveats: no live Dataplex call was made. Python 3.10, 3.11, 3.12 and 3.14 ran in minimal environments, not CI's full install, and the The PR description is updated to match. The fork workflows still need maintainer approval to run. |
caohy1988
left a comment
There was a problem hiding this comment.
Thanks for the thorough update! The earlier concerns (the nameless GetGlossary response, output path handling, page handling, and the project/location preflight checks) all look addressed, and the new tests cover them well. I noted a couple of smaller page-handling cases in a follow-up issue: #617
Summary
gm import-dataplex-glossary <glossary>, a read-only importer next togm import-owlthat turns a Knowledge Catalog (Dataplex) Business Glossary into anontology.yaml. The glossary becomes the root ontology and SKOS concept scheme, every category and term becomes an abstract entity, and category nesting becomes abstractskos_broaderrelationships.category_<id>/term_<id>), so the separate category and term ID spaces cannot collide. The raw ID is kept inskos:notationand the full resource name indataplex:resource.map_dataplex_glossary(), separate from the thin API wrapperimport_dataplex_glossary(). Output is canonical: re-importing an unchanged glossary gives byte-identical YAML and the samecompile_fingerprint, whatever order or repetition the API returns pages in.GetGlossaryanswered a request by one form with a name in the other, or because a Python caller passes it asproject_alias. AGetGlossaryresponse without a resource name, or for another glossary, fails before anything is listed.-oreplaces its file atomically.[dataplex]extra (google-cloud-dataplex>=2.12.0, also in[all]), imported only when the API is called.Part of #612.
Motivation
#612 asks for a way to bring an existing Knowledge Catalog Business Glossary into the ontology tooling. The review on that issue suggested a focused first PR for the glossary, categories, terms, labels and hierarchy, with the mapping separated from the API calls and fake-client tests that shuffle and repeat pages, and links and definitions as a later change. This is that first PR. How each review point is handled:
lookup_entry_linksneedsgoogle-cloud-dataplex>=2.17.0; 2.12.0+ is enough for glossary, category and term reads>=2.12.0and no link lookup is used. The tests ran against 2.12.0 (the floor) and 2.22.0.gm compileorOntologyRuntimeon its own, and an entity-less binding yields aCREATE PROPERTY GRAPHwith no node tables--emit-concept-index --concept-index-table, and dropping the bareCREATE PROPERTY GRAPH <ontology>;header. The header itself is unchanged by this PR.import-owldoes not sanitize names (a collision is an error) and leaves out hierarchy edges whose other end it did not import, so sanitizing, renaming and orphan-parent reporting are new behavior[A-Za-z0-9_]; collisions between resources of the same kind get an order-independent hash suffix (and a deterministic counter if the suffix is taken at every length); the raw ID stays inskos:notation. A category and a term that normalize alike have their own test (see Changes).map_dataplex_glossary()does no I/O. The tests shuffle and repeat pages and compare the YAML andcompile_fingerprint.Changes
Importer:
src/bigquery_ontology/dataplex_glossary_importer.py(new)map_dataplex_glossary(glossary, categories, terms, *, ontology_name=None, project_alias=None)returns(yaml_text, summary). It acceptsgoogle-cloud-dataplexmessages or any object or dict with the same fields, and does no network I/O and no SDK import.project_aliasis the glossary's project under its other form (ID or number) for callers that have verified the pair; without it, the project must match exactly. A different project of the same form (two IDs, or two numbers) is aValueError.import_dataplex_glossary(glossary_name, *, ontology_name=None, glossary_client=None)callsGetGlossaryand checks that the response names the requested glossary before it lists anything: the response must carry a resource name (a missing, blank or non-stringnameis rejected, with no fallback to the requested name), with the same location and glossary ID, and the same project or that project under its other form. It then lists all categories and terms (all pages) under the glossary's canonical name, with the requested project asproject_aliaswhen the response used the other form, and hands them to the mapper.pagesattribute) is read item by item, and a one-shotpagesiterator is read once, so no item is lost or read twice. A result that exposes response fields, as a GAPIC pager does, or whose first page is aList...Response, is read page by page as responses. A page that reportsunreachable_locations(even a blank entry), or a response page without itscategoriesortermsfield, fails the import instead of returning a partial ontology.ValueErrors such as JSON decode errors) and client-construction failures becomeDataplexImportError.ontology(the glossary ID, or--ontology-name) withdescriptionanddataplex:glossary/dataplex:uidannotations.description,skos:prefLabel(display name),skos:notation(raw ID),dataplex:resource(resource name) andskos:inScheme.skos:topConceptOf. Parent is a category of the glossary: an abstractskos_broaderrelationship. Any other parent (an unknown category, another glossary or project, the category itself):dataplex:orphan_parent, counted in the summary. A parent that names the glossary under the other, unverified form of its project is an orphan too, and is counted on its own summary line.category_<id>/term_<id>, with every character outside[A-Za-z0-9_]replaced by_. Resources of the same kind whose names still collide each get a_<sha256(raw id)[:8]>suffix. If that name is taken, the suffix grows one hex digit at a time up to the full digest, and then a_2,_3, … counter is appended. Names never depend on API order, and a suffix never takes another resource's natural name.GetGlossaryresponse without a resource name or for another glossary (nothing is listed); and a list page with unreachable locations or without its items. A parent in another project is not a failure; it becomes an orphan.display_name, the Dataplex resourcelabels, timestamps, per-recorduid, and the glossary's counts andetag.CLI:
src/bigquery_ontology/cli.pygm import-dataplex-glossary <glossary> [--ontology-name NAME] [-o/--out FILE] [--json]. The glossary must beprojects/<project>/locations/<location>/glossaries/<id>, where the project is a project number or a lowercase project ID (letters, digits and hyphens, starting with a letter and not ending with a hyphen; legacy domain-scoped IDs such asexample.com:my-projectincluded) and the location is a lowercase name such asus-central1orglobal. Anything else, such as123abc,UPPER-project,demo-project-ora::b, exits 2 (cli-usage) before any API call. The summary goes to stderr once the YAML has been written.-owrites a regular file, new or existing, through a temporary file (.gm-import-<random>.tmp) that is created exclusively in the file's real directory and moved into place withos.replace. A failed write or an interrupt leaves an existing file untouched and no temporary file behind.missing/../out.yamlfails instead of replacingout.yaml, a path ending in/or/.names a directory, and a symlink, dangling or not, is followed to the file it names (a dangling chain is followed as far asopen()would follow it: 40 links on Linux).0o666minus the umask. The process umask is not changed.cli-output-error). Descriptor paths (/dev/stdout,/dev/fd/<n>,/proc/self/fd/<n>, ...) and other non-regular files (/dev/null, a named pipe) are written directly.cli-usageandcli-missing-dependency(extra not installed); 1 forimport-validation(including aGetGlossaryresponse without a resource name or for another glossary),import-api-error(including client-side decoding errors, unreachable locations and unreadable pages) andcli-output-error(anOSErrorwhile writing stdout or the-ofile); 3 for an unexpected internal error, including one raised while writing the output. On failure,--jsonleaves exactly one JSON document on stderr, including for exit 3 (cli-internal-error). Argument-parsing errors (a missing<glossary>or option value) are reported by the CLI framework in plain text, as for everygmcommand. Existing commands are unchanged.Packaging:
pyproject.tomlgets adataplexextra, included inall.Docs:
docs/ontology/cli.md(new section 7; the old sections 7 and 8 become 8 and 9), the index row indocs/README.md, a new user-manual section (prerequisites, mapping table, naming and collision table, the glossary-to-concept-index walkthrough, and the differences fromimport-owl), andCHANGELOG.md.Tests:
tests/bigquery_ontology/test_dataplex_glossary_importer.py(new, 206 tests) and 103 new cases intests/bigquery_ontology/test_cli.py. They use synthetic glossaries and fake clients only, apart from two tests that build realgoogle-cloud-dataplexmessages and pagers and are skipped unless the SDK is installed. A few CLI tests start a child Python process (a broken stdout pipe, and the/dev/stdout,/dev/stderrand/dev/stdinpaths); the descriptor tests skip where/dev/fd,/procor/dev/<stream>don't exist. Highlights:test_shuffled_and_repeated_pages_give_byte_identical_output: identical YAML,compile_fingerprintand concept-index SQL across shuffled and repeated pages.test_category_and_term_normalizing_alike_never_collide,test_same_kind_collisions_get_order_independent_hash_suffixes,test_hash_suffixes_never_steal_a_natural_nameandtest_hash_suffix_falls_back_to_a_counter_when_every_length_is_taken.test_projects_match_exactly_unless_a_verified_alias_is_given,test_record_in_an_unrelated_project_number_is_rejected,test_parent_in_an_unrelated_project_number_stays_an_orphan, thetest_project_alias_*tests,test_import_pairs_the_requested_id_with_the_returned_number,test_import_rejects_records_from_a_third_project,test_mismatched_get_glossary_response_is_rejected_before_listingandtest_nameless_get_glossary_response_is_rejected_before_listing.test_item_iterable_results_with_plain_pages_are_read_item_by_item,test_single_use_item_pages_are_read_once_without_losing_items,test_unreadable_pages_fail_instead_of_reading_as_empty,test_real_gapic_pagers_are_read_page_by_page,test_unreachable_locations_on_any_page_fail_the_import,test_blank_unreachable_location_markers_still_fail_the_importandtest_value_errors_from_the_client_are_api_errors.-o: a failed overwrite keeps the previous file; the file mode, umask and symlinks are kept; a read-only file and a directory are refused;/dev/null, a named pipe and descriptor paths (/dev/fd/<n>,/proc/self/fd/<n>,/dev/stdout, ...) are written through;missing/../out.yaml, a dangling link through a missing directory, a trailing/or/., a symlink loop and-o ""are output errors that leave existing files alone; a dangling symlink chain of 40 links creates its target (this case runs on Linux only) and one of 41 is an output error; the temporary file never reuses a taken name, is staged beside a symlink's target and is removed after an interrupt; the process umask is left alone.test_import_dataplex_glossary_bad_project_or_location_is_usage_errorandtest_domain_scoped_projects_and_standard_locations_are_accepted.--json: one JSON document on stderr for output-write errors (cli-output-error), unexpected errors while writing or importing (cli-internal-error), and a broken stdout pipe.build_rows,compile_concept_index,OntologyRuntimeandLabelSynonymResolver.test_module_never_imports_google_cloud_dataplex_eagerly(an AST check that also catchesfrom google.cloud import dataplex_v1, with its own self-test) andtest_real_dataplex_messages_are_supported.Verification
All inputs are synthetic glossaries and fake clients. Nothing in the tests, and nothing run for this PR, calls Google Cloud.
rdflibtests forimport-owl, 2 real-SDK tests)google-cloud-dataplex2.12.0 (the floor)google-cloud-dataplex2.22.0 (latest)tests/bigquery_ontologyandtests/test_ontology_runtime.py(no extras), on each of those Python versionsPYTHONHASHSEEDs>=24.3.0,<26pin)git diff --checkcleanThe 17 whole-suite failures are all in
tests/test_power_bi_dashboard.py(node binary required for the configurator.mjs tests; Node.js is not installed here), and they are the same 17 tests on an unmodifiedupstream/mainexport.Ad-hoc checks, not part of the PR:
gmCLI app: import with-o,gm validate, an entity-less binding,gm compile --emit-concept-index --concept-index-table ..., thenOntologyRuntime. The documentedterm_clvsnippet matches the generated YAML, and the bareCREATE PROPERTY GRAPH retail;header and twoCREATE OR REPLACE TABLEstatements appear as described.GetGlossaryresponses (None,{}, and anameofNone,""or" "),-o missing/../retail.yamlover an existingretail.yaml, and an item-iterable list client whosepagesare plain lists.GetGlossaryname check, project matching and list reading) and of the CLI (preflight, exit codes and the-owriter) were each caught by the importer and CLI tests. They included ignoring a blankunreachable_locationsentry, reading a page without its items field as empty, droppingO_EXCLor the retry on a taken temporary name, staging the temporary file beside a link instead of beside its target, keeping the temporary file after an interrupt, treating/proc/self/fd/<n>or/dev/stdoutas ordinary files, and stopping a dangling symlink chain one link early. Three more changed no observable behavior (the symlink probes and the differential check below give identical results with and without them): two allow a 41st link, whichos.stathas already refused by then, and one drops a./..check that the directory-name test makes unreachable.-owriter againstopen(path, "w")over about 7,500 generated layouts and paths (missing and dangling-link directories,.., a trailing/or/., symlink loops, read-only files, directories) ran on each of Python 3.10 to 3.14 on Linux: the outcome and the resulting files were the same in every case. In 111 cases both fail, with a different errno (for exampleEISDIRfromopen()andENOTDIRorELOOPhere).open(path, "w")on Linux with Python 3.10 to 3.14: up to 40 links resolve and 41 fail withELOOP.pytest-xdistrun (-n 8) of both modules, andpython -X devwithResourceWarningas an error.pip install --dry-runof the[all]requirement list, with and withoutgoogle-cloud-dataplex>=2.12.0, resolves to the sameprotobuf,google-api-core,grpcioandproto-plusversions.Not verified:
get_glossary,list_glossary_categoriesandlist_glossary_termswith arequestdict, pager iteration throughpages) is checked against fake clients and against the real 2.12.0 and 2.22.0 client signatures, message types and pagers, not against the service. Theroles/dataplex.catalogViewerstatement in the docs comes from the public IAM documentation..[dev,streamlit]install (the same way therdflibtests skip). They were run by hand on 2.12.0 and 2.22.0 on each Python version.-otests and the differential check ran on Linux only.-ois a new file: hard links and open handles keep the old content, owner and ACLs are not carried over, and the destination directory must be writable even when the file itself is.gm import-owl -ois unchanged.MagicMock, for example) and also has an explicit plainpagesattribute is read as GAPIC-style and fails loudly, not silently.plotlyandstreamlitare not installed here, andtests/test_looker_studio_dashboard.pyneeds a headless Chrome and hung); none of them importsbigquery_ontology. Therdflibtests, includingtest_owl_importer.py, were skipped locally; this PR does not changeimport-owl.