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

Retain and index downloads when locking. #1650

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Mar 7, 2022

For the local case of lock create and then later resolve, it will be
good to retain the (primary) artifacts downloaded by Pip for the local
interpreter when creating the lock in order to save downloading those
artifacts again when later resolving from the lock.

Work towards #1583.

For the local case of lock create and then later resolve, it will be
good to retain the (primary) artifacts downloaded for the local
interpreter when creating the lock used to lock in order to save
downloading those artifacts again when later resolving from the lock.

Work towards pex-tool#1583.
return str(fp.read().decode("ascii"))


class DownloadManager(object):
Copy link
Member Author

Choose a reason for hiding this comment

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

N.B.: The forthcoming lock resolver will have its own implementation of this; thus factoring up the logic of where to store downloads for re-use / cache-hits centrally here.

# type: (Artifact) -> DownloadedArtifact

download_dir = os.path.join(self._download_dir, artifact.fingerprint.hash)
with atomic_directory(download_dir, exclusive=True) as atomic_dir:
Copy link
Member Author

@jsirois jsirois Mar 7, 2022

Choose a reason for hiding this comment

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

There is actually no need for this to be exclusive in this PR; however the lock resolver will also be implementing this and fetching URLs directly from PyPI most of the time. The exclusive lock will prevent two independent processes from trying to download the same artifact from PyPI concurrently and relieve a little pressure from PyPI as a result.

@jsirois jsirois merged commit 9b18a06 into pex-tool:main Mar 7, 2022
@jsirois jsirois deleted the issues/1583/lockfile-resolve/save-lock-downloads branch March 7, 2022 18:24
pex/resolve/lockfile/__init__.py Show resolved Hide resolved
pex/resolve/lockfile/download_manager.py Show resolved Hide resolved
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.

3 participants