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

Pin workerd local dev python package version numbers to match deployment #1707

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

garrettgu10
Copy link
Collaborator

During local development, we would like micropip to fetch the same version numbers as what's currently deployed on edgeworker. This PR hardcodes some version numbers used by edgeworker according to (https://github.com/dom96/pyodide_packages/releases) and makes sure that they are passed to micropip when installing the packages.

@garrettgu10 garrettgu10 requested review from a team as code owners February 21, 2024 21:18
@garrettgu10 garrettgu10 changed the title Pin workerd local dev version numbers to match EW deployment Pin workerd local dev python package version numbers to match EW deployment Feb 21, 2024
@garrettgu10 garrettgu10 changed the title Pin workerd local dev python package version numbers to match EW deployment Pin workerd local dev python package version numbers to match deployment Feb 21, 2024
@garrettgu10
Copy link
Collaborator Author

I couldn't find the version numbers for async_timeout or setuptools. @dom96 do you know what these are?

Copy link
Contributor

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Thanks @garrettgu10 this looks good to me for now. Eventually it would be nice to extract this from pyodide_packages.tar or something like that though since these will take some effort to update.

@hoodmane
Copy link
Contributor

I couldn't find the version numbers for async_timeout or setuptools.

As far as I can tell we aren't including them anymore and that was just out of date.

Copy link
Collaborator

@dom96 dom96 left a comment

Choose a reason for hiding this comment

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

We need to pin the dependencies as well, which this won't handle. But this is a good step in the right direction and we can iterate.

Please make sure to create a EW PR for this too to run the test suite there.

}

function addPinnedVersionToRequirement(requirement) {
if (requirement.includes("==")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should move this to the C++ and be even more strict: only allow characters which are valid package identifiers (so no spaces, no <, >, =, etc).

A good place for this would be workerd-api (and the equivalent in EW).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to do this in a separate PR.

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 it would be better to check for presence of the requirement against the lock file. That would also catch package names that we don't have / have a typo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hoodmane that would come after we disable micropip on edgeworker, right?

"anyio": "3.7.1",
"attrs": "23.2.0",
"certifi": "2024.2.2",
"charset_normalizer": "3.3.2",
Copy link
Collaborator Author

@garrettgu10 garrettgu10 Feb 22, 2024

Choose a reason for hiding this comment

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

@dom96 @hoodmane

I kept the underscores since that's what the original code said, but I think it might be necessary to normalize package names in this list as well as during lookup, since some users may use e.g. langchain-community in requirements.txt even though the name is langchain_community at import time.

But that might be better to put in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to have pretty similar logic to recursiveDependencies here:
https://github.com/pyodide/pyodide/blob/main/src/js/load-package.ts?plain=1#L186

In fact there's a pretty good chance we could use that same logic unchanged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point, yeah, normalization is a must.

@garrettgu10 garrettgu10 force-pushed the ggu/python-requirement-version-pinning branch from 1b324da to 4042bc3 Compare February 22, 2024 20:25
@garrettgu10 garrettgu10 merged commit 5dbeac2 into main Feb 22, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants