Skip to content

matrix environment selection with run and env run doesn't work as expected / documented #858

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

Open
tobi45 opened this issue May 17, 2023 · 2 comments

Comments

@tobi45
Copy link

tobi45 commented May 17, 2023

I have a matrix environment defined and want to run a script/command in a subset of all matrix based environments. For that purpose the run command has the + and - options and the env run command the -i and -x options to select a subset of all environments.

With both commands and options it is possible to select a value along one dimension/list, but not along more than one dimension/list.

Should it be possible to select/include values along multiple dimensions/lists?

Environment definition from pyproject.toml:

[tool.hatch.envs.test]
detached = true

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9"]
tensorflow = ["2.12.*", "2.11.*", "2.10.*", "2.9.*"]

[tool.hatch.envs.test.scripts]
test = [ "echo {env_name}" ]

My goal is e. g. to run a script/command in the environment with python 3.8 and tensorflow 2.11.*. Next are my tries with their result. Note that I included runs to show that the * in the value shouldn't be the problem.

  • hatch run +tensorflow=2.11.* test:test
    • works correctly, all python versions: test.py3.8-2.11.*, test.py3.9-2.11.*
  • hatch run +python=3.8 test:test
    • works correctly, all tensorflow versions
  • hatch run +tensorflow=2.11.* +python=3.8 test:test and hatch run +python=3.8 +tensorflow=2.11.* test:test
    • neither python specific nor tensorflow specific, thus all python versions and all tensorflow versions
  • hatch run +python=3.8,tensorflow=2.11.* test:test
    • python specific but not tensorflow specific, thus all tensorflow versions
  • hatch run +tensorflow=2.11.*,python=3.8 test:test
    • tensorflow specific but not python specific, thus all python versions

Then I tried env run:

  • hatch env run -i tensorflow=2.11.* -i python=3.8 test:test
  • hatch env run --env test -i tensorflow=2.11.* -i python=3.8 test
    • neither python specific nor tensorflow specific, thus all python versions and all tensorflow versions
  • hatch env run --env test -i tensorflow=2.11.* test
    • works correctly, all python versions
  • hatch env run --env test -i python=3.8 test
    • works correctly, all tensorflow versions
  • hatch env run --env test -i tensorflow=2.11.* python=3.8 test
    • no error message, no output, just does nothing
  • hatch env run --env test -i tensorflow=2.11.*,python=3.8 test
    • tensorflow specific but not python specific, thus all python versions

The only way I found to run scripts in exactly one matrix based environment, python 3.8 and tensorflow 2.11.*, is without the options -i or + but:

hatch env run --env test.py3.8-2.11.* test

It is unclear to me, if it shouldn't be possible and if the documentation is unclear and the command line parser has a bug or if it should be possible and there is a bug in the selection process and another one in the command line parser / option error handling.

@ofek
Copy link
Collaborator

ofek commented May 17, 2023

This looks like a bug to me and should be allowed

@pikhovkin
Copy link

same issue

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

3 participants