Skip to content

feat(discover): match unscoped tags against dir-prefixed model short names#159

Merged
coketaste merged 1 commit into
developfrom
coketaste/discover-per-directiory-model
Jul 15, 2026
Merged

feat(discover): match unscoped tags against dir-prefixed model short names#159
coketaste merged 1 commit into
developfrom
coketaste/discover-per-directiory-model

Conversation

@coketaste

Copy link
Copy Markdown
Collaborator

Summary

  • Per-directory models.json files prefix each model name with their directory
    (e.g. pyt_foo becomes dir/pyt_foo). This silently broke --tags pyt_foo for
    users who referenced models by their original flat name, since the exact-name
    match would no longer find them and no error was raised to explain why.
  • select_models() now also falls back to matching the model's short name (the
    part after the last /) for unscoped tags, for both models.json-defined
    models and custom models from get_models_json.py. This is purely additive —
    scoped tags (scope/tag), tag-field matching, and flat (non-prefixed) model
    names are all unaffected.
  • Added TestShortNameBackwardCompat covering: short-name resolution of a
    dir-prefixed model, flat names still working, short-name resolution for custom
    models, and scoped tags being unaffected by the new short-name fallback.
  • Updated test_unscoped_tag_does_not_cross_scope_boundary (now
    test_unscoped_tag_matches_scoped_model_by_short_name), which previously
    asserted the old (pre-fix) behavior that unscoped tags could not cross scope
    boundaries — that assumption is exactly what this change intentionally
    relaxes for backward compatibility.
  • Added test_ambiguous_short_name_matches_both_flat_and_prefixed_model to pin
    down current behavior for the edge case where both a flat model (foo) and a
    dir-prefixed model (dir/foo) share the same short name — today both are
    selected, since there's no precedence between an exact match and a
    short-name match.

Test plan

  • pytest tests/unit/test_discover_models.py -v — all 18 tests pass

…names

Per-directory models.json prefixes model names with their directory
(e.g. pyt_foo becomes dir/pyt_foo), which silently broke --tags pyt_foo
for users referencing models by their original flat name. Fall back to
matching the short name (the part after the last '/') for unscoped tags
so existing --tags invocations keep working after the migration.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coketaste coketaste self-assigned this Jul 15, 2026
Copilot AI review requested due to automatic review settings July 15, 2026 22:00

Copilot AI 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.

Pull request overview

This PR restores backward compatibility for DiscoverModels.select_models() when per-directory models.json introduces directory-prefixed model names (e.g., dir/pyt_foo), by allowing unscoped --tags <name> inputs to also match a model’s short name (the segment after the last /). It also adds/updates unit tests to lock in the intended behavior, including scoped-tag behavior remaining unchanged.

Changes:

  • Extend unscoped name-based model selection to also match model["name"].split("/")[-1] (and the equivalent for CustomModel.name).
  • Update an existing unit test to reflect the new backward-compat behavior for unscoped tags matching scoped models by short name.
  • Add a new test suite covering dir-prefixed models, flat names, custom models, scoped tags, and ambiguous short-name scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/madengine/utils/discover_models.py Adds short-name fallback matching for unscoped --tags against both models.json models and CustomModels.
tests/unit/test_discover_models.py Updates/expands unit tests to validate short-name backward compatibility and preserve scoped-tag semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coketaste
coketaste merged commit 2c55818 into develop Jul 15, 2026
1 check passed
coketaste added a commit that referenced this pull request Jul 16, 2026
Summarizes the develop-vs-main delta: amd-smi path resolution fix,
unscoped tag matching for dir-prefixed model names, and corrected
directory-scoped tag examples in the docs.
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.

2 participants