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

fix: Guard against removing package while uploading to it #64

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Feb 15, 2024

Resolves #57

  • On Anaconda Cloud as of 2024-01-04, if a wheel is being uploaded to a package, but the package only has one wheel in it and is of the same name as the uploaded wheel, Anaconda Cloud will overwrite the file by removing the file from the package index. However, when this happens it removes the entire package, and then the wheel that is in the process of being uploaded has no destination and the upload fails. To guard against this, ensure for each package that has a wheel being uploaded if:

    • there is only one release for the package
    • and only 1 file for that release
    • and the upload target wheel has the same name as the file
    • that the file (and so the package) is removed in advance of the
      upload.
  • To make filtering names and versions from wheels easier, add a get_wheel_name_version function that uses as regex to lazily capture the package name as well as the version and then return these.

    • Examples of this working:
      • "matplotlib-3.9.0.dev0-pp39-pypy39_pp73-win_amd64.whl"
        matplotlib 3.9.0.dev0

      • "scikit_learn-1.5.dev0-cp39-cp39-win_amd64.whl"
        scikit_learn 1.5.dev0

      • "scipy-openblas64-0.3.26.186-py3-none-macosx_10_9_x86_64.whl"
        scipy-openblas64 0.3.26.186

      • "awkward_cpp-29-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
        awkward_cpp 29

      • "awkward-2.6.1-py3-none-any.whl"
        awkward 2.6.1

  • As this requires curl and jq also add these to the environment and relock.

  • Add a extra upload in CI to thest this behavior.

In the future there will hopefully be a fix on Anaconda Cloud's side given anaconda/anaconda-client#702 but we need a solution now.

@matthewfeickert matthewfeickert added enhancement New feature or request CI labels Feb 15, 2024
@matthewfeickert matthewfeickert self-assigned this Feb 15, 2024
cmd.sh Outdated Show resolved Hide resolved
cmd.sh Show resolved Hide resolved
@matthewfeickert
Copy link
Member Author

@kenodegard @dholth as you know the Anaconda Cloud web APIs better than I do, if you would have time to review the changes to cmd.sh and let me know if there are better API calls to be making that would be excellent and much appreciated.

@matthewfeickert matthewfeickert requested a review from a team February 15, 2024 20:32
@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 19, 2024

@scientific-python/nightly-wheels-developers If it would be possible to get a review early this week it would be great to get this in so that I can create a new patch release with this.

(I'm assuming when I tag @scientific-python/nightly-wheels-developers that everyone on the team gets a notification except me (the tagger), but I'm not sure if that's correct or not.)

cmd.sh Outdated Show resolved Hide resolved
* On Anaconda Cloud as of 2024-01-04, if a wheel is being uploaded to a
  package, but the package only has one wheel in it and is of the same
  name as the uploaded wheel, Anaconda Cloud will overwrite the file by
  _removing_ the file from the package index. However, when this happens
  it removes the entire package, and then the wheel that is in the
  process of being uploaded has no destination and the upload fails.
  To guard against this, ensure for each package that has a wheel being
  uploaded if:
   - there is only one release for the package
   - and only 1 file for that release
   - and the upload target wheel has the same name as the file
   - that the file (and so the package) is removed in advance of the
     upload.
* To make filtering names and versions from wheels easier, add a
  get_wheel_name_version function that uses as regex to lazily capture
  the package name as well as the version and then return these.
   - Examples of this working:
     * "matplotlib-3.9.0.dev0-pp39-pypy39_pp73-win_amd64.whl"
       matplotlib 3.9.0.dev0

     * "scikit_learn-1.5.dev0-cp39-cp39-win_amd64.whl"
       scikit_learn 1.5.dev0

     * "scipy-openblas64-0.3.26.186-py3-none-macosx_10_9_x86_64.whl"
       scipy-openblas64 0.3.26.186

     * "awkward_cpp-29-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
       awkward_cpp 29
* As Anaconda Cloud normalizes package names, also distinguish between
  basename and package name to try to make things easier to keep track
  of when normalizing.
  * Example:
     - basename: test_package-0.0.1-py3-none-any.whl
     - basename prefix: test_package
     - package_name: test-package
@matthewfeickert
Copy link
Member Author

@scientific-python/nightly-wheels-developers Ping again on this, as given that apparently merging now requires a minimum of 1 review this can't get merged until someone reviews.

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 21, 2024

Thanks @jarrodmillman! I'm going to relock, merge, and then prep a new minor release as this add behavior without introducing breaking changes.

* As curl and jq are now used in cmd.sh, they need to also be added to
  the conda environment.yml.
* The lower bounds are chosen as the latest values, but are not
  motivated by known problems.
* Rebuild the lock file.
* Add a test that triggers the conditions for removal of a package from
  Anaconda Cloud in advance of its upload to avoid an error.
@matthewfeickert matthewfeickert merged commit 95f7bf6 into main Feb 21, 2024
2 checks passed
@matthewfeickert matthewfeickert deleted the fix/check-if-removing-will-delete-package branch February 21, 2024 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload of package version of same name causes error and package removal
2 participants