-
Notifications
You must be signed in to change notification settings - Fork 7
Migrate Python environment management from conda to uv #1082
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
Changes from all commits
b677ab4
cd8e78a
9fef659
796f037
20d3100
073096f
e5a5734
1f61d5c
1d5b568
e46ae41
9745ecd
40612be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,70 +17,71 @@ jobs: | |
| runs-on: ${{ matrix.os }} | ||
| defaults: | ||
| run: | ||
| shell: bash -l {0} | ||
| shell: bash | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| label: environments/environment-Linux.yml | ||
|
|
||
| - os: macos-latest # Mac arm64 runner | ||
| label: environments/environment-MAC-apple-silicon.yml | ||
|
|
||
| - os: macos-15-intel # Mac x64 runner | ||
| label: environments/environment-MAC-intel.yml | ||
|
|
||
| - os: windows-latest | ||
| label: environments/environment-Windows.yml | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| # see https://github.com/conda-incubator/setup-miniconda#caching-environments | ||
| - name: Set up conda | ||
| uses: conda-incubator/setup-miniconda@v3 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v8.3.2 | ||
| with: | ||
| miniforge-version: latest | ||
| activate-environment: nwb-guide | ||
| conda-remove-defaults: true | ||
|
|
||
| - name: Set cache date | ||
| id: get-date | ||
| run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
| enable-cache: true | ||
|
|
||
| - name: Cache Conda env | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ env.CONDA }}/envs | ||
| key: conda-${{ runner.os }}-${{ runner.arch }}-${{steps.get-date.outputs.today }}-${{ hashFiles(matrix.label) }}-${{ env.CACHE_NUMBER }} | ||
| id: cache | ||
| - name: Install Python dependencies | ||
| run: uv sync --locked | ||
|
|
||
| - if: steps.cache.outputs.cache-hit != 'true' | ||
| name: Create and activate environment | ||
| run: conda env update --name nwb-guide --file ${{ matrix.label }} | ||
| - name: Add the virtual environment to PATH | ||
| run: | | ||
| if [ "$RUNNER_OS" == "Windows" ]; then | ||
| echo "$GITHUB_WORKSPACE\\.venv\\Scripts" >> "$GITHUB_PATH" | ||
| else | ||
| echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH" | ||
| fi | ||
| echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Use Node.js 20 | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
|
|
||
| - name: Install GUIDE | ||
| run: npm ci --verbose | ||
|
|
||
| - name: Install testing dependencies | ||
| run: pip install pytest pytest-cov | ||
|
|
||
| # matplotlib arrives transitively through neuroconv's extras and GUIDE never imports it. | ||
| # PyInstaller bundles whatever is installed, and matplotlib's hidden libraries break the | ||
| # packaged build, so every job drops it to keep tests and releases on the same environment. | ||
| # `uv tree --invert --package matplotlib` lists what currently pulls it in. | ||
| - name: Manually remove matplotlib | ||
| run: pip uninstall matplotlib --yes | ||
| run: uv pip uninstall matplotlib || true | ||
|
|
||
| - name: Create env file | ||
| run: | | ||
| touch .env | ||
| echo DANDI_SANDBOX_API_KEY=${{ secrets.DANDI_SANDBOX_API_KEY }} >> .env | ||
|
|
||
| - if: matrix.os != 'ubuntu-latest' | ||
| # The macOS x64 runner intermittently crashes Chromium/Electron subprocesses (GPU and | ||
| # network-service), which fails the E2E run. Retry only on that runner. | ||
| - if: matrix.os == 'macos-15-intel' | ||
| name: Run tests (retried on the flaky x64 runner) | ||
| uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this job do?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also, why can't you just
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The job retries the below command ( Recent best practices for github actions, especially non-official actions, are to pin a specific commit instead of the mutable version tag. Last year, a popular GitHub Action To prevent these attacks, GitHub now supports "immutable releases", but adoption has been slow across the actions community. Surprisingly, not even the github-maintained core "actions/checkout" action is immutable: actions/checkout#2316 . The setup-uv action has started to make immutable releases, and so pinning to a version tag there is fine (note that they stopped publishing "floating tags" (v4, v4.0) for similar reasons). Until actions are immutable, pinning to a specific release commit gives the highest security possible, at the costs of the workflow being less readable and the action not auto-updated. I think in a year, actions will be immutable, and we can return to tag-based pointers. I did not update the action pins in all the workflows in this PR, just the changed ones. The others ones will be updated in a separate PR.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, good to know. Thanks for the info! |
||
| with: | ||
| timeout_minutes: 25 | ||
| max_attempts: 5 | ||
| command: npm run coverage:tutorial | ||
|
|
||
| - if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' | ||
| name: Run tests | ||
| run: npm run coverage:tutorial | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.