test(lerobot): use realistic valid shas in cache-namespacing test - #375
Conversation
The cache-namespacing test stubs _hf_repo_info wholesale, so its fixtures are never validated by the production hex-only sha guard. Replace the non-hex 'sha-a'/'sha-b' literals with 40-character hexadecimal shas and reference them by variable in the assertions, so a future bug in the validator or the cache-path construction has a test that can fail for the right reason. The test's contract is unchanged: two revisions that resolve to the same sha share one cache directory, a different sha gets its own.
kstonekuan
left a comment
There was a problem hiding this comment.
LGTM, merging.
Both shas satisfy the validator that made this worth changing, and the old ones did not:
sha_a len=40 [0-9a-f]{7,64} accepts: True
sha_b len=40 [0-9a-f]{7,64} accepts: True
'sha-a' len= 5 accepts: False
a1b2c3... against f0e1d2... is the right call on DoD 3: distinguishable at a glance, so the two-revisions-one-cache leg still reads as two revisions and one cache rather than two forty-character blurs. Naming them as constants and commenting why branch-a and tag-a share one is what keeps that legible.
On the out-of-scope note: those two test_checks.py failures do not reproduce here. On your branch merged with current main, tests/test_checks.py is 35 passed and the full suite is 1436 passed / 6 skipped with nothing failing. The likely cause is a sync without the optional extras, which is the same trap that has caught two other contributors this week:
uv sync --locked --all-extras
uv run pytest -q--all-extras is the documented form in CONTRIBUTING, and without it a handful of vision-dependent tests behave differently. Worth confirming before opening that separate PR, since there may be nothing to fix.
Closes #371.
What was wrong
test_import_namespaces_source_cache_by_resolved_revisionproves the cache is namespaced by the resolved Hugging Face sha. It stubbed_hf_repo_infoto return the valuessha-aandsha-b— neither of which would survive the production validator atsrc/hflow/importers/lerobot.py:239-240(r"[0-9a-f]{7,64}"). The test passed only because the stub bypassed the validator, so a future bug in the validator or in the cache-path construction that consumes the resolved sha could not manifest in this test.A test that uses values its own code path would reject cannot fail for the right reason.
What changed
tests/test_lerobot_converter.py: replaced the non-hexsha-a/sha-bliterals with two 40-character hexadecimal shas and bound them to local variablessha_aandsha_b. The fixture dict and both assertions now reference the variables, so the test no longer contradicts the production validator._hf_repo_info's validator, the cache-path construction, and the rest of the test file are untouched.branch-aandtag-astill resolve to the same sha on purpose — that is the two-revisions-one-cache leg of the contract.The two shas were chosen so a reader can tell them apart at a glance (one starts with
a1b2, the other withf0e1), not just at the last character.How the fix was validated
uv run ruff check --fix— passeduv run ruff format— passed (no formatting changes)uv run ty check— passeduv run pytest -q tests/test_lerobot_converter.py— 35 passeduv run pytest -q— 1421 passed, 12 skipped (the two pre-existingtest_checks.pyfailures aroundcamera_motionand Lucas-Kanade optical flow are unrelated to this change — they reproduce on plainorigin/mainwithout this branch's commit and concern a different module; out of scope for this PR).Proof the relevant test passes
Out of scope
The two
test_checks.pyfailures observed on the full suite are pre-existing and unrelated to this change. They will be addressed in a separate PR.closes #371