Skip to content

test(lerobot): use realistic valid shas in cache-namespacing test - #375

Merged
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
rakesh0x:fix/lerobot-cache-namespacing-test-uses-real-shas
Sep 3, 2026
Merged

test(lerobot): use realistic valid shas in cache-namespacing test#375
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
rakesh0x:fix/lerobot-cache-namespacing-test-uses-real-shas

Conversation

@rakesh0x

@rakesh0x rakesh0x commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What was wrong

test_import_namespaces_source_cache_by_resolved_revision proves the cache is namespaced by the resolved Hugging Face sha. It stubbed _hf_repo_info to return the values sha-a and sha-b — neither of which would survive the production validator at src/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-hex sha-a / sha-b literals with two 40-character hexadecimal shas and bound them to local variables sha_a and sha_b. The fixture dict and both assertions now reference the variables, so the test no longer contradicts the production validator.
  • No production code changes. _hf_repo_info's validator, the cache-path construction, and the rest of the test file are untouched.
  • The test's contract is unchanged: two revisions that resolve to the same sha share one cache directory, a different sha gets its own. branch-a and tag-a still 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 with f0e1), not just at the last character.

How the fix was validated

  • uv run ruff check --fix — passed
  • uv run ruff format — passed (no formatting changes)
  • uv run ty check — passed
  • uv run pytest -q tests/test_lerobot_converter.py35 passed
  • uv run pytest -q1421 passed, 12 skipped (the two pre-existing test_checks.py failures around camera_motion and Lucas-Kanade optical flow are unrelated to this change — they reproduce on plain origin/main without this branch's commit and concern a different module; out of scope for this PR).

Proof the relevant test passes

$ uv run pytest -q tests/test_lerobot_converter.py::test_import_namespaces_source_cache_by_resolved_revision
.                                                                        [100%]
1 passed in 0.12s

Out of scope

The two test_checks.py failures observed on the full suite are pre-existing and unrelated to this change. They will be addressed in a separate PR.

closes #371

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 kstonekuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kstonekuan
kstonekuan merged commit de070d3 into Hebbian-Robotics:main Sep 3, 2026
9 checks passed
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.

The importer cache namespacing test uses shas its own validator would reject

2 participants