Skip to content
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: validate machine using lockfile #2849

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

ruben-arts
Copy link
Contributor

@ruben-arts ruben-arts commented Jan 7, 2025

Why:

This PR tries to make the running of environments more flexible. The system-requirements were previously checked before you could run an environment. This PR changes that to only allow installation of a prefix if all virtual packages are matched with the requirements in the lockfile. This results in a less strict rule, as we don't let the user the requirements (Now this became an even worse name).

Resulting in the following benefits:

  • Having a system-requirement on cuda would still allow an environment to be installed on Mac.
  • Having a strict system-requirement while there aren't actually packages that require it, allows the user to still run it.

Manifests that will now work but didn't work before:

[project]
channels = ["https://prefix.dev/conda-forge"]
name = "pytorch-conda-forge"
platforms = ["linux-64", "osx-arm64", "osx-64"]

# This could have been fixed with the `[target.linux.system-requirements]` if that existed but this also works as a result of this feature.
[system-requirements]
cuda = "12.0"

[target.linux.dependencies]
cuda-version = "==12.6"
pytorch-gpu = "*"

[dependencies]
python = "3.12.*"
[project]
channels = ["https://prefix.dev/conda-forge"]
name = "pytorch-conda-forge"
platforms = ["linux-64", "osx-arm64", "osx-64"]

[system-requirements]
libc = "123.0"

[dependencies]
python = "3.12.*"

Draft because:

  • I broke the logic that tasks can be checked if they run on a system (as there is no promise of a lockfile), not sure what to do yet.
  • PyPI also needs logic to validate the wheel tags against the machine.
  • Better testing, which is now even harder as the logic has more dependencies (lockfile)
  • Get feat: Match GenericVirtualPackage with MatchSpec conda/rattler#1016 in rattler merged and use the release
  • Run all tests before merging, label: test:extra_slow

@ruben-arts ruben-arts added the UX Related to the User Experience of pixi label Jan 7, 2025
@ruben-arts ruben-arts marked this pull request as draft January 9, 2025 15:43
@ruben-arts ruben-arts added the test:extra_slow Run the extra slow tests label Jan 10, 2025
crates/pypi_modifiers/Cargo.toml Outdated Show resolved Hide resolved
src/cli/run.rs Outdated Show resolved Hide resolved
@@ -249,7 +244,6 @@ fn command_not_found<'p>(project: &'p Project, explicit_environment: Option<Envi
project
.environments()
.into_iter()
.filter(|env| verify_current_platform_has_required_virtual_packages(env).is_ok())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this causes all tasks to be shown regardless of whether the current system supports it. Should we maybe call a function here to check that?

src/cli/task.rs Outdated
Comment on lines 405 to 413
if verify_current_platform_has_required_virtual_packages(env).is_ok() {
Some((env.clone(), env.get_filtered_tasks()))
} else {
None
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my comment above, perhaps we can call a function to see if a certain environment is supported by the current platform.

@@ -465,12 +458,7 @@ fn build_env_feature_task_map(project: &Project) -> Vec<EnvTasks> {
.environments()
.iter()
.sorted_by_key(|env| env.name().to_string())
.filter_map(|env: &Environment<'_>| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

src/lock_file/update.rs Outdated Show resolved Hide resolved
src/lock_file/virtual_packages.rs Outdated Show resolved Hide resolved
let conda_records = environment
.conda_repodata_records(platform)
.map_err(VirtualPackageError::RepodataConversionError)?
.ok_or(VirtualPackageError::NoCondaRecordsFound(platform))?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that bad? It means there is an environment but that specific environment is empty. I guess its installable then?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually have a legitimate use case for empty environments: tasks that use software not managed by pixi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should indeed not error on an empty environment, I'm also a big user of that as a feature ;)

src/lock_file/virtual_packages.rs Outdated Show resolved Hide resolved
@@ -150,11 +148,6 @@ impl<'p, D: TaskDisambiguation<'p>> SearchEnvironments<'p, D> {
.iter()
// Filter out default environment
.filter(|env| !env.name().is_default())
// Filter out environments that can not run on this machine.
.filter(|env| {
self.ignore_system_requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be added back somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently implemented it in such a way that it only checks the platform but this would ambigue the cuda vs non cuda tasks.... I think I'll still have to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test:extra_slow Run the extra slow tests UX Related to the User Experience of pixi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants