Repository navigation
feat(adapters): name the unsupported technology in adapter not-found errors - #1843
Conversation
…errors Resolving a Granite Switch slot whose technology Mellea skips (e.g. 'sr') raised a bare 'No adapter found' ValueError; the reason was only in an earlier log warning. An index where every slot was skipped read as empty. Discovery now records each skipped slot's reason and includes it in the error, and the Hub path restates it against the repo ID. Closes generative-computing#1837 Assisted-by: Claude Code Signed-off-by: Nigel Jones <[email protected]>
ajbozarth
left a comment
There was a problem hiding this comment.
Some feedback from Claude: looks good, one optional nit inline.
Co-authored-by: Alex Bozarth <[email protected]> Signed-off-by: Nigel Jones <[email protected]>
| } | ||
| (tmp_path / "adapter_index.json").write_text(json.dumps(index)) | ||
| with pytest.raises( | ||
| ValueError, match="no adapter function has a supported technology" |
There was a problem hiding this comment.
Must-fix. This test fails on the PR head. The match regex expects the phrase "no adapter function has a supported technology", but _NoEmbeddedAdaptersError produces:
No adapters found in <path>; skipped unsupported entries: 'slot_a': technology 'sr' is not supported (supported: ['alora', 'lora', 'probe']); 'slot_b': ...
Verified locally: uv run pytest test/backends/test_adapters/test_embedded_adapter.py on the PR branch fails here with AssertionError: Regex pattern did not match (main passes all 54 tests in this file; the only other failures in a fresh checkout were missing extras and disappear after uv sync --all-extras --all-groups). The message appears to have been reworded in 8938fa9 without updating this regex, and the PR description quotes a third wording. The regex and the message need to agree before merge.
| ) from e | ||
| except _NoEmbeddedAdaptersError as e: | ||
| raise _NoEmbeddedAdaptersError(repo_id, e.intrinsic_name, e.skipped) from e | ||
| except ValueError as e: |
There was a problem hiding this comment.
Lower severity. This generic handler still discards the reason for every non-no-adapters ValueError. An io.yaml-not-found or io_config-path-escape error raised by _embedded_adapters_from_model_directory is rewritten here into "No adapter found for adapter function 'x' in <repo_id>", which states the slot does not exist when the index actually lists it and its io.yaml is missing or escaping. The PR description notes the Hub path "replaced the whole message, so the reason was lost there too", but the new _NoEmbeddedAdaptersError branch only covers the no-adapters case. Restating only the location for these errors, or letting the directory-path messages pass through, would close the gap.
| @@ -642,12 +643,14 @@ def _embedded_adapters_from_model_directory( | |||
| technology = entry.get("technology", "lora") | |||
There was a problem hiding this comment.
Lower severity. The io_config_rel is None check just above (lines 640-642) continues before this technology check, so an unsupported-technology entry that omits its io_config key entirely never reaches the skipped dict. Requesting such a slot by name still yields the generic "No adapter found for adapter function 'future_slot' in <path>" with no mention of the unsupported technology — the exact case this change exists to explain. Since the technology check needs no file access (and the comment below notes unsupported slots may not publish an io.yaml), moving it above the io_config check would close the gap.
Move the technology check above the 'io_config is None' continue, so an unsupported entry that omits io_config is recorded in 'skipped' and named when the slot is requested, instead of falling through to the generic 'No adapter found' message. Update the all-slots-unsupported test to the message wording from 8938fa9 ('skipped unsupported entries'), which the test still expected in its old form, and cover the no-io_config case. Assisted-by: pi (claude) Signed-off-by: Nigel Jones <[email protected]>
The generic 'except ValueError' handler in _embedded_adapters_from_hub replaced the message wholesale, so an io.yaml-not-found or io_config path-escape error from discovery read as 'No adapter found for adapter function x in <repo>' -- stating the slot does not exist when the index lists it and only its config is broken. Restate the location against the repo ID and keep the original reason, mirroring what _NoEmbeddedAdaptersError already does. Assisted-by: pi (claude) Signed-off-by: Nigel Jones <[email protected]>
|
@markstur all three fixed in
Pre-commit and |
5293201
Pull Request
Thanks for sending a pull request! Please make sure you read the contributing guidelines.
Issue
Fixes #1837
Description
If a Granite Switch checkpoint contains an adapter whose
technologyMellea doesn't support (e.g.sr), asking for it by name used to fail with a message that gave no reason. It now names the technology and what is supported. Discovery has skipped such slots with a warning since #1797; the warning is unchanged.Before:
After:
When every slot is skipped, the error no longer reads like an empty index:
How it works.
_embedded_adapters_from_model_directoryrecords why each slot was skipped and raises_NoEmbeddedAdaptersError, a privateValueErrorsubclass, so existingexcept ValueErrorhandlers still catch it._embedded_adapters_from_hubrebuilds the message with the repo ID instead of the cache path. Its genericexcept ValueErrorhandler also keeps the original reason now: an io.yaml-not-found or io_config path-escape error used to be rewritten as a bare "No adapter found", stating the slot does not exist when the index lists it and only its config is broken.Differs from the issue's plan. The issue proposed threading skip reasons through
_discover_embedded_adaptersso theKeyErrorinresolve_adapterwould carry them. ThatKeyErrornever fires here:resolve_adapterre-runs discovery withintrinsic_name=<slot>, which raises theValueErrorfirst. So this fixes the message directly, with no change to helper return shapes or call sites.Testing
New
TestProbeSlotstests intest/backends/test_adapters/test_embedded_adapter.pycover an unsupported slot, an all-unsupported index, the Hub path (message names the repo ID), andresolve_adapterend to end, and an unsupported slot that omitsio_config. The four original tests failed before the fix; theio_configcase failed on the pre-fix code too.uv run pytest test/ -m "not qualitative": 5,435 passed, 1 failed. The failure istest_adapter_versions_unchanged, a live Hugging Face drift check (skipped on CI) reporting thatgranitelib-rag-r1.0andgranitelib-core-r1.0have moved past their pinned SHAs. This PR doesn't touch them. The ruff, mypy, and docstring quality gates are clean.Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.