fast-photographer-12719
11/07/2023, 2:05 PMinstall_from_resolve
setting for pytest. I have the following in project.toml:
[python]
interpreter_constraints = [ ">=3.10" ]
enable_resolves = true
default_resolve = "default"
[python.resolves]
default = "3rdparty/python/default.lock"
torch-cpu-test = "3rdparty/python/torch-cpu-test.lock"
[pytest]
install_from_resolve = "torch-cpu-test"
However this will error with
stderr:
Failed to resolve compatible artifacts from lock 3rdparty/python/default.lock for 1 target:
1. /usr/bin/python3.10:
Failed to resolve all requirements for cp310-cp310-manylinux_2_35_x86_64 interpreter at /usr/bin/python3.10 from 3rdparty/python/default.lock:
which is weird because default.lock is irrelevant
Setting default_resolve = "torch-cpu-test"
seems to fix it, which makes me believe that the install_from_resolve
is being ignored.curved-television-6568
11/07/2023, 3:22 PMlate-advantage-75311
11/07/2023, 3:58 PMlate-advantage-75311
11/07/2023, 4:01 PMdefault
resolve won't be in use. For example, you can install pytest from a specific resolve, but use it to run a python_test
that has resolve=something_else
late-advantage-75311
11/07/2023, 4:03 PMgorgeous-winter-99296
11/07/2023, 4:06 PMfast-photographer-12719
11/07/2023, 4:06 PM16:04:26.96 [WARN] Pants cannot infer owners for the following imports in the target mlcore/models/cnn/litehrnet.py:
* numpy (line: 11)
These imports are not in the resolve used by the target (`default`), but they were present in other resolves:
* numpy: 'torch-cpu' from 3rdparty/python:default#numpy@resolve=torch-cpu, 'torch-cpu-test' from 3rdparty/python:default#numpy@resolve=torch-cpu-test
there are many lines of missing dependencies as default has very little in it. Here's an example of numpy not being available. It's here that you can again see it's looking in default not the install_from_resolve
fast-photographer-12719
11/07/2023, 4:07 PMgorgeous-winter-99296
11/07/2023, 4:12 PMpytest
is just a program, from the perspective here. It doesn't have to have any relation to the code-under-test. What Pants does functionally is build one "venv" with pytest, and one "venv" with the code to test.fast-photographer-12719
11/07/2023, 4:16 PMgorgeous-winter-99296
11/07/2023, 4:21 PM+cpu
and +cu118
f.ex.? Do you also want to support mac?curved-television-6568
11/07/2023, 4:25 PMAdditionally, i was intending to have a resolve for dev-dependencies separately ontop of that.you don’t need to keep that distinction with pants. It’s clever enough to not include any requirements you may have in your resolve that are not used by production code.
gorgeous-winter-99296
11/07/2023, 4:40 PMgpu
which currently is +cu118
-- used for local dev/algorithm development, and obviously cloud
• cpu
which currently is +cpu
-- used for tests and Linux users without GPUs
• base
, which explicitly forbids either (torch==1.x,!=1.x+cu118,!=1.x+cpu
). Since neither of the two above support mac, we need this for those developers.
Each contains exactly the same dependencies except for torch and torch-related deps. We tried a few different setups for selecting resolves, but for now we do this:
__defaults__({
(python_sources,python_tests): dict(resolve=parametrize("cpu", "gpu", "base))
})
Which in effect means any run or test has three variants:
pants test path/to/test.py@resolve=cpu
pants test path/to/test.py@resolve=gpu
pants test path/to/test.py@resolve=base
And same for run
, etc. This ended up being easier to teach than using --default-resolve
etc. Then we use filters (pants test --filter-adress-regex='.*@resolve=cpu ::
) to only run the CPU variants or others when we do globbing.gorgeous-winter-99296
11/07/2023, 4:45 PMfast-photographer-12719
11/07/2023, 4:54 PM@resolve=cpu
syntax and can't get that to work for mine.gorgeous-winter-99296
11/07/2023, 4:55 PMgorgeous-winter-99296
11/07/2023, 4:58 PMfast-photographer-12719
11/07/2023, 5:10 PMfast-photographer-12719
11/08/2023, 10:33 AM$ pants test tests/::@resolve=cpu
10:19:38.05 [ERROR] Failed to parse address spec `tests/::@resolve=cpu`: error at 1:9: expected EOF
I can't find many examples of the parametrised target but i think that syntax seems to match teh tutorial, except with :: instead of :gorgeous-winter-99296
11/08/2023, 10:34 AM@resolve=cpu
goes on a single target. Unfortunately. If you want to filter with a glob-spec like ::
you need --filter-adress-regex='.*@resolve=cpu'
.gorgeous-winter-99296
11/08/2023, 10:35 AMpants run src/py/my_app/main.py@resolve=cpu
would work.gorgeous-winter-99296
11/08/2023, 10:36 AM__defaults__
does for you -- it adds the resolve parametrization to all targets in and below that directory.)late-advantage-75311
11/08/2023, 10:39 AMtest
file?fast-photographer-12719
11/08/2023, 1:14 PM