-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat: Add support for CONDA_OVERRIDE_CUDA
#818
Conversation
CONDA_OVERRIDE_CUDA
CONDA_OVERRIDE_CUDA
CONDA_OVERRIDE_CUDA
CONDA_OVERRIDE_CUDA
@@ -26,10 +27,14 @@ pub fn cuda_version() -> Option<Version> { | |||
.clone() | |||
} | |||
|
|||
const CUDA_OVERRIDE_ENV: &str = "CONDA_OVERRIDE_CUDA"; | |||
/// Attempts to detect the version of CUDA present in the current operating system by employing the | |||
/// best technique available for the current environment. | |||
pub fn detect_cuda_version() -> Option<Version> { |
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.
This function should be pure functional without environmental side-effects.
Instead I propose we add some sort of from_env
function to the appropriate virtual packages that allow users to choose whether they want this behavior. Or a or_override_with_env_var
or something along those lines.
We should also debate the environment variable name. I believe conda has a different name? Im also not sure whether we should hardcode that in rattler itself.
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.
This function should be pure functional without environmental side-effects.
But the function is already not pure because it runs shell commands/dlopens libraries.
Instead I propose we add some sort of from_env function to the appropriate virtual packages that allow users to choose whether they want this behavior. Or a or_override_with_env_var or something along those lines.
I'm not sure I understand. where would this be? in the config?
We should also debate the environment variable name.
This is the name see here
I think this would also be good for all the other virtual packages as a way to hot-fix certain scenarios that we haven't covered yet (#815 for example). |
My idea would be to add functions to the virtual package implementations. Lets take CUDA as an example, we would add these functions to the impl Cuda {
pub fn from_env_var_name(env_var_name: &str) -> Option<Self> {
let version_str = env::var(env_var_name)?;
// Extract versions
...
}
pub fn from_default_env_var() -> Option<Self> {
Self::from_env_var_name("CONDA_OVERRIDE_CUDA")
}
...
} You can then write: let cuda = Cuda::from_default_env_var().or_else(Cuda::current); To get the CUDA version of the system based on env var, or if not present by detecting it. Similarly a function I think this allows:
Which I think hits the sweet spot. And indeed as @wolfv said, it would be nice to add these for the other virtual packages as well. |
oh, yeah that looks great! |
Does this make sense as a rough draft? |
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.
Yeah that looks a lot better! I left a few comments.
I think there is one issue, finding the environment variable and it being empty is different than the environment variable not being present, should the type be |
I think everything should have been handled gracefully. |
Do we want to override the glibc runtime? like |
Suggestion-- could this be done in a followup PR? Landing |
Anything else needed to get this over the finish line? This is a blocker for us switching fully over to rattler so happy to dedicate to some time to any remaining blockers in getting this merged. |
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.
This looks good! Ill take a closer look at the CI failure tomorrow!
This should solve some of the failure, pre-commit is not ran by default |
Are there any implications for pyrattler from this PR btw? Anything new that should be exposed? |
I don't think pyrattler has any implication for pixi, so I'd rather this be merged w/o py-rattler support. My understanding is that in But I think that someone else has probably a better idea. |
@baszalmstra It's very inconvenient that the checks require maintainer auth. |
Yes, but once your first PR lands that restriction is lifted 👍 |
oh nice! |
I think it would be good to also expose this functionality to the python bindings, but we can do that in another PR. Thanks for your first contribution @SobhanMP ! |
@baszalmstra I think this first requires figuring out #818 (comment) . I think option 2 makes the most sense. |
The next thing is where this should be used. Should |
## 🤖 New release * `rattler_conda_types`: 0.27.2 -> 0.27.3 * `rattler_package_streaming`: 0.22.3 -> 0.22.4 * `rattler_lock`: 0.22.20 -> 0.22.21 * `rattler_solve`: 1.0.3 -> 1.0.4 * `rattler_virtual_packages`: 1.0.4 -> 1.1.0 * `rattler_index`: 0.19.24 -> 0.19.25 * `rattler`: 0.27.6 -> 0.27.7 * `rattler_cache`: 0.1.8 -> 0.1.9 * `rattler_shell`: 0.21.6 -> 0.21.7 * `rattler_repodata_gateway`: 0.21.8 -> 0.21.9 <details><summary><i><b>Changelog</b></i></summary><p> ## `rattler_conda_types` <blockquote> ## [0.27.3](rattler_conda_types-v0.27.2...rattler_conda_types-v0.27.3) - 2024-09-02 ### Added - add edge case tests for `StringMatcher` ([#839](#839)) </blockquote> ## `rattler_package_streaming` <blockquote> ## [0.22.4](rattler_package_streaming-v0.22.3...rattler_package_streaming-v0.22.4) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([#818](#818)) ### Fixed - zip large files compression ([#838](#838)) </blockquote> ## `rattler_lock` <blockquote> ## [0.22.21](rattler_lock-v0.22.20...rattler_lock-v0.22.21) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([#818](#818)) </blockquote> ## `rattler_solve` <blockquote> ## [1.0.4](rattler_solve-v1.0.3...rattler_solve-v1.0.4) - 2024-09-02 ### Fixed - Redact spec channel before comparing it with repodata channel ([#831](#831)) ### Other - Remove note that only libsolv is supported ([#832](#832)) </blockquote> ## `rattler_virtual_packages` <blockquote> ## [1.1.0](rattler_virtual_packages-v1.0.4...rattler_virtual_packages-v1.1.0) - 2024-09-02 ### Added - start adding interface to override ([#834](#834)) - Add support for `CONDA_OVERRIDE_CUDA` ([#818](#818)) ### Other - make virtual package overrides none by default consistently ([#842](#842)) </blockquote> ## `rattler_index` <blockquote> ## [0.19.25](rattler_index-v0.19.24...rattler_index-v0.19.25) - 2024-09-02 ### Other - release ([#824](#824)) </blockquote> ## `rattler` <blockquote> ## [0.27.7](rattler-v0.27.6...rattler-v0.27.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming </blockquote> ## `rattler_cache` <blockquote> ## [0.1.9](rattler_cache-v0.1.8...rattler_cache-v0.1.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming </blockquote> ## `rattler_shell` <blockquote> ## [0.21.7](rattler_shell-v0.21.6...rattler_shell-v0.21.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types </blockquote> ## `rattler_repodata_gateway` <blockquote> ## [0.21.9](rattler_repodata_gateway-v0.21.8...rattler_repodata_gateway-v0.21.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
## 🤖 New release * `rattler_conda_types`: 0.27.2 -> 0.27.3 * `rattler_package_streaming`: 0.22.3 -> 0.22.4 * `rattler_lock`: 0.22.20 -> 0.22.21 * `rattler_solve`: 1.0.3 -> 1.0.4 * `rattler_virtual_packages`: 1.0.4 -> 1.1.0 * `rattler_index`: 0.19.24 -> 0.19.25 * `rattler`: 0.27.6 -> 0.27.7 * `rattler_cache`: 0.1.8 -> 0.1.9 * `rattler_shell`: 0.21.6 -> 0.21.7 * `rattler_repodata_gateway`: 0.21.8 -> 0.21.9 <details><summary><i><b>Changelog</b></i></summary><p> ## `rattler_conda_types` <blockquote> ## [0.27.3](conda/rattler@rattler_conda_types-v0.27.2...rattler_conda_types-v0.27.3) - 2024-09-02 ### Added - add edge case tests for `StringMatcher` ([conda#839](conda#839)) </blockquote> ## `rattler_package_streaming` <blockquote> ## [0.22.4](conda/rattler@rattler_package_streaming-v0.22.3...rattler_package_streaming-v0.22.4) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([conda#818](conda#818)) ### Fixed - zip large files compression ([conda#838](conda#838)) </blockquote> ## `rattler_lock` <blockquote> ## [0.22.21](conda/rattler@rattler_lock-v0.22.20...rattler_lock-v0.22.21) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([conda#818](conda#818)) </blockquote> ## `rattler_solve` <blockquote> ## [1.0.4](conda/rattler@rattler_solve-v1.0.3...rattler_solve-v1.0.4) - 2024-09-02 ### Fixed - Redact spec channel before comparing it with repodata channel ([conda#831](conda#831)) ### Other - Remove note that only libsolv is supported ([conda#832](conda#832)) </blockquote> ## `rattler_virtual_packages` <blockquote> ## [1.1.0](conda/rattler@rattler_virtual_packages-v1.0.4...rattler_virtual_packages-v1.1.0) - 2024-09-02 ### Added - start adding interface to override ([conda#834](conda#834)) - Add support for `CONDA_OVERRIDE_CUDA` ([conda#818](conda#818)) ### Other - make virtual package overrides none by default consistently ([conda#842](conda#842)) </blockquote> ## `rattler_index` <blockquote> ## [0.19.25](conda/rattler@rattler_index-v0.19.24...rattler_index-v0.19.25) - 2024-09-02 ### Other - release ([conda#824](conda#824)) </blockquote> ## `rattler` <blockquote> ## [0.27.7](conda/rattler@rattler-v0.27.6...rattler-v0.27.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming </blockquote> ## `rattler_cache` <blockquote> ## [0.1.9](conda/rattler@rattler_cache-v0.1.8...rattler_cache-v0.1.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming </blockquote> ## `rattler_shell` <blockquote> ## [0.21.7](conda/rattler@rattler_shell-v0.21.6...rattler_shell-v0.21.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types </blockquote> ## `rattler_repodata_gateway` <blockquote> ## [0.21.9](conda/rattler@rattler_repodata_gateway-v0.21.8...rattler_repodata_gateway-v0.21.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
Description
Hi, I know this is terrible, not elegant, etc, but I do think that having support for something in the spirit of CONDA_OVERRIDE_CUDA is necessary on academic HPC environments. Reasons include
I'm not really used to writing rust, so would be greatful for some guidance.
Thanks