Repository navigation
feat(runtimes): show runtime provenance in list and examine (ROCMAI-189) #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2ab661
89e63fe
9f0c1a5
1cbfe46
0e898a8
6896878
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,9 +29,9 @@ use rocm_core::{ | |
| }; | ||
|
|
||
| use crate::runtime_registry::{ | ||
| ManifestOverwrite, paths_equivalent, runtime_manifest_path, runtime_registry_dir, | ||
| sort_manifests_newest_install_first, validate_runtime_manifest_for_activation, | ||
| write_runtime_manifest, | ||
| ADOPTED_RUNTIME_ARTIFACT_URL, ManifestOverwrite, paths_equivalent, runtime_manifest_path, | ||
| runtime_registry_dir, sort_manifests_newest_install_first, | ||
| validate_runtime_manifest_for_activation, write_runtime_manifest, | ||
| }; | ||
| use crate::therock; | ||
|
|
||
|
|
@@ -298,7 +298,7 @@ pub(crate) fn adopt_runtime_from_probe( | |
| family_source: "runtime_id".to_owned(), | ||
| version, | ||
| install_root: install_root.clone(), | ||
| selected_artifact_url: "adopted-read-only".to_owned(), | ||
| selected_artifact_url: ADOPTED_RUNTIME_ARTIFACT_URL.to_owned(), | ||
| source_layout_generation: None, | ||
| index_url: None, | ||
| tarball_file_name: None, | ||
|
|
@@ -644,12 +644,36 @@ mod tests { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// The other half of the same derivation: an adopted environment that does | ||
| /// expose a CMake path has the toolchain, and the manifest must say so or | ||
| /// the next `rocm update` would quietly reinstall without it. | ||
| #[test] | ||
| fn runtime_adopt_records_devel_when_the_probe_finds_cmake() -> Result<()> { | ||
| let (root, paths) = test_paths("runtime-adopt-devel"); | ||
| /// Adopts a fake external TheRock venv under `root` whose probe reports a | ||
| /// CMake path, through the same `adopt_runtime_from_probe` that | ||
| /// `rocm runtimes adopt` runs, and returns the manifest it registered. | ||
| fn adopt_test_runtime( | ||
| root: &Path, | ||
| paths: &AppPaths, | ||
| ) -> Result<therock::InstalledRuntimeManifest> { | ||
| adopt_test_runtime_with(root, paths, TestAdoptRequest::HandBuilt) | ||
| } | ||
|
|
||
| /// How [`adopt_test_runtime_with`] builds its adoption request. | ||
| enum TestAdoptRequest { | ||
| /// A request with the runtime id and key spelled out. | ||
| HandBuilt, | ||
| /// The request `rocm runtimes adopt` builds, through | ||
| /// [`infer_adopt_runtime_request`]; `runtime_id` is `--runtime-id` and | ||
| /// `channel` is `--channel`. | ||
| Inferred { | ||
| runtime_id: Option<&'static str>, | ||
| channel: Option<&'static str>, | ||
| }, | ||
| } | ||
|
|
||
| /// Adopts a fake external environment, building the request as `request` | ||
| /// says. | ||
| fn adopt_test_runtime_with( | ||
| root: &Path, | ||
| paths: &AppPaths, | ||
| request: TestAdoptRequest, | ||
| ) -> Result<therock::InstalledRuntimeManifest> { | ||
| let external_root = root.join("external-therock-venv"); | ||
| let scripts_dir = external_root.join(if cfg!(windows) { "Scripts" } else { "bin" }); | ||
| let python_executable = scripts_dir.join(if cfg!(windows) { | ||
|
|
@@ -680,38 +704,59 @@ mod tests { | |
| fs::write(&amdhip, "amdhip")?; | ||
| fs::write(&hipblas, "hipblas")?; | ||
|
|
||
| let adopted = adopt_runtime_from_probe( | ||
| &paths, | ||
| AdoptRuntimeRequest { | ||
| let probe = therock::RocmSdkPythonProbe { | ||
| import_ok: true, | ||
| rocm_sdk_version: Some("7.13.0".to_owned()), | ||
| root_path: Some(sdk_root.clone()), | ||
| bin_path: Some(sdk_bin.clone()), | ||
| cmake_path: Some(cmake_path), | ||
| runtime_roots: vec![sdk_root], | ||
| bin_paths: vec![sdk_bin.clone()], | ||
| library_paths: vec![sdk_bin], | ||
| resolved_libraries: vec![ | ||
| therock::RocmSdkLibraryProbe { | ||
| shortname: "amdhip64".to_owned(), | ||
| paths: vec![amdhip], | ||
| }, | ||
| therock::RocmSdkLibraryProbe { | ||
| shortname: "hipblas".to_owned(), | ||
| paths: vec![hipblas], | ||
| }, | ||
| ], | ||
| resolved_target_family: Some("gfx120X-all".to_owned()), | ||
| ..therock::RocmSdkPythonProbe::default() | ||
| }; | ||
| let request = match request { | ||
| TestAdoptRequest::HandBuilt => AdoptRuntimeRequest { | ||
| python_executable, | ||
| install_root: external_root, | ||
| runtime_id: "therock-release:gfx120X-all".to_owned(), | ||
| runtime_key: "adopted-release-pip-gfx120x-all-7-13-0".to_owned(), | ||
| replace: false, | ||
| }, | ||
| therock::RocmSdkPythonProbe { | ||
| import_ok: true, | ||
| rocm_sdk_version: Some("7.13.0".to_owned()), | ||
| root_path: Some(sdk_root.clone()), | ||
| bin_path: Some(sdk_bin.clone()), | ||
| cmake_path: Some(cmake_path), | ||
| runtime_roots: vec![sdk_root], | ||
| bin_paths: vec![sdk_bin.clone()], | ||
| library_paths: vec![sdk_bin], | ||
| resolved_libraries: vec![ | ||
| therock::RocmSdkLibraryProbe { | ||
| shortname: "amdhip64".to_owned(), | ||
| paths: vec![amdhip], | ||
| }, | ||
| therock::RocmSdkLibraryProbe { | ||
| shortname: "hipblas".to_owned(), | ||
| paths: vec![hipblas], | ||
| }, | ||
| ], | ||
| resolved_target_family: Some("gfx120X-all".to_owned()), | ||
| ..therock::RocmSdkPythonProbe::default() | ||
| }, | ||
| )?; | ||
| TestAdoptRequest::Inferred { | ||
| runtime_id, | ||
| channel, | ||
| } => infer_adopt_runtime_request( | ||
| python_executable, | ||
| Some(external_root), | ||
| runtime_id.map(str::to_owned), | ||
| None, | ||
| channel.map(str::to_owned), | ||
| false, | ||
| &probe, | ||
| )?, | ||
| }; | ||
| adopt_runtime_from_probe(paths, request, probe) | ||
| } | ||
|
|
||
| /// The other half of the same derivation: an adopted environment that does | ||
| /// expose a CMake path has the toolchain, and the manifest must say so or | ||
| /// the next `rocm update` would quietly reinstall without it. | ||
| #[test] | ||
| fn runtime_adopt_records_devel_when_the_probe_finds_cmake() -> Result<()> { | ||
| let (root, paths) = test_paths("runtime-adopt-devel"); | ||
| let adopted = adopt_test_runtime(&root, &paths)?; | ||
|
|
||
| assert!( | ||
| adopted.devel, | ||
|
|
@@ -722,6 +767,49 @@ mod tests { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Adoption installs nothing, so there is no package source to name: the | ||
| /// manifest's artifact URL holds only the adoption marker. The listing must | ||
| /// say the source was not recorded rather than present that marker as one. | ||
| /// The channel is the one adoption recorded, for each way the request | ||
| /// `rocm runtimes adopt` builds can name it: adoption's default, `release`, | ||
| /// when neither `--channel` nor `--runtime-id` names one; `nightly` after | ||
| /// `--channel nightly`; and `nightly` after `--runtime-id | ||
| /// therock-nightly:<family>` with no `--channel`, where the channel comes | ||
| /// from the runtime id alone. The family is the one the test probe reports. | ||
| #[test] | ||
| fn adopted_runtime_lists_its_channel_and_its_source_as_unrecorded() -> Result<()> { | ||
| for (runtime_id_flag, channel_flag, expected_channel) in [ | ||
| (None, None, "release"), | ||
| (None, Some("nightly"), "nightly"), | ||
| (Some("therock-nightly:gfx120X-all"), None, "nightly"), | ||
| ] { | ||
| let flags = format!("--runtime-id {runtime_id_flag:?} --channel {channel_flag:?}"); | ||
| let (root, paths) = test_paths("runtime-adopt-provenance"); | ||
| let adopted = adopt_test_runtime_with( | ||
| &root, | ||
| &paths, | ||
| TestAdoptRequest::Inferred { | ||
| runtime_id: runtime_id_flag, | ||
| channel: channel_flag, | ||
| }, | ||
| )?; | ||
| let rendered = | ||
| crate::runtimes_cmd::render_runtimes_text(&paths, &RocmCliConfig::default())?; | ||
| let _ = fs::remove_dir_all(root); | ||
|
|
||
| assert_eq!(adopted.channel, expected_channel, "{flags}"); | ||
| assert_eq!( | ||
| crate::runtimes_cmd::tests::provenance_line(&rendered, &adopted.runtime_key), | ||
| format!( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reaches into
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point. |
||
| " provenance: channel={expected_channel} source=unrecorded \ | ||
| source_layout_generation=unrecorded device_target=unrecorded" | ||
| ), | ||
| "{flags}:\n{rendered}" | ||
| ); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runtime_adopt_request_infers_ids_from_probe() -> Result<()> { | ||
| let (root, _) = test_paths("runtime-adopt-infer"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The precedence chain (index else artifact URL, layout field else composition, trim/blank handling) is implementation detail that the unit test already pins and will drift here; consider keeping the README to the user-visible facts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. The README states the same precedence rules that
runtime_list_reads_each_provenance_fact_from_where_it_was_recordedalready pins, and one commit on this branch existed only to fix copies that had drifted apart. I've recorded a follow-up on ROCMAI-189 to cut the README down to what a user sees: the four fields,unrecorded, that nothing is guessed, and the adopted-runtime rule. The chains would then live only in theprovenance()doc comment, with docs/testing.md pointing at it.