Skip to content

refactor(cql): remove dead normalize() family from loader.py - #879

Open
mattmillerai wants to merge 1 commit into
mainfrom
matt/be-4365-remove-dead-normalize
Open

mattmillerai wants to merge 1 commit into
mainfrom
matt/be-4365-remove-dead-normalize

Conversation

@mattmillerai

Copy link
Copy Markdown
Collaborator

ELI-5

There was a chunk of code in loader.py called normalize() (plus five helper
functions) whose whole job was to reshape different graph formats into one
common shape. A recent change removed the only real feature that used it, so now
nothing in the app calls it anymore — the only things keeping it "alive" were its
own tests. This PR deletes that dead code and its test file so the module is
smaller and only does the one job it still has: fetching and caching the node
catalog (object_info) resiliently.

What changed

  • comfy_cli/cql/loader.py — deleted normalize and its helpers
    (_looks_like_object_info, _looks_like_api_workflow, _from_object_info,
    _normalize_input, _from_api_workflow) and the # ---- normalization ----
    divider. Dropped the now-unused CQLRuntimeError import (it was raised only
    inside normalize; the resilient path catches LoadError, imported locally).
    Rewrote the module docstring so it describes only the resilient
    object_info cache/fetch wrapper that remains.
  • tests/comfy_cli/cql/test_loader.py — deleted entirely; all five tests
    exercised normalize, and its OBJECT_INFO / API_WORKFLOW fixtures were
    local to the file (no other test imports them).

normalize was module-public but was never exported in cql.__all__ and
never advertised, so this removes no documented API.

Why this is safe (dead-code verification)

Run before deleting:

  • grep -rn "normalize" --include='*.py' comfy_cli/ — the only cql/ hits were
    loader.py's own definitions. Every other hit is an unrelated symbol
    (file_utils._normalize_path, billing.normalize_plans,
    workflow_to_api._normalize_combo_values, cm_cli_util.normalize_cm_cli_exit_code,
    etc.) that never calls loader.normalize.
  • No production import of normalize or any of its helpers anywhere in the tree;
    the only importer was tests/comfy_cli/cql/test_loader.py (deleted). The engine
    builds its Graph from raw object_info directly and never touches this module's
    reshaping code; the only symbol the rest of the package imports from loader.py
    is resilient_load_object_info.

After deleting: grep -rnE "normalize\b" --include='*.py' comfy_cli/cql/zero hits.

Verification

  • ruff check . — passes (confirms no import became unused; time is retained
    because the resilient cache path still uses it).
  • ruff format --check . — passes.
  • pytest full suite — 7548 passed, 38 skipped, 4 failed. All 4 failures are
    pre-existing and environment-dependent, unrelated to this change (confirmed by
    reproducing them identically on a clean checkout of the base branch): two umask
    default-mode assertions in test_file_utils.py, one packaging-version-parsing
    assertion in test_node_deps.py, and one console-line-wrap wording assertion in
    test_logs.py. None touch cql/loader/normalize.
  • pytest tests/comfy_cli/cql/ in isolation — 517 passed.

Residual

  • Optional rename not done (ticket item 4): the plan offered renaming
    test_loader_resilient.pytest_loader.py "for tidiness (optional; skip if
    it churns the diff)." Skipped to keep this diff a clean pure-deletion; the
    resilient/TTL tests keep their current filenames. A follow-up could do the
    rename if a reviewer prefers it.
  • Pre-existing full-suite failures (not in scope, not introduced here): the 4
    environment-dependent test failures listed above already fail on the base branch
    in this environment. They are unrelated to this change and left untouched; worth
    their own look if the CI environment hits the same umask/packaging/console-width
    conditions.

Provenance

  • Authored by: agent-work loop
  • Verified: ruff check ., ruff format --check ., and pytest (full suite +
    isolated cql/ run) as described above; dead-code claim verified by the greps
    above plus an __all__ check.
  • Deviations: skipped the optional test-file rename (ticket item 4) to keep the
    diff a pure deletion — noted under Residual.

The load_graph removal left loader.py's normalize() and its helpers
(_looks_like_object_info, _looks_like_api_workflow, _from_object_info,
_normalize_input, _from_api_workflow) reachable only from their own tests.
No production code calls normalize: the engine builds its Graph from raw
object_info directly, resilient_load_object_info is the only symbol the rest
of the package imports from this module, and normalize was never in
cql.__all__.

Delete the normalize family and the now-unused CQLRuntimeError import,
rewrite the module docstring to describe only the resilient object_info
cache/fetch wrapper that remains, and delete tests/comfy_cli/cql/test_loader.py
(every test in it exercised normalize).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 7f6dc564-ebfa-43cf-b622-d383d9824bc2

📥 Commits

Reviewing files that changed from the base of the PR and between fdd966b and 32b685d.

📒 Files selected for processing (2)
  • comfy_cli/cql/loader.py
  • tests/comfy_cli/cql/test_loader.py
💤 Files with no reviewable changes (1)
  • tests/comfy_cli/cql/test_loader.py

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The loader now provides resilient loading without graph normalization. The normalize API, conversion helpers, related import, documentation, and dedicated tests were removed.

Changes

Loader normalization removal

Layer / File(s) Summary
Remove normalization support
comfy_cli/cql/loader.py, tests/comfy_cli/cql/test_loader.py
The loader retains resilient loading and removes normalize, its object-info and API-workflow conversion helpers, and the related test module.

Suggested reviewers: skishore23

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 32b68

The change removes unused normalization code and its dedicated tests; no current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch matt/be-4365-remove-dead-normalize
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch matt/be-4365-remove-dead-normalize

Comment @coderabbitai help to get the list of available commands.

@mattmillerai mattmillerai added agent-coded PR authored by the agent-work loop cursor-review Request Cursor bot review labels Sep 16, 2026
@coderabbitai
coderabbitai Bot requested a review from skishore23 September 16, 2026 05:45

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Cursor Review — Consolidated panel

Triggered by @mattmillerai.

Found 1 finding(s).

Severity Count
⚪ Nit 1

Panel: 6/6 reviewers contributed findings.

Comment thread comfy_cli/cql/loader.py
This module is the resilient object_info cache/fetch wrapper.
``resilient_load_object_info`` wraps the engine's loaders
(``comfy_cli.cql.engine._load_from_file`` / ``_load_from_target``) with a
cache-first TTL gate, auto-caches every successful fetch per host, retries

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit — The new docstring describes the wrapper as applying a "cache-first TTL gate" unconditionally, but resilient_load_object_info only consults read_fresh_object_info_cache when mode == "cloud"; local targets always fetch live. Qualifying this as cloud-only avoids a future change "fixing" local to match the docstring and hiding newly installed custom nodes for the TTL window. Raised by 1 of 6 reviewers (claude-opus-5-thinking-max edge-case).

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

Labels

agent-coded PR authored by the agent-work loop cursor-review Request Cursor bot review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant