Skip to content

Remove redundant config re-resolution in doctor diagnostics#38

Open
nicoloesch wants to merge 3 commits into
mainfrom
remove-redundant-config
Open

Remove redundant config re-resolution in doctor diagnostics#38
nicoloesch wants to merge 3 commits into
mainfrom
remove-redundant-config

Conversation

@nicoloesch

Copy link
Copy Markdown
Collaborator

Summary

collect_doctor_report() was calling get_cdm_context() a second time even though collect_maintenance_info() (called immediately before it) already resolves the same config. This results in three independent config reads for one doctor CLI invocation once the @omop_command decorator's own resolution is counted.

Now threads the already-resolved result through instead of re-reading. collect_maintenance_info()'s own independent resolution is intentionally left as-is (it's a diagnostic health-check whose job is to test config resolution fresh, not a case of "caller already has it") . Its broad except Exception around that resolution is narrowed to avoid mislabeling unrelated bugs as a generic engine-resolution error.

@nicoloesch nicoloesch added the fix Bug fix, backwards-compatible. PATCH: x.y.z+1 label Jul 22, 2026
@nicoloesch
nicoloesch requested a review from gkennos July 22, 2026 23:19
@nicoloesch

Copy link
Copy Markdown
Collaborator Author

Removing the Liskov Substitution Principle fix that got picked up by ty>=0.0.62 as privately discussed. The respective bug is now reported here:
#41

Pinning ty to 0.0.61 to pass the static typing check.

Already-resolved CDM engine (from the ``@omop_command`` decorator),
reused for the deep checks below instead of re-resolving config.
"""
info = collect_maintenance_info(vocabulary_included=vocabulary_included)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the call here still has unbounded except within collect_maintenance_info - noted since the PR is aiming to clean up the broad exceptions here

maybe (in cli_schema_info.py)

except (FileNotFoundError, ValueError, ValidationError, KeyError) as exc:
    engine_error = f"Could not resolve engine configuration: {exc}"

else:
    try:
        engine = create_cdm_engine(resolved)
        engine_created = True
    except RuntimeError as exc:
        engine_error = str(exc)


def collect_doctor_report(
*,
engine: sa.engine.Engine,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this API change makes it technically breaking - shouldn't matter if this is being absorbed into the intended 2.0 upversion anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix, backwards-compatible. PATCH: x.y.z+1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants