Skip to content

ci: install test job env via micromamba (refs #279)#910

Open
anevolbap wants to merge 5 commits into
pymc-labs:mainfrom
anevolbap:try/279-conda-ci
Open

ci: install test job env via micromamba (refs #279)#910
anevolbap wants to merge 5 commits into
pymc-labs:mainfrom
anevolbap:try/279-conda-ci

Conversation

@anevolbap
Copy link
Copy Markdown
Contributor

@anevolbap anevolbap commented May 7, 2026

Refs #279.

The CI test matrix still installs PyMC via pip. #304 moved local dev to a conda install but explicitly scoped out CI. Earlier attempts at the CI half stalled (#281 conda-lock, #412 pixi). #713 has since made environment.yml an autogenerated artifact synced with pyproject.toml, which makes a clean swap straightforward.

What this PR does

Switches the test matrix in .github/workflows/ci.yml from pip install -e .[test] to mamba-org/setup-micromamba consuming the autogenerated environment.yml, so PyMC comes from conda-forge in CI.

  • Pin setup-micromamba to v3.0.0 by SHA, matching the security style of the rest of the workflow.
  • Add defaults.run.shell: bash -el {0} so the activated env persists across steps.
  • Source the test-only deps (pytest, pytest-cov, papermill) from environment.yml by adding -e test to the pyproject2conda invocation in .pre-commit-config.yaml and the check-environment-yml job. Keeps environment.yml as the single source of truth.
  • Install the local package with pip install --no-deps -e . so pip cannot pull pip-built pymc/pytensor on top of the conda ones.

Open question: Python 3.11 in CI

The matrix changed from ["3.11", "3.14"] to ["3.12", "3.14"], because environment.yml is generated with --python-include "python>=3.12" and the 3.11 leg would not solve. The package itself still claims 3.11 support (requires-python = ">=3.11", Programming Language :: Python :: 3.11 classifier). Two paths forward, neither taken in this PR:

  1. Bump requires-python to >=3.12 and drop the 3.11 classifier.
  2. Loosen --python-include in the pyproject2conda invocation to python>=3.11 so the 3.11 leg can solve, then re-add it to the matrix.

Happy to take direction on which one you prefer.

CI runtime impact

The test matrix went from ~3-5 min (pip) to roughly 5-8 min (conda) on the first run. cache-environment should bring subsequent runs closer to the pip baseline as long as environment.yml does not change.

Verification

  • Local run on Python 3.14: pymc, pytensor, numpy, scipy all from conda-forge with MKL BLAS, blas_ldflags references the conda env's lib, no pytensor.tensor.blas numpy-fallback warning. Doctests 35 passed / 11 skipped, extra tests 2 passed, full suite 936 passed / 17 skipped, coverage 94.97% in 3m27s.
  • CI on this PR: both test (3.12) and test (3.14) pass. The Show environment step in each test job's log confirms pymc is installed from conda-forge and blas_ldflags references the conda env's lib.

Out of scope

Reviewed with Claude Opus 4.7 (adversarial review pass).

Replace pip-based setup in the test matrix with mamba-org/setup-micromamba
consuming the autogenerated environment.yml, so PyMC comes from
conda-forge in CI.

- Pin setup-micromamba to v3.0.0 by SHA, matching the security style
  of the rest of the workflow.
- Add `defaults.run.shell: bash -el {0}` so the activated env persists
  across steps.
- Pass python plus the missing test extras (pytest, pytest-cov,
  papermill) via `create-args`, since environment.yml is generated
  from the dev extras and does not include them.
- Install the local package with `pip install --no-deps -e .` so pip
  cannot pull pip-built pymc/pytensor on top of the conda ones.
- Drop 3.11 from the matrix because environment.yml pins
  `python>=3.12`. New matrix is ["3.12", "3.14"].

Probe for pymc-labs#279, kept on a feature branch for validation.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.07%. Comparing base (390129f) to head (de99dff).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #910   +/-   ##
=======================================
  Coverage   95.07%   95.07%           
=======================================
  Files          87       87           
  Lines       13701    13701           
  Branches      812      812           
=======================================
  Hits        13026    13026           
  Misses        479      479           
  Partials      196      196           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 7, 2026

Documentation build overview

📚 causalpy | 🛠️ Build #32710354 | 📁 Comparing de99dff against latest (0d81af2)

  🔍 Preview build  

169 files changed · + 56 added · ± 113 modified

+ Added

± Modified

@anevolbap anevolbap changed the title [DRAFT] ci: prototype conda-based install for test job (#279 probe) ci: install test job env via micromamba (closes #279) May 7, 2026
@anevolbap anevolbap marked this pull request as ready for review May 7, 2026 10:06
@github-actions github-actions Bot added the devops DevOps related label May 7, 2026
anevolbap added 2 commits May 7, 2026 06:20
Add `-e test` to the pyproject2conda invocation in
.pre-commit-config.yaml and the check-environment-yml job in
ci.yml. Regenerate environment.yml so it now includes pytest,
pytest-cov, and papermill.

Drop those three deps from the test job's create-args, since
they now flow through environment.yml. Keeps that file as the
single dependency source per pymc-labs#713 and removes the cache-key
divergence introduced by passing test deps through create-args.
Header-only change so the file matches what the pyproject2conda-yaml
prek hook produces. The body is identical to the previous commit.
Restores pre-commit.ci to green.
@anevolbap anevolbap changed the title ci: install test job env via micromamba (closes #279) ci: install test job env via micromamba (refs #279) May 7, 2026
Copy link
Copy Markdown
Collaborator

@juanitorduz juanitorduz left a comment

Choose a reason for hiding this comment

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

thanks @anevolbap !

@drbenvincent can you take a look as this one is key ;) ?

@drbenvincent
Copy link
Copy Markdown
Collaborator

Thanks for all these. I'm a bit behind on causal reviews - bear with me and I'll attempt to catch up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants