Repository navigation
ROCMAI-215: extract engine/runtime selection and HTTP readiness polling into engine_runtime_select.rs - #756
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Integration with prerequisite #752 remains unverified, and build/test results were not independently validated in this review environment.
No open issues 🎉
What changed in this PR
Continues the main.rs modularization by moving engine/runtime selection and HTTP readiness polling into a dedicated module, with no intended behavior change.
Changes:
- Relocates selection, managed-child environment, argument-building, and readiness helpers into
engine_runtime_select.rs. - Updates caller imports and moves 11 existing tests alongside the extracted code.
- Documents the module’s responsibilities and shared crate-root helpers.
| File | Description |
|---|---|
docs/architecture.md |
Documents the extracted module and its callers. |
apps/rocm/src/service_launch.rs |
Updates launch-helper imports, preserving platform gates. |
apps/rocm/src/serve_cmd.rs |
Imports runtime selection from the new module. |
apps/rocm/src/runtimes_cmd.rs |
Updates the runtime-selector test import. |
apps/rocm/src/main.rs |
Registers the module and removes relocated helpers and tests. |
apps/rocm/src/engines_cmd.rs |
Updates selection and environment-helper imports. |
apps/rocm/src/engine_runtime_select.rs |
Houses extracted helpers and 11 existing tests. |
apps/rocm/src/engine_ipc.rs |
Updates helper imports and module documentation. |
apps/rocm/src/chat.rs |
Updates environment and model-name helper imports. |
Review effort: Balanced
82d2f1c to
36746c5
Compare
…ng into engine_runtime_select.rs Signed-off-by: Jussi Elo <jussi.elo@amd.com>
36746c5 to
6f4304c
Compare
juhovainio
left a comment
There was a problem hiding this comment.
Looks good. This is a clean extraction. I compared the code removed from main.rs against what was added in engine_runtime_select.rs: the function bodies are identical apart from the pub(crate) visibility, rewrapped imports, and fs:: becoming std::fs:: in two moved tests. No logic was added or dropped, the 11 tests moved over one-for-one, the Clap enums and dispatch() are untouched, docs/architecture.md has the new module entry, and the scope matches ROCMAI-215. This is based on reading the diff; I did not build it locally and am relying on CI for compile and Windows cfg coverage.
Two optional nits, neither blocking:
- The module doc comment and the architecture.md bullet repeat the same long lists of pub(crate) callers. These will drift as callers change. It matches what sibling modules like engine_ipc.rs do, so fine to leave, or trim one of the two.
- The comment in main.rs says the moved code reaches select_runtime_manifest via its own
use crate::runtimes_cmd::select_runtime_manifest;, but the new file uses a groupeduse crate::runtimes_cmd::{...}. Wording only.
CI note: the two Strix Halo Ubuntu E2E jobs show as cancelled at the run step, which looks like runner contention rather than a regression; the MI300X and W7900 E2E jobs were still pending when I checked.
Drop the pub(crate) visibility and caller list from the architecture.md
entry for engine_runtime_select.rs; the module's own doc comment keeps it,
next to the code, so the two copies cannot drift. Also reword the main.rs
comment to say the moved code reaches select_runtime_manifest through a
grouped `use crate::runtimes_cmd::{...}` import.
Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Summary
Phase 6f-8 of the
main.rsmodularization (epic ROCMAI-27) — the last sub-phase before the file's sharedmod testsblock. Mechanical relocation, no behavior change: moves engine/runtime selection and HTTP readiness-polling logic out ofapps/rocm/src/main.rsinto a newapps/rocm/src/engine_runtime_select.rs.resolve_engine_selection/validate_engine_selection_runtime(plusstruct EngineSelection, their return type, not named in the ticket but part of the cluster),single_ready_runtime_key,resolve_runtime_selector_to_exact_key,optional_arg,engine_recipe_json_arg/parse_engine_recipe_json_arg,app_path_env_vars/app_path_env_var_values/app_path_env_var_refs,daemon_run_argv,managed_service_launcher_path,apply_app_path_env,wait_for_service_http_ready(_with_progress),service_http_readiness_paths,http_get_local_service/http_post_local_service_json,service_http_readiness_response_ready,lemonade_health_ready_for_model,model_list_ready_for_model,service_model_gpu_ready/service_model_reports_rocm_backend/service_model_names_matchmoved.const fn status_for_readinesssits physically inside the span but has external callers (service_launch.rs,main.rs) and stayed behind, same treatment as earlier PRs'device_policy_name/ROLLBACK_RECOVERY_HINT.treat_as_natural_language, immediately following this cluster, is confirmed out of scope and untouched — dispatch-adjacent routing logic from ROCMAI-87, staying inmain.rspermanently.chat.rs,engine_ipc.rs,engines_cmd.rs,serve_cmd.rs,service_launch.rs, andruntimes_cmd.rs's own test module.dispatch()confirmed byte-identical (independently re-verified by SHA-256).docs/architecture.mdupdated with this module's entry.Test plan
cargo build --workspacecargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checkcargo xtask manifest --checkcargo xtask check-crate-edgespython scripts/smoke_local.py --profile debug --skip-buildcargo test --workspace --no-fail-fast— 4322 passed, 0 failed, 17 ignored (independently re-run, matches baseline exactly)dispatch()call sites confirmed byte-identical (SHA-256 of the function body)Depends on #752 (ROCMAI-210) — sixth PR in the ROCMAI-86 (Phase 6f) stack.
Part of Jira ROCMAI-215 / epic ROCMAI-27.
🤖 Generated with Claude Code