Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
16587cc
test: pin how each caller finds a Python environment root from its in…
jussielo-amd Nov 5, 2026
7157d08
refactor: find a Python environment root from its interpreter by one …
jussielo-amd Nov 5, 2026
aedaa26
test(runtime): pin what each install-root payload check answers
jussielo-amd Nov 5, 2026
36a59a9
test(runtimes): pin how the ComfyUI and engine paths pick the single …
jussielo-amd Nov 5, 2026
4f586de
Merge remote-tracking branch 'origin/main' into refactor-one-python-e…
jussielo-amd Nov 5, 2026
8ea8577
Merge remote-tracking branch 'origin/main' into refactor-one-python-e…
jussielo-amd Nov 5, 2026
6e10950
Merge remote-tracking branch 'origin/main' into refactor-one-python-e…
jussielo-amd Nov 5, 2026
b8331b3
fix(comfyui): pick the single ready runtime by the same rule as the e…
jussielo-amd Nov 5, 2026
de8d41f
test(comfyui): pin that an unusable setup runtime fails the default s…
jussielo-amd Nov 5, 2026
c564ebe
Merge origin/main into refactor-one-single-ready-runtime-rule
jussielo-amd Nov 5, 2026
8fdc0fc
refactor(runtime): one definition of a non-empty install root
jussielo-amd Nov 5, 2026
b4d94d3
test(system_packages): pin that the install hints read the real host'…
jussielo-amd Nov 5, 2026
e36e69d
refactor(hardware_root): one reader for the real host's os-release
jussielo-amd Nov 5, 2026
9009f34
test: pin which manifest files each way of registering a runtime writes
jussielo-amd Nov 5, 2026
78c6171
refactor: register every runtime through one manifest writer
jussielo-amd Nov 5, 2026
8b9d3dc
Merge origin/main into refactor-one-single-ready-runtime-rule
jussielo-amd Nov 5, 2026
beb2a8d
Merge origin/main into refactor-one-runtime-manifest-writer
jussielo-amd Nov 5, 2026
9bf5354
Merge remote-tracking branch 'origin/main' into refactor-one-python-e…
jussielo-amd Nov 5, 2026
61ae44a
Merge remote-tracking branch 'origin/main' into refactor-one-single-r…
jussielo-amd Nov 5, 2026
3e60035
Merge remote-tracking branch 'origin/main' into refactor-one-install-…
jussielo-amd Nov 5, 2026
cf10007
fix(comfyui): keep a --dry-run install preview from restoring the reg…
jussielo-amd Nov 6, 2026
049aa06
fix(runtimes): judge an install root manifest as current by what it d…
jussielo-amd Nov 6, 2026
bdb4d87
Merge refactor-one-python-env-root-rule into the runtime-install PR
jussielo-amd Nov 6, 2026
78de17d
Merge refactor-one-single-ready-runtime-rule into the runtime-install PR
jussielo-amd Nov 6, 2026
6f043a8
Merge refactor-one-install-root-payload-and-os-release-rule into the …
jussielo-amd Nov 6, 2026
02506ce
fix(comfyui): let an explicit runtime choice find the setup runtime a…
jussielo-amd Nov 6, 2026
f5d730b
fix(comfyui): report a registry that cannot take the setup runtime ba…
jussielo-amd Nov 6, 2026
fa5b41e
fix(comfyui): set aside an unusable setup runtime while a registered …
jussielo-amd Nov 6, 2026
f82b274
fix(runtimes): write the registry entry after the install-root manifest
jussielo-amd Nov 6, 2026
1d6be02
test(runtimes): make the single-registry-writer guard read whole file…
jussielo-amd Nov 6, 2026
5efc8eb
test(comfyui): fix clippy findings in the runtime selection state matrix
jussielo-amd Nov 6, 2026
92515aa
Merge remote-tracking branch 'origin/main' into rf-934d
jussielo-amd Nov 6, 2026
53d7107
fix(runtimes): count a file builder as a write only when a write opti…
jussielo-amd Nov 6, 2026
0a3ff17
Merge remote-tracking branch 'origin/main' into rf-934d
jussielo-amd Nov 6, 2026
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 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,9 @@ exits without prompting or making changes.

`adopt` registers an existing TheRock-based Python environment as a managed
runtime. It does not work with standard ROCm package installs (for example,
`/opt/rocm`); use `rocm install sdk` instead.
`/opt/rocm`); use `rocm install sdk` instead. Without `--root`, the environment
folder is the one that holds the `--python` interpreter's `bin` (or `Scripts`)
folder; an interpreter anywhere else is refused until you pass `--root`.

### Disk space

Expand Down
2 changes: 1 addition & 1 deletion apps/rocm/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ left, so it cannot undo more than one activation."
/// Python executable inside the existing ROCm environment.
#[arg(long)]
python: PathBuf,
/// Optional SDK root path.
/// Python environment folder. Taken from --python when that sits in a bin or Scripts folder; required otherwise.
#[arg(long)]
root: Option<PathBuf>,
/// Runtime id to assign.
Expand Down
174 changes: 173 additions & 1 deletion apps/rocm/src/comfyui/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use super::{
};
use crate::cli_progress::AnimatedSpinner;
use crate::freeform_planner::format_structured_tool_call;
use crate::runtime_adopt::SetupRecovery;
use crate::therock;
use anyhow::{Context, Result, bail};
use flate2::read::GzDecoder;
Expand All @@ -48,7 +49,14 @@ pub(crate) fn install(
options: ComfyUiInstallOptions,
) -> Result<String> {
paths.ensure()?;
let runtime = select_runtime(paths, config, options.runtime_id.as_deref())?;
// A preview names the runtime the real run will use but does not write the
// registry entry that run would restore.
let runtime = select_runtime(
paths,
config,
options.runtime_id.as_deref(),
SetupRecovery::for_dry_run(options.dry_run),
)?;
let app_root = runtime_app_root(&runtime.manifest);
let source_path = source_path_from_app_root(&app_root);
let log_path = install_log_path_from_app_root(&app_root);
Expand Down Expand Up @@ -1908,6 +1916,170 @@ mod tests {
remove_test_root(&paths);
Ok(())
}

/// `--dry-run` promises not to change files. With nothing chosen, the install
/// finds the runtime `rocm setup` created even though its registry entry was
/// lost, but a preview must not write that entry back: it names the same
/// runtime the real run will use and leaves the registry as it found it.
#[test]
fn dry_run_previews_the_setup_runtime_without_restoring_its_registry_entry() -> Result<()> {
let paths = test_paths("comfyui-dry-run-setup-runtime");
let manifest = crate::test_support::write_test_setup_runtime_missing_from_registry(
&paths,
"release-pip-gfx120x-all-7-14-0",
)?;
let config = RocmCliConfig::load(&paths)?;
assert_eq!(
crate::test_support::runtime_registry_entry_names(&paths),
Vec::<String>::new()
);

let rendered = install(
&paths,
&config,
ComfyUiInstallOptions {
runtime_id: None,
reinstall: false,
dry_run: true,
},
)?;

assert!(rendered.contains(" mode: dry-run\n"), "{rendered}");
assert!(
rendered.contains(&format!(
" ROCm runtime: {}\n",
therock::runtime_version_display(&manifest.version)
)),
"{rendered}"
);
assert!(
rendered
.lines()
.any(|line| line.contains("install command:")
&& line.contains(&format!("--runtime-id {}", manifest.runtime_key))),
"{rendered}"
);
assert_eq!(
crate::test_support::runtime_registry_entry_names(&paths),
Vec::<String>::new(),
"a preview must not restore the registry entry"
);
remove_test_root(&paths);
Ok(())
}

/// A runtime that setup created and the registry forgot, with a cached
/// ComfyUI archive and a fake interpreter, so a real install into it needs
/// no network and no GPU.
#[cfg(unix)]
fn setup_runtime_the_registry_forgot(
name: &str,
) -> Result<(AppPaths, RocmCliConfig, therock::InstalledRuntimeManifest)> {
let paths = test_paths(name);
let manifest = crate::test_support::write_test_setup_runtime_missing_from_registry(
&paths,
"release-pip-gfx120x-all-7-14-0",
)?;
let config = RocmCliConfig::load(&paths)?;
let app_root = runtime_app_root(&manifest);
plant_cached_source_archive(
&app_root,
&[("main.py", "new main"), ("requirements.txt", "torch\n")],
)?;
let python = PathBuf::from(
manifest
.python_executable
.as_deref()
.context("runtime has no Python")?,
);
rocm_core::fake_executable::write_fake_executable(
&python,
"#!/bin/sh\nprintf '%s' '{\"torch_version\": \"2.4.0\", \"torch_cuda_available\": true, \"device_count\": 1, \"devices\": [\"Fake GPU\"]}' > \"$2\"\n",
)?;
Ok((paths, config, manifest))
}

/// The preview prints the install command it would run, and that command
/// has to work from the state the preview left: the registry still without
/// the entry. Its `--runtime-id` is an explicit choice, which used to look
/// only in the registry and fail with "Install ROCm first". Following the
/// printed command previews again without a write, and runs for real with
/// the one write the real run makes.
#[cfg(unix)]
#[test]
fn the_printed_install_command_works_from_the_state_the_preview_left() -> Result<()> {
let (paths, config, manifest) =
setup_runtime_the_registry_forgot("comfyui-printed-command-setup-runtime")?;
let options = |runtime_id: Option<String>, dry_run| ComfyUiInstallOptions {
runtime_id,
reinstall: false,
dry_run,
};
let printed_runtime_id = |rendered: &str| -> Result<String> {
let line = rendered
.lines()
.find(|line| line.contains("install command:"))
.with_context(|| format!("the preview prints its command:\n{rendered}"))?;
let words: Vec<&str> = line.split_whitespace().collect();
let at = words
.iter()
.position(|word| *word == "--runtime-id")
.context("the printed command names the runtime")?;
Ok(words[at + 1].to_owned())
};

let preview = install(&paths, &config, options(None, true))?;
let printed = printed_runtime_id(&preview)?;
assert_eq!(printed, manifest.runtime_key, "{preview}");
assert!(
crate::test_support::runtime_registry_entry_names(&paths).is_empty(),
"the premise: the preview leaves the registry without the entry"
);

let again = install(&paths, &config, options(Some(printed.clone()), true))
.context("the printed command, previewed again")?;
assert_eq!(printed_runtime_id(&again)?, printed, "{again}");
assert!(
crate::test_support::runtime_registry_entry_names(&paths).is_empty(),
"previewing the printed command must not write the entry either"
);

install(&paths, &config, options(Some(printed), false))
.context("the printed command, run for real")?;
assert_eq!(
crate::test_support::runtime_registry_entry_names(&paths),
vec![format!("{}.json", manifest.runtime_key)],
"the real run restores the entry the printed command's runtime needs"
);
remove_test_root(&paths);
Ok(())
}

/// The other half: the real run does restore the entry, so the runtime the
/// preview named is one `rocm runtimes list` shows once the install has run.
#[cfg(unix)]
#[test]
fn install_restores_the_setup_runtime_registry_entry_the_preview_left_alone() -> Result<()> {
let (paths, config, manifest) =
setup_runtime_the_registry_forgot("comfyui-install-setup-runtime")?;

install(
&paths,
&config,
ComfyUiInstallOptions {
runtime_id: None,
reinstall: false,
dry_run: false,
},
)?;

assert_eq!(
crate::test_support::runtime_registry_entry_names(&paths),
vec![format!("{}.json", manifest.runtime_key)]
);
remove_test_root(&paths);
Ok(())
}
}

/// Property tests for the ComfyUI source unpack, judged on the filesystem by
Expand Down
Loading
Loading