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

define matrices that vary both the python version and the dependency version #1613

Closed
axiomofjoy opened this issue Jul 12, 2024 · 4 comments
Closed

Comments

@axiomofjoy
Copy link

I am able to define matrices for testing on different Python versions. I am also able to define a matrix for testing using different dependency versions using the approach described in this issue. However, using both at once results in a large number of combinations that slows down my pipeline. How would I test on Python 3.8 with pydantic<2 and on Python 3.12 with pydantic>=2.0.0 with only two runs of my test suite?

@ofek
Copy link
Collaborator

ofek commented Jul 13, 2024

please enumerate the exact environments you want with which dependencies

@axiomofjoy
Copy link
Author

Thanks for the fast response. I would like to test on the following environments:

  • Python 3.8 with pydantic v1
  • Python 3.12 with pydantic v2

Here is my current configuration in pyproject.toml.

[tool.hatch.envs.test.overrides]
matrix.pydantic.dependencies = [
  { value = "pydantic<2", if = ["pydantic-v1"] },
  { value = "pydantic>=2.0.0", if = ["pydantic-v2"] },
]

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.12"]
pydantic = ["pydantic-v1", "pydantic-v2"]

This results in four runs of the test suite. I would like to have just two.

@ofek
Copy link
Collaborator

ofek commented Jul 13, 2024

the condition should be based on the Python version

@axiomofjoy
Copy link
Author

Thanks, I should have thought of that.

For posterity, here's what worked for me.

[tool.hatch.envs.test.overrides]
matrix.python.dependencies = [
  { value = "pydantic<2", if = ["3.8"] },
  { value = "pydantic>=2.0.0", if = ["3.12"] },
]

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.12"]

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

No branches or pull requests

2 participants