fix: accept a path-like tool_index_path, as weights already does - #110
Open
kevin9327 wants to merge 1 commit into
Open
fix: accept a path-like tool_index_path, as weights already does#110kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
Signed-off-by: kevin9327 <kevin9327@users.noreply.github.com>
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.
Problem
Needle(tool_index_path=Path("tools.idx"))raises, but only when no tuned weights are passed:The same argument is accepted a few lines further down.
__init__has two paths and they disagree:So with
weights=the agent takes aPathand without it the same call fails.weightsitselftakes one either way, which is what a caller reasonably expects of the argument beside it, and
Pathis the ordinary way to build a path next to the checkpoint you just wrote.Fix
One line:
os.fspathbefore the encode, matchingweightsdirectly above and the worker branchdirectly below.
Tests
Two in
tests/test_weights.py, on the existingenginefixture so no engine is needed:test_tool_index_path_takes_a_path_object— aPathreaches the engine as itsos.fspathbytes.Before this change it raises the
AttributeErrorabove.test_tool_index_path_agrees_between_the_base_and_tuned_paths— the samePathis accepted bythe base agent and by the worker-backed tuned agent, which is the asymmetry that made this easy to
miss.
How I tested
Windows 11, Python 3.12.10,
pip install -e ".[test,train]".pytest -q -m "not slow"gives 66 passed, 9 skipped; the two new tests are the only change andnothing else moves. The 9 skips are the six engine tests and the three worker tests that want a C
compiler.
test_lora.py,test_render.py,test_run.py,test_build.pyandtest_finetune.pyare excludedfrom that run: they need
flax, whoseorbax-checkpointdependency will not install on Windowsbecause its paths exceed
MAX_PATH. Nothing here touches them, and CI runs them on Ubuntu.