Skip to content

refactor(rlix-examples): extract shared driver helpers into _common#19

Open
TianyeGGBond wants to merge 2 commits into
rlops:zhenyu/m11-mvp-testfrom
TianyeGGBond:tianye/m11-dual-dedup-common
Open

refactor(rlix-examples): extract shared driver helpers into _common#19
TianyeGGBond wants to merge 2 commits into
rlops:zhenyu/m11-mvp-testfrom
TianyeGGBond:tianye/m11-dual-dedup-common

Conversation

@TianyeGGBond

Copy link
Copy Markdown

Context

examples/rlix/run_miles_rlix.py (single) and run_miles_dual.py (dual)
carried three near-verbatim copies of the same logic:

  • the RLIX_CONTROL_PLANE=rlix env-var guard (must run before heavy imports),
  • the MilesPipelineConfig dataclass (defined as a local class in each
    main(); the dual one had an extra cluster_device_mappings field),
  • the Ray runtime_env env_vars construction (identity vars + PYTHONPATH +
    the forwarded smoke-only escape hatches).

Two drifting copies are easy to let diverge.

Change

New examples/rlix/_common.py (stdlib-only, so it is safe to import before
the per-actor CUDA_VISIBLE_DEVICES guard fires):

  • require_rlix_control_plane(script_path, module_path) — the guard
  • MilesPipelineConfig — one dataclass; cluster_device_mappings defaults
    to {}, so the single driver (which never set it) is unaffected
  • build_pipeline_runtime_env(pipeline_id, namespace, *, extra=None) — the
    env_vars dict; the dual driver passes MILES_ROLLOUT_BASE_PORT via extra=

Both drivers now import these instead of redefining them. No behavior change.

Stacking

Stacked on #18 (partial-env fail-fast). Until #18 merges into
zhenyu/m11-mvp-test, this PR's Files-changed view also shows #18's commit;
review the top commit here. Merge after #18.

🤖 Generated with Claude Code

_overlap_pools_from_env returned None whenever any of the four
MILES_DUAL_P*_{TRAIN,INFER} vars was unset, so a typo or one missing var
silently fell back to the disjoint topology and ran a different experiment
than intended. Treat the four as all-or-nothing: all set -> overlap, none
set -> disjoint fallback, partial set -> ValueError naming the missing vars.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The single (run_miles_rlix.py) and dual (run_miles_dual.py) drivers carried
near-identical copies of the env-var guard, the MilesPipelineConfig
dataclass, and the Ray runtime_env construction. Move them to a new
examples/rlix/_common.py (stdlib-only, safe to import before the heavy
imports):

- require_rlix_control_plane(script, module) — the RLIX_CONTROL_PLANE guard
- MilesPipelineConfig — single dataclass (cluster_device_mappings defaults
  to {} so the single driver is unaffected)
- build_pipeline_runtime_env(pipeline_id, namespace, extra=) — identity vars
  + PYTHONPATH + forwarded escape hatches; dual passes MILES_ROLLOUT_BASE_PORT
  via extra=

Imports of _common use a try/except fallback (from ._common, else from
_common) so both `python -m examples.rlix.run_miles_*` (package context) and
`python examples/rlix/run_miles_*.py` (direct script, as the rlix smoke
scripts invoke it) keep working.

No behavior change; both drivers now share one definition.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TianyeGGBond
TianyeGGBond force-pushed the tianye/m11-dual-dedup-common branch from 131181c to 6d23375 Compare June 21, 2026 17:04
@TianyeGGBond

Copy link
Copy Markdown
Author

Updated (force-push) to fix a blocker: the relative from ._common import ...
broke direct-script invocation (python examples/rlix/run_miles_*.py), which
the rlix smoke scripts use — ImportError: attempted relative import with no known parent package.

Both driver _common imports now use a try/except fallback (from ._common
from _common), so both python -m examples.rlix.run_miles_* and
python examples/rlix/run_miles_*.py work. Verified both invocation styles
resolve _common (heavy imports still deferred past the env guard).

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.

1 participant