Repository navigation
refactor(core): split the episode modules into types, context and failure records - #5564
Merged
Merged
Conversation
…lure records After #5536 moved episode_types.py into core/, the package held two modules with overlapping names. episode.py held episode identity and the current episode's context variables; episode_types.py held the episode wire envelopes and the failure records. Episode types now have one home, and each concern has its own module: - core/episode_types.py: every episode data type, including EpisodeId and TaskId, which come back to the module that shipped them in 0.7.0. - core/episode_context.py (new): the current episode, that is, the context variables, the rollout id rules and the verifier invocation id. - core/failure_records.py (new): failure boundaries, failure events, the failure report and the episode failure envelope, beside failure_kinds.py and failure_transport.py. core/episode.py is removed. It never shipped in a release, so it gets no old-path entry. The old-path entries that pointed into it now point at the new modules. nemo_gym.episode_types (0.7.0) keeps serving the failure names that moved out of it until 0.10.0. nemo_gym.core serves the same public names. The docs redirect for nemo_gym.episode_types now points at the core/episode_types page instead of the server_runtime page that #5536 removed, and the core/episode page redirects to core/episode_types. Follow-up to #5166. Signed-off-by: Ananth Subramaniam <[email protected]>
Contributor
svcnvidia-nemo-ci
left a comment
Contributor
There was a problem hiding this comment.
SHIP
LGTM — no concerns found. I reviewed the changed hunks and traced the relocated definitions through public and legacy imports, request context, failure transport, and checkpoint and rollout consumers. I found no introduced correctness or compatibility defects.
I couldn't execute tests or build the generated documentation in this read-only review.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
35 of 41 tasks
This branch was previously deployed
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.
What changed and why
After #5536 moved
episode_types.pyintonemo_gym/core/, the package has two modules with overlapping names:episode.pyheld episode identity (EpisodeId,TaskId) and the context variables for the current episode.episode_types.pyheld the episode wire envelopes and the failure records.A reader looking for an episode type had to guess which of the two holds it. This PR gives every episode type one home and gives each concern its own module:
EpisodeId,TaskIdcore/episode.pycore/episode_types.pyMaterializedTask,BaseEpisodeRequest,BaseEpisodeResponse,is_materialized_task_rowcore/episode_types.pycore/episode_types.py(unchanged)VERIFIER_INVOCATION_HEADER,ROLLOUT_ID_PATTERN,maybe_rollout_id_from_run_body,current_rollout_id,current_episode_id,rollout_context,current_verifier_invocation_id,verifier_invocation_context, and the two context variablescore/episode.pycore/episode_context.py(new)FailureBoundary,SdkErrorDetails,SandboxFailureDetails,ModelFailureDetails,FailureEvent,validate_failure_event_map,FailureReport,EpisodeFailurecore/episode_types.pycore/failure_records.py(new)core/episode.pyis removed.failure_records.pysits besidefailure_kinds.pyandfailure_transport.py, so the three failure modules read as one group.Arrows mean "imports". The definitions move unchanged. One test patched
validate_failure_event_mapthroughepisode_types; it now patches it infailure_records, where the failure report looks it up.Imports follow the layout rule. Library code and its tests import each name from the module that defines it;
python scripts/migrate_imports.pyrewrote them. Code outsidenemo_gym/already imported these names fromnemo_gym.core, which serves the same public names from the new modules, so no server changes apart from one docstring.Compatibility
nemo_gym.core.episodenever shipped in a release, so it gets no old-path entry. The old-path entries that pointed into it (fornemo_gym.server_utils,nemo_gym.rollout_correlationandnemo_gym.models.base_responses_api_model) now point atepisode_contextorepisode_types.nemo_gym.episode_typesshipped in 0.7.0 withEpisodeId,TaskIdandEpisodeFailure.EpisodeIdandTaskIdare defined in its new location again. The failure names that moved out of it, andFailureStageandvalidate_failure_kind, which it imported, resolve throughMOVED_NAMESwith aDeprecationWarninguntil 0.10.0. The import snapshot test checks every recorded name.nemo_gym/episode_typespage pointed atserver_runtime/episode_types, which refactor(core): move the failure modules from #5072 into their packages #5536 removed. It now points atcore/episode_types, and thecore/episodepage redirects there too.Validation
lint-imports: the layer contract is kept, with no new ignored imports.nemo_gym.episode_types,nemo_gym.rollout_correlation,nemo_gym.server_utils) and gets the identical objects from the new modules, each with aDeprecationWarning;nemo_gym.core.episodeno longer imports.migrate_importsand import-linter coverage tests pass.pytest -n 16 -o addopts="" tests/unit_tests: everything passes except tests that fail the same way onmainon this host: four Harbor run summary tests and one benchmark listing test (the hostname resolves to 127.0.1.1, which Gym refuses to advertise to a sandbox) and two Docker PTY tests.pre-commit runon every changed file passes.Rollout evidence
N/A: the types move unchanged and only import lines change, so no rollout behavior changes. The unit suite covers the moved code.
Overlap with open PRs
None of #5526, #5528, #5531, #5533 or #5553 has merged; this branch is based on the current
main. A trial merge against each head:nemo_gym/agents/base_responses_api_agent.py.nemo_gym/agents/base_responses_api_agent.py,nemo_gym/client/server_client.pyandnemo_gym/rollouts/rollout_collection.py.The conflicts are adjacent import lines. Whichever PR lands second needs a small rebase. Because
nemo_gym.core.episodenever shipped, it has no old-path entry: a branch that adds an import from it must switch that import toepisode_typesorepisode_context.Follow-up to #5166.