Resolve model engine names through the shared registry (item 5, step 2) - #164
Merged
Conversation
Item 5, step 2 -- the two collapsible lists of the three. Non-breaking:
`available_models()` returns the same six names in the same order, and
`_adapters` was private.
Three parallel lists of engine names existed, holding *different* sets:
ModelFactory._adapters 2 -- ANI2X, ANI2XT only
ModelFactory.available_models() 6 -- a hand-written literal, derived from nothing
ENGINE_INFO (cli/commands) 6 -- AIMNET, three aimnet variants, two ANI
`_adapters` held only the engines built from a local adapter class; the four
aimnet entries are names resolved through the aimnet registry, not adapters. So
one list was keyed by "has a local adapter" and two by "user-facing name", and
nothing connected them.
`_engines` is now the one registry, keyed by user-facing name, with the adapter
class as the value where there is one and `None` where the name is resolved
through the aimnet registry. `available_models()` derives from it rather than
restating it -- adding an engine and forgetting that list used to leave it
working but undiscoverable.
The import-time `assert set(_adapters) == set(BUILTIN_ANI_MODELS)` survives, now
derived from the registry so the two cannot drift. It moved to module scope
because a comprehension inside a class body cannot see that class's own
attributes -- a scoping rule, not a style choice.
`ENGINE_INFO` is deliberately still separate. Moving it into `info=` belongs
with the CLI's changes rather than this factory's, and it is the remaining piece
of item 5. Naming it here so the third list is not mistaken for handled.
Suite: 1756 passed, 1 skipped, 70 deselected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Non-breaking.
available_models()returns the same six names in the same order,and
_adapterswas private. Suite: 1756 passed, 1 skipped, 70 deselected.Three lists holding different sets
ModelFactory._adaptersANI2X,ANI2XTonlyModelFactory.available_models()ENGINE_INFO(cli/commands/models.py)AIMNET, three aimnet variants, two ANI_adaptersheld only engines built from a local adapter class. The fouraimnet entries are not adapters at all — they are names resolved through the
aimnet registry. So one list was keyed by "has a local adapter" and two by
"user-facing name", and nothing connected them; they agreed by hand.
This is the finding recorded in #162's body, and it is why step 2 was the larger
half.
What changed
_enginesis one registry keyed by user-facing name, with the adapter class asthe value where there is one and
Nonewhere the name resolves through theaimnet registry.
available_models()derives from it instead of restating it —adding an engine and forgetting that literal used to leave it working but
undiscoverable.
The import-time
assert set(_adapters) == set(BUILTIN_ANI_MODELS)survives andis now derived from the registry, so the two cannot drift. It moved to module
scope because a comprehension inside a class body cannot see that class's own
attributes — a Python scoping rule, found by it raising
NameErroron import,not a style preference.
ENGINE_INFOis deliberately still separateMoving it into
info=belongs with the CLI's changes rather than this factory's.It is the remaining piece of item 5, and it is named here so the third list is
not mistaken for handled.