Skip to content

feat(overview-metrics): asset_composition routine (subtype tree, two count scopes) - #534

Merged
dwolfson merged 1 commit into
odpi:mainfrom
dwolfson:feat/asset-composition-routine
Nov 7, 2026
Merged

dwolfson merged 1 commit into
odpi:mainfrom
dwolfson:feat/asset-composition-routine

Conversation

@dwolfson

@dwolfson dwolfson commented Nov 7, 2026

Copy link
Copy Markdown
Member

Summary

RS-W1-4 PR-A: the asset_composition routine in pyegeria/view/overview_metrics.py, registered in analytic_registry.py with an AnalyticDeclaration. PR-B (egeria-workspaces, the Overview endpoint and histogram) waits for a release that contains this.

  • asset_subtype_tree(vm, root="Asset", depth=2) walks the tree breadth-first with ValidMetadataManager.get_sub_types, one call per expanded node. The root is level 0. A null result means "no subtypes". A call that raises sets subtypes_error on the node, and that node gets no other row. After each parent's children comes an other row: type_name = parent, exact_type = True, at the children's level.
  • asset_composition(mgr, vm=None, root="Asset", depth=2, as_of=None, scopes=("viewer", "repository"), concurrency=3, strict=True) counts each distinct type once per scope with count_elements(mgr, t, as_of, strict=True, scope=s). All counts in both scopes run in one ThreadPoolExecutor(max_workers=concurrency), so the cap applies to everything in flight. The default is 3. Anything above 5 is lowered to 5, because Egeria's database pool is 10 connections. strict=False is refused.
  • Settled points: a 0 is nothing_found. A failure (None or an exception) is not_measured with the failure's words in reason, and is never 0. An other cell is parent − sum(children), but only when the parent and every child are established in that scope. Otherwise it is not_measured with "a child count is missing" (or "the parent count is missing"). not_visible needs both scopes established. If only one scope was requested, it is not_measured with "needs both scopes". A negative difference is also not_measured, never shown as a number.
  • Population word: each cell carries population (viewer | repository), the owner's choice for RS-W1-1 §5. The routine's keyword stays scopes=, and count_elements keeps scope=.
  • Absence sentences use measured_nothing, because RS-W1-1 PR-2 (the nothing_found rename in the declaration) has not landed. pyegeria's AbsenceSentences still requires that field.
  • vm is optional and defaults to mgr. An EgeriaTech serves both. The report-spec executor binds only clients named mgr/ce/expert/client, so a required vm could not be run from a report spec.
  • The docstring names the stages in §10.8's words: a typedefs producer, two per-row derives (viewer count, repository count) and a difference. Today it is one opaque routine.

Cell shape (CompositionCell)

{"value": int | None, "state": "measured" | "nothing_found" | "not_measured",
 "completeness": "complete" (repository) | "unknown" (viewer, or any not_measured cell),
 "as_of": <requested as_of, else run time>, "population": "viewer" | "repository",
 "reason": str, "elapsed_s": float | None (None on a derived `other` cell)}

Result shape (AssetComposition, TypedDicts in overview_metrics)

{state: measured | nothing_found | not_established, state_reason: "not measured: Process/viewer, ..." + tree errors,
 root, depth, scopes, as_of, concurrency,
 rows: [{type_name, parent, level, exact_type, subtypes_error, viewer?, repository?,
         not_visible: {value, state, reason}}],
 not_measured: ["<type>/<population>", ...],
 provenance: {pyegeria_version, platform, server, run_at, as_of_requested, elapsed_s}}

The envelope is measured when any cell is measured. It is nothing_found when every established cell is 0, and not_established otherwise. state/state_reason are the keys format_set_executor._result_envelope reads.

Declaration

result_kind: distribution
measures (unit "elements", as_of "as_of"):
  repository_count  value_field rows.repository.value
  viewer_count      value_field rows.viewer.value
  not_visible       value_field rows.not_visible.value
absence:
  not_measured:     The subtype counts could not be measured: the count queries failed or the server could not answer them.
  not_permitted:    You are not permitted to count these elements.
  not_applicable:   A subtype composition does not apply to this type.
  measured_nothing: Counted: there are no elements of this type or its subtypes.

pyegeria's AnalyticDeclaration has no out-shape field. The declared out shape is therefore the AssetComposition / AssetCompositionRow / CompositionCell TypedDicts, and the spec's returns names them. This is the first built-in that carries a declaration, so test_existing_specs_load_without_a_declaration now exempts the declared built-ins and checks they really declare one.

Tests

  • 14 new tests in tests/micro-tests/test_overview_metrics.py use a fake vm with a three-level tree and a fake counter that fails one type in one scope and raises on another. They cover:
    • breadth-first order and other rows, depth 3, and skipping non-direct subtypes;
    • a failed subtype call;
    • cell shape and completeness per scope;
    • 0 → nothing_found;
    • failure → not_measured with the exception's words, and the effect on other and not_visible;
    • the all-failed envelope, and a single scope;
    • pool size, counting peak concurrent calls across both scopes: 1/2/3/5, and 12 lowered to 5;
    • default 3, as_of passthrough, vm defaulting to mgr, and bad arguments;
    • the real count seam's push_down per scope;
    • the registry declaration.
  • pytest tests/micro-tests: 1835 collected, 0 failed.

Live check (read-only, local platform, repository scope only, depth 2)

wall 0.91 s, concurrency 3, state measured, nothing not measured
Asset: 61315
  DataAsset: 2997 · Infrastructure: 210 · Process: 58102 · RunnableSoftwareComponent: 0 nothing_found · Asset (other): 6
    DataFeed 7 · DataSet 2471 · DataStore 519 · DataAsset (other) 0 nothing_found
    Equipment 58 · ITInfrastructure 152 · Infrastructure (other) 0 nothing_found
    Action 57614 · DeployedSoftwareComponent 486 · Process (other) 2

Level 1 plus other adds up to the Asset total (2,997 + 210 + 58,102 + 0 + 6 = 61,315). Viewer scope was not run live; the viewer Process count takes about 120 s.

No release, version bump or tag in this PR.

🤖 Generated with Claude Code

…nd two count scopes

Adds asset_subtype_tree() and asset_composition() to pyegeria.view.overview_metrics
(RS-W1-4 PR-A): the subtype tree under a root (default Asset) to a depth, each
type counted in viewer and/or repository scope, an `other` row per parent, and
not_visible = repository - viewer. All counts in both scopes share one
ThreadPoolExecutor (default 3 workers, hard cap 5, below Egeria's pool of 10).
A 0 is nothing_found; a failed count is not_measured with its reason, never 0.
Each cell names its population under `population` (viewer | repository).

Registered as `asset_composition` with the first built-in AnalyticDeclaration
(distribution; repository_count, viewer_count, not_visible in elements). The
absence sentences use measured_nothing, because RS-W1-1 PR-2 has not landed.

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
@dwolfson
dwolfson merged commit 9243060 into odpi:main Nov 7, 2026
6 checks passed
dwolfson added a commit that referenced this pull request Nov 7, 2026
Ships #534 (asset_composition routine: Asset subtype tree with viewer and
repository counts) and #535 (absence word nothing_found; legacy
measured_nothing still read).

Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com>
@dwolfson
dwolfson deleted the feat/asset-composition-routine branch November 20, 2026 19:14
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