Skip to content

refactor: use format.py constants for metadata record names in testing.py - #88

Merged
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
ayam04:fix/testing-format-constants
Aug 22, 2026
Merged

refactor: use format.py constants for metadata record names in testing.py#88
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
ayam04:fix/testing-format-constants

Conversation

@ayam04

@ayam04 ayam04 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

What changed

src/hflow/testing.py spelled format-owned metadata strings by hand at five sites ("episode/v1" and "robot_software_version"). It now imports and uses the constants that own those names, METADATA_RECORD_EPISODE and EPISODE_KEY_ROBOT_SOFTWARE_VERSION from hflow/format.py, mirroring the pattern already used in transform.py (its metadata handling at transform.py:444-446).

Sites changed (per issue #62):

  • _video_episode_metadata: dict key + reserved_metadata_keys entry
  • _write_video_episode (video fixture): writer.add_metadata(name=...)
  • _write_episode_with_channels (channel fixture): writer.add_metadata(name=...) + metadata dict key

Runtime behavior is unchanged — the constants hold the same strings.

Validation (run in WSL2, since HFlow imports fcntl and native Windows cannot import it)

uv sync --locked --all-extras
uv run ruff check        # All checks passed!
uv run ruff format --check  # 96 files already formatted
uv run ty check          # All checks passed!
uv run pytest -q         # 371 passed, 3 skipped; 3 failed + 6 errors all in tests/test_ffmpeg.py

The tests/test_ffmpeg.py failures are environment-only on this machine (they need real ffmpeg/ffprobe binaries on PATH): I ran the same file on a clean main worktree and got the identical 3 failed, 18 passed, 1 skipped, 6 errors, so they are pre-existing and unrelated to this change.

Also verified the issue's DoD grep is now empty:

rg 'name="episode/v1"|"robot_software_version"' src/hflow/testing.py   # no output

Fixes #62

…g.py

METADATA_RECORD_EPISODE and EPISODE_KEY_ROBOT_SOFTWARE_VERSION now own
the strings that testing.py previously spelled by hand at all five
format-owned sites, matching the transform.py pattern.

Closes Hebbian-Robotics#62

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

Thank you @ayam04. Complete and correctly scoped, and you counted better than my issue did: the body listed four sites and there are five, since synthesize_episode's own metadata dict carries robot_software_version too. You caught it, which is the whole point of the change.

Also right to leave task, operator, and success as literals. EPISODE_KEY_ROBOT_SOFTWARE_VERSION is the only episode key with a constant in format.py, so converting the others would have meant inventing constants the format does not own yet. Matching what exists beats being tidy.

What I validated locally:

  • Full quality gate is clean (ruff check, ruff format --check, ty check) and all 380 tests pass on your branch against current main.
  • The definition-of-done grep comes back empty, and I confirmed zero remaining hardcoded occurrences of either string in the module.
  • Generated a synthetic episode through synthesize_episode afterwards to confirm the fixtures still write a real, readable file rather than merely type-checking.

On the tests/test_ffmpeg.py failures: environment, not your change, and they pass here. Checking them against a clean main worktree before reporting is the right habit, and it is the second time you have done it. It genuinely saves me time.

Merging now.

One note I owe you, and it applies from here rather than as a complaint about this PR: the good first issue pool is best kept for people making their first contribution, and with #79 already merged you are past that. Nothing wrong with this one, and I would rather you had taken it than have it sit. But for the next one, the higher-leverage work is where you have already shown range: you did the layering analysis that shaped action_rate back in #24, and that kind of reasoning is worth more here than a mechanical refactor. Two live examples if either appeals, neither a starter issue: #86, where registering a check with required keyword arguments is accepted and then fails once per episode, and #85, where RuntimeConfig(api_port=True) slips through a range check because bool subclasses int. Never a rule, always an invitation.

@kstonekuan
kstonekuan merged commit f9ac687 into Hebbian-Robotics:main Aug 22, 2026
5 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.

testing.py hardcodes episode/v1 and robot_software_version instead of the format.py constants

2 participants