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

Use conda-lock to create test environments #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Use conda-lock to create test environments #281

wants to merge 1 commit into from

Conversation

maresb
Copy link

@maresb maresb commented Dec 17, 2023

Closes #279, if I'm understanding correctly.

This needs to be tested, but it uses lockfiles (which are generated by a separate CI) to set up a Conda environment for running the tests.

We need to set up a fine-grained GitHub token with the following permissions to the CausalPy repo:

  • Read access to metadata
  • Read and Write access to code and pull requests
    and make it available as a secret named GH_PAT_FOR_PR. (I can't do it myself since I'm not admin here.)

Copy link

codecov bot commented Dec 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (83cb28c) 75.86% compared to head (b92084f) 75.86%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #281   +/-   ##
=======================================
  Coverage   75.86%   75.86%           
=======================================
  Files          20       20           
  Lines        1305     1305           
=======================================
  Hits          990      990           
  Misses        315      315           

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

@maresb
Copy link
Author

maresb commented Dec 17, 2023

It looks like the Python 3.8 doctests are hanging right after:

 causalpy/tests/test_integration_pymc_examples.py::test_geolift1 PASSED   [ 69%]

I'm not sure what's the next test that's running here.

EDIT: Looking at the other runs, it seems the test that's hanging may be:

causalpy/tests/test_integration_pymc_examples.py::test_iv_reg

@drbenvincent
Copy link
Collaborator

Cool. This is outside my comfort zone at the moment, so let's jump on a quick call at some point when you have time.

@maresb
Copy link
Author

maresb commented Dec 23, 2023

I'm happy to discuss when I find a moment, but let me write a few words about how this works, because I think ideally these sorts of things should be documented somewhere.

The starting point is a bunch of test environment definitions. They include a particular version of Python, and pip. For completeness, I define environments for Python 3.11 and 3.12, even though they aren't used.

The next step is generating/updating the lockfiles via the update-lockfile.yml workflow. For each of the Python versions in ["3.8", "3.9", "3.10"], we generate lockfiles based on the dependencies in pyproject.toml, the test extras defined in pyproject.toml, and the environment definition file which selects the particular Python version. In more detail, conda-lock merges these dependency specifications, solves them, and writes the solution into the respective lockfile. The workflow generates a pull request once per week with the updated dependency solutions.

The final step is updating the test CI to install and cache the environment based on the lockfile.

This guarantees that the installed dependencies are deterministic, reproducible, regularly updated, and done in the recommended Conda way.

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.

install pymc in the recommended manner for remote workflows
2 participants