Skip to content

fix(lerobot): refuse non-finite FPS values in meta/info.json - #313

Merged
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
rakesh0x:fix/lerobot-fps-finite-positive
Aug 31, 2026
Merged

kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
rakesh0x:fix/lerobot-fps-finite-positive

Conversation

@rakesh0x

Copy link
Copy Markdown
Contributor

Summary

Fixes #299.

The LeRobot metadata boundary in _ensure_source_archive validated that fps from meta/info.json is numeric and positive, but not finite — so float("nan") and float("inf") passed validation and only failed later with misleading errors (no meta/episodes parquet files found, or a raw int() conversion failure in episode conversion).

This change mirrors the existing TransformConfig.gop_seconds pattern (math.isfinite) at the metadata boundary:

  • fps must now be finite as well as numeric and positive.
  • The contextual ValueError names the offending value and states the complete rule: FPS must be finite and positive.
  • The refusal happens before episode metadata discovery, so no episode metadata, source video, Parquet, or canonical output is written after an invalid info document is read.

Tests

Parametrized metadata-boundary regressions in tests/test_lerobot_converter.py:

  • NaN, +inf, and -inf are refused as invalid FPS (new behavior).
  • Boolean, missing, nonnumeric, zero, and negative FPS keep their existing refusal.
  • A normal positive FPS (30) is still accepted through discovery.
  • Each refusal case asserts the error names the bad value, mentions "finite and positive", and that _hf_tree episode discovery never runs and no meta/episodes output is created.
  • The regressions were verified to fail against unpatched main and pass with the fix.

No new dependency and no converter-version bump.

Validation

  • uv run ruff check --fix — clean
  • uv run ruff format — clean
  • uv run ty check — clean
  • uv run pytest -q tests/test_lerobot_converter.py — 18 passed
  • Full suite from repo root (tests + packages/hflow-server/tests per testpaths): 1255 passed, 11 skipped, 0 failed

The LeRobot metadata boundary checked that fps is numeric and positive
but not finite, so NaN and +/-inf passed validation and failed later
with unrelated errors (no meta/episodes parquet files found, or a raw
int() conversion error).

Mirror the TransformConfig boundary: require fps to be finite as well
as numeric and positive, and name the bad value with a complete rule
in the error. Regression coverage parametrizes NaN, +inf, -inf, bool,
missing, nonnumeric, zero, and negative fps, asserting refusal before
any episode metadata discovery or output is written.

Fixes Hebbian-Robotics#299

@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.

Validated on your branch: ruff check, ruff format --check, ty check clean, 1260 passed / 6 skipped.

Also checked the tests can detect the fix being removed. Dropped the math.isfinite clause and the nan and positive-infinity cases failed, the other six still passed. That's the right split: -inf was already caught by <= 0, so nan and +inf are the actual new coverage and your parametrization makes that visible instead of hiding it behind one green test.

"finite and positive" matches what _camera_motion.py:59 and _frame_statistics.py:98 already say, so the message reads like the rest of the repo.

One thing, and it's an invitation not a rule: the good first issue pool is where newcomers land, and you're three PRs in now, so it's worth leaving those for people who need somewhere to start. #320 (parse LeRobot metadata into a typed archive model) is the natural next step from this one, and it's where the _SourceArchive TypedDict you just validated a field of gets turned into something that can't hold a bad fps in the first place.

Or the higher-leverage version: you already filed #287 off Egocentric-10K, and that report was more useful than any of these fixes. More of that, pointing HFlow at real corpora and telling us what breaks, is worth more to us than the starter queue.

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.

LeRobot metadata accepts non-finite FPS values

2 participants