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

ci: Add nightly upload of wheels to Anaconda Cloud #3012

Merged

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Feb 7, 2024

Resolves #3011

I'm putting this in draft mode so that I can clean it up before this gets approved and merged.

Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

I'm definitely in favor. This is a great thing to do; thanks!

Don't worry about the pypy test. It's allowed to fail as a non-required test to remind us about #2971.

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 7, 2024

I'm definitely in favor. This is a great thing to do; thanks!

@jpivarski Great! I think beyond a review here, what would be good to discuss is also updates to the other workflows that are doing the wheel building to make sure that all desired wheels are built each night to get uploaded. At the moment #3011 (comment) makes it seems like only a subset are being built in the test workflows.

Also the

If this sounds good, I'll PR what I have and I'll need at least 1 (perferably 2) maintainers to create Anaconda Cloud (https://anaconda.org/) accounts and make new API tokens with permissions described in https://scientific-python.org/specs/spec-0004/#process-for-adding-new-projects

image

from #3011 (comment) is needed before this can go in.

@jpivarski
Copy link
Member

Is this only for compiled wheels or for pure Python packages as well? (I'm thinking about Uproot.) Pure Python packages are less in need of pre-built wheels because pip+git would work.

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 8, 2024

Is this only for compiled wheels or for pure Python packages as well? (I'm thinking about Uproot.) Pure Python packages are less in need of pre-built wheels because pip+git would work.

Yeah, good point. It is totally up to us, as this is a package index that Scikit-HEP controls, so for single point of contact simplicity we could add pure-Python wheels, but for pyhf's HEAD of dependencies testing workflow simply doing

...
python -m pip uninstall --yes uproot
python -m pip install --upgrade git+https://github.com/scikit-hep/uproot5.git

has worked fine. So I'd defer to you and the rest of the uproot team on this.

* To ensure that there are wheels to upload to Anaconda Cloud, run a
  nightly cron job of the 'Packaging Tests' workflow to ensure that
  there are wheel artifacts uploaded that can be searched for and
  downloaded.
@codecov-commenter
Copy link

codecov-commenter commented Feb 8, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (b749e49) 81.90% compared to head (cec028e) 81.91%.
Report is 12 commits behind head on main.

Additional details and impacted files
Files Coverage Δ
src/awkward/_connect/cuda/__init__.py 0.00% <ø> (ø)
src/awkward/operations/ak_enforce_type.py 81.97% <ø> (ø)
src/awkward/operations/ak_to_dataframe.py 90.76% <100.00%> (+0.14%) ⬆️
src/awkward/_nplikes/typetracer.py 74.85% <0.00%> (ø)

* On a schedule that follows _after_ the schedule job for the packaging
  tests workflow, use the gh command line API to find the latest run of
  the packaging tests workflow. Filtering on 'schedule' events to find
  the latest schedule run, extract the run id, and then use that to
  download all of the 'awkward-wheel' and 'awkward-cpp-wheels-*'
  artifacts from the workflow.
* Use the scientific-python/upload-nightly-action GitHub Action to then
  upload these wheels to the scikit-hep-nightly-wheels Anaconda Cloud
  organization registry.
   - c.f. https://github.com/scientific-python/upload-nightly-action
   - c.f. https://anaconda.org/scikit-hep-nightly-wheels
@matthewfeickert matthewfeickert marked this pull request as ready for review February 8, 2024 04:23
@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 8, 2024

@jpivarski Okay, I cleaned up a few things in the PR and gave it nicer commit messages for the history. Once you have done the following:

This can get merged in and should start working.

https://github.com/scikit-hep/awkward/blob/dd4753b97949e4098aa6008a189624ba7a72fda6/.github/workflows/packaging-test.yml only builds a handful of wheels, and so isn't quite providing true nightly wheels for all targets yet, but this is a solid first step and I think the Awkward team can exapnd on this to meet whatever goals they want from here.

@agoose77
Copy link
Collaborator

agoose77 commented Feb 8, 2024

Right now we don't publish any wheels built on main, unless I am misremembering something! We do build PR wheels, which you rightly spot in packaging-test.yml.

Given that we test quite a lot of platform-specific stuff in our main PR test suite, I'd be tempted to change packaging-test.yml to test only main via a CRON job (or maybe on PUSH). @jpivarski thoughts?

Copy link
Member Author

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

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

@agoose77 here's updated logic. @jpivarski These revisions also look good to you?

.github/workflows/packaging-test.yml Outdated Show resolved Hide resolved
.github/workflows/upload_nightly_wheels.yml Outdated Show resolved Hide resolved
Copy link
Member Author

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

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

@jpivarski @agoose77 Reverted things, but added runs on push events on main until you can tell me if you want this or just the schedule events added here. At the moment, the logic for downloading is only checking for schedule events, but it could look for schedule or push and just get whatever is the latest.

.github/workflows/packaging-test.yml Outdated Show resolved Hide resolved
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

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

I'm still in favor of this; it looks like a good thing to do. I wonder what motivates the odd time, though. It's late enough to be evening, even in the U.S. (We'll soon have a new collaborator in Mountain time, but it's still okay for that—not likely to take away task-runners when we want feedback on a PR.)

@matthewfeickert
Copy link
Member Author

I wonder what motivates the odd time, though

Ah that is easy to explain. Running jobs at 0:00 UTC gets slowed way down because many people are using that as a default and so GitHub Actions gets swamped with runner usage right then. Running at 1:23 UTC then gives you a little offset (and the numbers are just silly placeholders) and then running the uploader at 2:34 UTC means that you give it a huge amount of time to finish in the event that anything ever goes wrong and things get delayed by many minutes.

* Also selecting on workflow dispatch allows for on demand runs to be
  selected for uploads.
@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 8, 2024

To make testing of this easier in advance of merge, I just triggered a workflow dispatch run of .github/workflows/packaging-test.yml on Awkward which finished and then I pushed a change that looks for both schedule and workflow_dispatch event triggers. So this shell script

#!/bin/bash

rm -rf awkward-cpp-wheels-* awkward-wheel dist runs.json

PROJECT_REPO="scikit-hep/awkward"
BRANCH="main"
WORKFLOW_NAME="packaging-test.yml"
ARTIFACT_PATTERN="awkward*wheel*"  # awkward-wheel and awkward-cpp-wheels-*

gh run --repo "${PROJECT_REPO}" \
   list --branch "${BRANCH}" \
        --workflow "${WORKFLOW_NAME}" \
        --json event,status,conclusion,databaseId > runs.json
RUN_ID=$(
  jq --compact-output \
    '[
      .[] |
      # Filter on "schedule" and "workflow_dispatch" events to main (nightly build) ...
      select(.event == "schedule" or .event == "workflow_dispatch") |
      # that have completed successfully ...
      select(.status == "completed" and .conclusion == "success")
     ] |
    # and get ID of latest build of wheels.
    sort_by(.databaseId) | reverse | .[0].databaseId' runs.json
)
gh run --repo "${PROJECT_REPO}" view "${RUN_ID}"
gh run --repo "${PROJECT_REPO}" \
   download "${RUN_ID}" --pattern "${ARTIFACT_PATTERN}"

mkdir dist
mv ${ARTIFACT_PATTERN}/*.whl dist/
ls -l dist/

is the logic I implemented in the PR. If you run it

$ bash debug.sh 

✓ main Packaging Tests · 7836312788
Triggered via workflow_dispatch about 16 minutes ago

JOBS
✓ Build awkward-cpp: windows-latest in 6m41s (ID 21383661203)
✓ Build awkward in 45s (ID 21383661437)
✓ Build awkward-cpp: macos-latest in 8m33s (ID 21383661690)
✓ Build awkward-cpp: ubuntu-latest in 7m1s (ID 21383661957)

ARTIFACTS
awkward-sdist
awkward-wheel
awkward-cpp-sdist
awkward-cpp-wheels-windows-latest
awkward-cpp-wheels-ubuntu-latest
awkward-cpp-wheels-macos-latest

For more information about a job, try: gh run view --job=<job-id>
View this run on GitHub: https://github.com/scikit-hep/awkward/actions/runs/7836312788
total 3844
-rw-r--r-- 1 feickert feickert  761870 Feb  8 15:57 awkward-2.6.1-py3-none-any.whl
-rw-r--r-- 1 feickert feickert  706425 Feb  8 15:57 awkward_cpp-29-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
-rw-r--r-- 1 feickert feickert  707671 Feb  8 15:57 awkward_cpp-29-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
-rw-r--r-- 1 feickert feickert 1214783 Feb  8 15:57 awkward_cpp-29-cp38-cp38-macosx_10_9_universal2.whl
-rw-r--r-- 1 feickert feickert  533474 Feb  8 15:57 awkward_cpp-29-cp39-cp39-win_amd64.whl

it gets the wheels that were just built. 👍 That's the whole wheel gathering logic that I added and then the rest of the PR is just the uploader action.

@jpivarski jpivarski enabled auto-merge (squash) February 8, 2024 22:04
@jpivarski jpivarski merged commit 2c780d0 into scikit-hep:main Feb 8, 2024
38 checks passed
@matthewfeickert matthewfeickert deleted the ci/add-nightly-wheel-upload branch February 8, 2024 22:09
@matthewfeickert
Copy link
Member Author

So as the wheels all have the same name each time (they don't have vcs information associated with them) they currently need some manual rerunning to deal with anaconda/anaconda-client#702, but after that, the workflow runs fine.

image

image

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.

Add nightly wheel upload to Anaconda Cloud
4 participants