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

Propagate fork markers to extras #6065

Merged
merged 2 commits into from
Aug 14, 2024
Merged

Propagate fork markers to extras #6065

merged 2 commits into from
Aug 14, 2024

Conversation

charliermarsh
Copy link
Member

Summary

When constructing the Resolution, we only propagated the fork markers to the package node, but not the extras node. This led to cases in which an extra could be included unconditionally or otherwise diverge from the base package version.

Closes #6062.

@charliermarsh charliermarsh added bug Something isn't working resolver Related to the package resolver preview Experimental behavior labels Aug 13, 2024
@charliermarsh
Copy link
Member Author

This isn't quite doing the right thing in lock_python_version_marker_complement. I'm getting an instability there.

@charliermarsh
Copy link
Member Author

I think my change is correct but now hitting the aforementioned instability.

// true), but is a more robust approach that should
// capture all cases.
marker: self.markers.fork_markers().cloned().unwrap_or_default(),
marker: MarkerTree::TRUE,
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this into graph construction, since we're now AND-ing the fork markers with every edge.

{ name = "package-b", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "implementation_name == 'pypy'" },
{ name = "package-b", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "implementation_name == 'cpython'" },
{ name = "package-b", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "implementation_name == 'pypy' and sys_platform == 'darwin'" },
{ name = "package-b", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "implementation_name == 'cpython' and sys_platform == 'darwin'" },
Copy link
Member Author

Choose a reason for hiding this comment

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

These may not be strictly necessary... Because you can only reach this node on sys_platform == 'darwin'.

Copy link
Member Author

Choose a reason for hiding this comment

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

(Yeah confirmed. Is it wrong to include then?)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's wrong, but it does seem superfluous. But I'm okay to run with it for now.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

I think this looks right to me.

In terms of moving this PR forward, maybe I cherry pick this PR into my branch that will (hopefully) fix the instability issue? So it won't get merged right away, but it will be in an active branch somewhere.

@@ -1901,8 +1897,8 @@ dependencies = [
{ name = "packaging" },
{ name = "regex" },
{ name = "rich" },
{ name = "tensorflow-text", version = "2.7.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_system != 'Darwin'" },
{ name = "tensorflow-text", version = "2.15.0", source = { registry = "https://pypi.org/simple" }, marker = "platform_system != 'Darwin'" },
Copy link
Member Author

Choose a reason for hiding this comment

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

Ouch, not good!

{ name = "tensorflow-text", version = "2.7.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_system != 'Darwin'" },
{ name = "tensorflow-text", version = "2.15.0", source = { registry = "https://pypi.org/simple" }, marker = "platform_system != 'Darwin'" },
{ name = "tensorflow-text", version = "2.7.3", source = { registry = "https://pypi.org/simple" }, marker = "python_version < '3.13' and platform_system != 'Darwin'" },
{ name = "tensorflow-text", version = "2.15.0", source = { registry = "https://pypi.org/simple" }, marker = "python_version >= '3.13' and platform_system != 'Darwin'" },
Copy link
Member Author

Choose a reason for hiding this comment

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

So that's a bugfix.

Copy link
Member

Choose a reason for hiding this comment

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

Yup! ANd there's no extra here.

@@ -3144,7 +3144,7 @@ name = "redis"
version = "5.0.8"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "async-timeout", marker = "python_full_version < '3.11.[X]'" },
{ name = "async-timeout", marker = "python_full_version < '3.11.[X]' and python_version < '3.12'" },
Copy link
Member Author

Choose a reason for hiding this comment

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

This looks wrong. I don't know where it's coming from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Debugging this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven’t figured this out yet, I think I should understand why this is happening before we merge @BurntSushi though you’re welcome to cherry-pick.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh... I guess this is actually fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

I needed to see it with fresh eyes.

@charliermarsh
Copy link
Member Author

Very hard to explain but regarding the instability: it has to do with the fact that when we resolve without a lockfile, we create the fork on the dependencies of the project. So we iterate over all dependencies, then create forks.

When we resolve with a lockfile, we fork on the project itself... So when we go to solve for that project's dependencies, we already have a requires-python marker which we then apply to filter out certain dependencies.

@charliermarsh
Copy link
Member Author

That might need to be solved holistically, though fixing the normalization to detect disjointness for these would also help.

@charliermarsh
Copy link
Member Author

Basically, we end up with this bad fork due to the confusion:

DEBUG skipping iniconfig ; python_version >= '3.10' because of context resolver markers python_full_version > '3.10' and python_version < '3.10'
DEBUG skipping iniconfig ; python_version < '3.10' because of Requires-Python python_full_version > '3.10' and python_version > '3.10'

@charliermarsh
Copy link
Member Author

charliermarsh commented Aug 14, 2024

Rebasing on #6076 does fix one of the instabilities, but github_wikidata_bot is still unstable...

@charliermarsh charliermarsh force-pushed the charlie/ex branch 2 times, most recently from 99abf46 to fbefe60 Compare August 14, 2024 01:52
@charliermarsh charliermarsh changed the base branch from main to charlie/py-fork August 14, 2024 01:52
@charliermarsh charliermarsh changed the base branch from charlie/py-fork to main August 14, 2024 13:37
@BurntSushi
Copy link
Member

but github_wikidata_bot is still unstable

Is this the only issue? If so, I'd say flip this test to non-deterministic (like transformers) via lock_ecosystem_package_non_deterministic and merge it. That way we're working from a common base and because this PR fixes bugs where there are multiple versions of the same package for the same marker environment in the lock file.

@charliermarsh
Copy link
Member Author

Yeah will do. lock_python_version_marker_complement and lock_conditional_dependency_extra also became non-deterministic, but some of those are fixed upstream I think. I'm gonna document and merge.

@charliermarsh charliermarsh merged commit 4a902a7 into main Aug 14, 2024
57 checks passed
@charliermarsh charliermarsh deleted the charlie/ex branch August 14, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Experimental behavior resolver Related to the package resolver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extras are sometimes not collapsed properly
2 participants