Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,071 changes: 236 additions & 3,835 deletions apps/rocm/src/comfyui.rs

Large diffs are not rendered by default.

2,263 changes: 2,263 additions & 0 deletions apps/rocm/src/comfyui/install.rs

Large diffs are not rendered by default.

527 changes: 527 additions & 0 deletions apps/rocm/src/comfyui/process.rs

Large diffs are not rendered by default.

967 changes: 967 additions & 0 deletions apps/rocm/src/comfyui/runtime_env.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/rocm-core/src/quoting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
//! `posix_shell_quote`'s output is sent over SSH to a remote shell
//! (`apps/rocm/src/remote/mod.rs`'s `remote_serve_command` and friends), and
//! `powershell_quote`'s output is written into a `.ps1` script executed via
//! `powershell.exe -File` (`apps/rocm/src/comfyui.rs`'s Windows runtime
//! launch) or interpolated into a `-Command` string
//! `powershell.exe -File` (`apps/rocm/src/comfyui/process.rs`'s Windows
//! runtime launch) or interpolated into a `-Command` string
//! (`crate::fix::path_export_windows`, `crate::diagnose`'s matching
//! printed copy). A mistake in either one is a real command-injection or
//! script-corruption bug, which is why both carry direct unit coverage here
Expand Down
5 changes: 4 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Each per-crate module inventory lists one file per line. Flat inventories (every
- [`cli_audit.rs`](../apps/rocm/src/cli_audit.rs) — mechanical relocation, no owned types: the CLI audit and lifecycle log (`record_cli_audit_event`, plus the helpers behind it that write `logs/cli-lifecycle.log` and the per-action files under `logs/cli/`). Its production code depends only on `rocm-core`. `record_cli_audit_event`, `cli_lifecycle_log_path` and `sanitize_log_value` are `pub(crate)` and reached from other modules as `crate::<name>` through a re-import in [`main.rs`](../apps/rocm/src/main.rs); every other item is private. The two regression tests live in this module's own `mod tests`, reaching the shared `test_paths` fixture through `crate::tests::`.
- [`cli_progress.rs`](../apps/rocm/src/cli_progress.rs) — shared CLI-output component (`Spinner`, `AnimatedSpinner`).
- [`cli_report.rs`](../apps/rocm/src/cli_report.rs) — shared CLI-output component (`ActionReport`).
- [`comfyui.rs`](../apps/rocm/src/comfyui.rs) — full domain extraction; serves the `comfyui` subcommand, whose command enum (`ComfyuiCommand`) and dispatch fn stay in [`main.rs`](../apps/rocm/src/main.rs) (unlike [`bootstrap.rs`](../apps/rocm/src/bootstrap.rs) above, which owns its own).
- [`comfyui.rs`](../apps/rocm/src/comfyui.rs) — full domain extraction; serves the `comfyui` subcommand, whose command enum (`ComfyuiCommand`) and dispatch fn stay in [`main.rs`](../apps/rocm/src/main.rs) (unlike [`bootstrap.rs`](../apps/rocm/src/bootstrap.rs) above, which owns its own). It owns the ComfyUI types and constants, the install and state paths, the manifest and state files, `status` and `logs` rendering, and the helpers that run a Python child and capture its output. Choosing the ROCm runtime and building its environment ([`comfyui/runtime_env.rs`](../apps/rocm/src/comfyui/runtime_env.rs)), the process lifecycle ([`comfyui/process.rs`](../apps/rocm/src/comfyui/process.rs)) and the install ([`comfyui/install.rs`](../apps/rocm/src/comfyui/install.rs)) are in child modules, listed below with the other `apps/rocm` modules; `start`, `stop` and `install` are re-exported from them so callers still write `comfyui::start`, `comfyui::stop` and `comfyui::install`.
- [`config_cmd.rs`](../apps/rocm/src/config_cmd.rs) — mechanical relocation, dispatch-adjacent, no owned types: `rocm config`'s command handler (`config()`), the provider-key prompt it uses (`read_provider_key_from_user`) and the text `rocm config show` prints (`render_config_text`, `telemetry_policy_summary`). `ConfigCommand` stays in [`main.rs`](../apps/rocm/src/main.rs). `config()` and `render_config_text` are `pub(crate)`: `dispatch()` calls `config()` and [`chat.rs`](../apps/rocm/src/chat.rs)'s read-only handling of `rocm config show` calls `render_config_text`, both through re-imports in `main.rs`; the other two functions are private. The two `render_config_text` regression tests live in this module's own `mod tests`, reaching the shared `test_paths` fixture through `crate::tests::`.
- [`dash.rs`](../apps/rocm/src/dash.rs) — full domain extraction.
- [`dash_seam.rs`](../apps/rocm/src/dash_seam.rs) — full domain extraction.
Expand Down Expand Up @@ -101,6 +101,9 @@ Each per-crate module inventory lists one file per line. Flat inventories (every
Further `apps/rocm` modules, not part of the `main.rs` split:

- [`advised_commands.rs`](../apps/rocm/src/advised_commands.rs) — test-only (`#[cfg(test)]`): checks that every `rocm …`/`rocmd …` command the repository advises — in `--help` text, production string literals, the markdown docs and skills, and the VHS tapes — exists and parses, by running it through the parser of the binary it names (`rocm`'s clap `Cli`, or `rocmd`'s `parse_args`).
- [`comfyui/install.rs`](../apps/rocm/src/comfyui/install.rs) — child module of [`comfyui.rs`](../apps/rocm/src/comfyui.rs): `rocm comfyui install`, including its dry run and the reinstall that replaces ComfyUI's code (through [`comfyui/source_swap.rs`](../apps/rocm/src/comfyui/source_swap.rs)) while refusing to do so under a running ComfyUI. It downloads and unpacks the source archive, installs ComfyUI's Python dependencies into the selected runtime with uv (filtering out and pinning the runtime's own torch stack, and streaming uv's output to the install log) and runs the AMD GPU check. The manifest, the install log paths and the GPU probe stay in `comfyui.rs`. It imports `runtime_env` and, for the running-ComfyUI guard, `process`; neither imports it. Its unit tests and the Unix-only `archive_properties` property tests for the source unpack live in the module; the fixtures they share with the tests left in `comfyui.rs` stay there.
- [`comfyui/process.rs`](../apps/rocm/src/comfyui/process.rs) — child module of [`comfyui.rs`](../apps/rocm/src/comfyui.rs): the lifecycle of the ComfyUI process this CLI launches. `start` checks the installed folder, runs the GPU check, launches ComfyUI in the background (a detached child on Linux, a hidden PowerShell launcher on Windows) and waits for its port; `stop` ends the saved process tree. `evaluate_running_state` tells a running, a still-loading and a stopped ComfyUI apart for `status`, and `running_from`, `refuse_while_running` and `running_advice` are the guard that refuses a reinstall while ComfyUI runs from the folder it would replace. The saved state and the types in it stay in `comfyui.rs`. Among the `comfyui` children it imports from [`comfyui/runtime_env.rs`](../apps/rocm/src/comfyui/runtime_env.rs) and uses [`comfyui/source_swap.rs`](../apps/rocm/src/comfyui/source_swap.rs) to check for an interrupted reinstall; neither imports it, so there is no cycle.
- [`comfyui/runtime_env.rs`](../apps/rocm/src/comfyui/runtime_env.rs) — child module of [`comfyui.rs`](../apps/rocm/src/comfyui.rs): choosing which installed ROCm runtime ComfyUI runs against (`select_runtime`, with the messages that tell the user how to pick one when none or several are ready) and building the `VIRTUAL_ENV`, `ROCM_PATH`, `PATH` and library-path environment a ComfyUI child process runs with. The types it returns (`SelectedRuntime`, `ComfyUiRuntimeEnvironment`) stay in `comfyui.rs`, which the module imports from; it imports nothing from the other `comfyui` children.
- [`comfyui/source_swap.rs`](../apps/rocm/src/comfyui/source_swap.rs) — child module of [`comfyui.rs`](../apps/rocm/src/comfyui.rs): replacing ComfyUI's code in an existing `source/` folder on reinstall without touching anything else there.
- [`remote/mod.rs`](../apps/rocm/src/remote/mod.rs) — `rocm remote`: driving a remote GPU host from this machine, with SSH as the control channel and the remote's own service published onto the tailnet for inference traffic. Like [`bootstrap.rs`](../apps/rocm/src/bootstrap.rs), it owns its command enum (`RemoteCommand`) and dispatch fn (`run`). Its `pub(crate)` submodules:
- [`remote/bootstrap.rs`](../apps/rocm/src/remote/bootstrap.rs) — deciding whether a remote machine can host a model before asking it to.
Expand Down
9 changes: 7 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,11 @@ Windows-only:

```bash
cargo test -p rocm --bin rocm comfyui::source_swap
cargo test -p rocm --bin rocm comfyui::install
cargo test -p rocm --bin rocm comfyui::tests
```

The second filter covers the install-level tests: `reinstall_*`,
The last two filters cover the install-level tests: `reinstall_*`,
`install_after_an_interrupted_reinstall_finishes_it`,
`start_refuses_an_interrupted_reinstall_until_install_finishes_it`,
`a_reinstall_that_*`, `a_reinstall_proceeds_over_an_unreadable_saved_state`,
Expand All @@ -748,7 +749,11 @@ The second filter covers the install-level tests: `reinstall_*`,
`swap_changes_summary_names_what_was_replaced_and_set_aside`,
`a_plain_install_is_not_refused_while_comfyui_runs`,
`plain_install_dry_run_previews_no_reinstall`,
`a_refusal_just_before_the_swap_changes_nothing` and `chat_status_answer_*`.
`a_refusal_just_before_the_swap_changes_nothing` and `chat_status_answer_*`. The
second filter (`comfyui::install`) holds all of them except
`start_refuses_an_interrupted_reinstall_until_install_finishes_it` and
`chat_status_answer_*`, which span `start`, `status` and `install` and stay under
the third (`comfyui::tests`), with the fixtures both share.
The running guard is tested against a ComfyUI answering on its port
(`running`) and one whose process is up but whose port is not answering yet
(`starting`).
Expand Down
12 changes: 7 additions & 5 deletions tests/e2e-cucumber/src/bin/fake-python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
//! A stand-in for the runtime's Python interpreter, for the ComfyUI install
//! scenarios' two probes.
//!
//! `apps/rocm/src/comfyui.rs` shells out to the runtime's Python twice:
//! `-c <script>` for the pre-install torch-stack version probe (answered here
//! with empty JSON, so the probe reads "nothing pinned") and
//! `<script-path> <result-path>` for the post-install GPU check (answered by
//! writing a fixed, GPU-having result to the given path). One binary answers
//! The ComfyUI install shells out to the runtime's Python twice. The first call
//! is `-c <script>`, the pre-install torch-stack version probe in
//! `apps/rocm/src/comfyui/install.rs`; this binary answers it with empty JSON,
//! so the probe reads "nothing pinned". The second call is
//! `<script-path> <result-path>`, the post-install GPU check in
//! `apps/rocm/src/comfyui.rs`; this binary answers it by writing a fixed,
//! GPU-having result to the given path. One binary answers
//! both forms unconditionally, so a scenario that only reaches the first
//! probe and one that reaches both work against the same stand-in.
//!
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e-cucumber/tests/e2e/comfyui_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ async fn assert_install_succeeded(world: &mut E2eWorld) {
async fn assert_dependencies_installed(world: &mut E2eWorld) {
// Closes the last vacuity path a zero exit code leaves open. `comfyui::install`
// guards the whole `uv` install with `if !packages.is_empty()`
// (`apps/rocm/src/comfyui.rs`), so an empty filtered requirement list skips it
// (`apps/rocm/src/comfyui/install.rs`), so an empty filtered requirement list skips it
// and still exits 0 — leaving the runtime untouched and every invariant below
// passing having installed nothing.
//
Expand Down
4 changes: 2 additions & 2 deletions xtask/src/ascii_output_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ mod tests {
/// covering.
const EXEMPT_LITERALS: &[(&str, &str, &str)] = &[
(
"apps/rocm/src/comfyui.rs",
"apps/rocm/src/comfyui/install.rs",
"Resolving and installing packages with uv…",
SPINNER_LABEL,
),
(
"apps/rocm/src/comfyui.rs",
"apps/rocm/src/comfyui/install.rs",
"Fetching ComfyUI source archive…",
SPINNER_LABEL,
),
Expand Down
Loading