Repository navigation
refactor(rocm): move the comfyui dispatch function out of main.rs - #938
Closed
jussielo-amd wants to merge 1 commit into
Closed
jussielo-amd wants to merge 1 commit into
jussielo-amd wants to merge 1 commit into
Conversation
The `comfyui` dispatch function (the match over `ComfyuiCommand`, about 160 lines) moves from `apps/rocm/src/main.rs` into `apps/rocm/src/comfyui.rs` as `comfyui::run`, next to the code it calls, the way `remote::run` and `bootstrap::run` are named. It is a pure move: the body is unchanged apart from dropping the `comfyui::` prefix on calls that are now local, and the module reaches `record_cli_audit_event` through `crate::cli_audit` like its sibling command modules, so no new module cycle appears. The one arm of `dispatch()` now calls `comfyui::run(command)`. The clap command tree already lives in `cli.rs`, so the convention text that said the command enum and its dispatch function usually stay in `main.rs` (with `comfyui()` as the example) is updated in the same change: docs/architecture.md (module-organization convention, the `main.rs` entry and the `comfyui.rs` entry) and AGENTS.md section 6. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The ComfyUI dispatcher relocation has no active review issues.
No open issues 🎉
What changed in this PR
Moves the ComfyUI command dispatcher from main.rs into its domain module, following the earlier clap-tree extraction and aligning ComfyUI with sibling commands. The relocation preserves command behavior and audit logging.
Changes:
- Relocates the handler as
comfyui::runand updates the top-level dispatch call and imports. - Updates architecture documentation and contributor guidance to reflect where command enums and dispatch functions live.
| File | Description |
|---|---|
docs/architecture.md |
Updates module-organization guidance and the main/ComfyUI module descriptions. |
apps/rocm/src/main.rs |
Delegates to comfyui::run, removes the old handler, and cleans up imports and a comment. |
apps/rocm/src/comfyui.rs |
Hosts the relocated dispatcher with direct command-type and audit imports. |
AGENTS.md |
Aligns dispatch-placement guidance with the module structure. |
Review effort: Balanced
Collaborator
Author
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.
Summary
rocm comfyuiwas the one command whose dispatch function (the match overComfyuiCommandthat renders status, logs and the models path and runs install, start and stop, recording an audit event for each) was still defined inapps/rocm/src/main.rs, about 160 lines away from everything else about ComfyUI, while the sibling commands (services,config,automations,engines,runtimes,install,setupand others) already keep theirs in their own module. This moves it intoapps/rocm/src/comfyui.rs, next to the code it calls, as a pure move. Delivers ROCMAI-833, and with the clap-tree move in the merged #889 it completes ROCMAI-858 (main.rs is now under the 1,500 production-line limit).The module-organization text in
docs/architecture.mdand in AGENTS.md section 6 said the clap command enum and its dispatch function usually stay inmain.rs, and thatcomfyui()was the example. The clap tree already moved tocli.rsin #889, so that text was already half out of date; this change makes both texts say what the code now does, in the same commit as the move.What moved
fn comfyui(command: Option<ComfyuiCommand>) -> Result<()>apps/rocm/src/main.rspub(crate) fn run(command: Option<ComfyuiCommand>) -> Result<()>inapps/rocm/src/comfyui.rsThe body is unchanged apart from import paths: the
comfyui::prefix on calls into the module (render_status,render_models_path,render_logs,install,start,stop,ComfyUiInstallOptions,ComfyUiStartOptions) is dropped because they are now local, andcomfyui.rsgainsuse crate::cli::ComfyuiCommand;anduse crate::cli_audit::record_cli_audit_event;, the same direct importservices_cmd.rs,config_cmd.rsandinstall_cmd.rsuse. Reachingcli_auditdirectly means no new edge back intomain.rs, so no new module cycle. Inmain.rsthe one arm ofdispatch()becomesSome(Command::Comfyui { command }) => comfyui::run(command)(the name followsremote::runandbootstrap::run), the now-unusedComfyuiCommandimport is dropped, and a comment that saidmain.rsitself callsrecord_cli_audit_eventis trimmed because it no longer does.Docs updated in the same commit: the module-organization convention and the
main.rsandcomfyui.rsentries indocs/architecture.md(thecomfyui()handler is no longer listed undermain.rs; thecomfyui.rsentry now says the dispatch function lives there while the enum stays incli.rs), and the new-subsystems bullet in AGENTS.md section 6.Verification
Ran:
cargo fmt --all --check;cargo clippy -p rocm --all-targets -- -D warningson Linux;cargo test -p rocm --no-fail-fast; the leaf-name diff ofcargo test -p rocm --bin rocm -- --listand-- --list --ignoredagainst clean origin/main (both empty: 1,516 tests and 8 ignored before and after);cargo xtask manifest --check;cargo xtask check-crate-edges; lychee (offline, repo config) ondocs/architecture.mdandAGENTS.md; the leak scan against origin/main; a conflict-marker grep.Not run: the Windows clippy cross-check could not build locally (the
aws-lc-sysC build forx86_64-pc-windows-msvcneeds a Windows C toolchain that is not installed here), so the Windows lane is the check; the moved code has nocfggates. Thetests/e2e-cucumbercomfyui scenarios were not run locally; CI carries them.User-visible behaviour
None, so no new scenario: this is an internal relocation. The existing comfyui scenarios in
tests/e2e-cucumber/features/exercise the same dispatch path and are expected to stay green unmodified. The function has no unit tests of its own to move.Notes for reviewers
One commit. Reading order:
apps/rocm/src/comfyui.rs(the function, directly afterComfyUiStartOptions), the one-line arm inmain.rs, then the three documentation edits.git diff --color-movedshows the body as moved apart from the droppedcomfyui::prefixes. Besides the docs hotspot (docs/architecture.mdis edited by many open PRs, expect a mechanical rebase), #923 also touchesapps/rocm/src/comfyui.rs, in a different region.