Hi All, While working with multiple resolves and p...
# general
a
Hi All, While working with multiple resolves and parametrizing the shared code, how do we specify the explicit third party dependency? For example, I have the following dependency on redis in my PANTS file but unable to specify it since the python_sources target is parametrized to include both resolves:
Copy code
python_sources(
    dependencies=[
        "deps:default#redis",
    ],
    resolve=parametrize("default", "airflow"),
)
I would like to specify the explicit dependency depending on the resolve(ie,"deps:default#redis" for default resolve and "deps:airflow#redis" for airflow resolve) . Thanks!
Looks like you can parametrize multiple fields by doing something like
Copy code
**parametrize("py2", interpreter_constraints=["==2.7.*"], resolve="lock-a"),
a
I'm unable to specify the
dependencies
in python_sources target in a similar manner. Do you mind sharing the syntax for this case?
I'm running into the following type error when I update the python_sources target like the following:
Copy code
python_sources(
    **parametrize("default", dependencies=["deps:default#redis"], resolve="default"),
    **parametrize("airflow", dependencies=["deps:airflow#redis"], resolve="airflow"),
)
TypeError: python_sources argument after ** must be a mapping, not Parametrize
s
Mind sharing which version of Pants you are using?
The above parametrize helper was released in v2.19
a
We are using v2.17.0. Is there a workaround in this version?
s
Does the example
Copy code
python_test(
    name="tests",
    source="tests.py",
    interpreter_constraints=parametrize(py2=["==2.7.*"], py3=[">=3.6"]),
    resolve=parametrize("lock-a", "lock-b"),
)
from https://www.pantsbuild.org/2.17/docs/using-pants/key-concepts/targets-and-build-files#parametrizing-targets help?
Does
dependencies=parametrize(["deps:default#redis"], ["deps:airflow#redis"])
work?
a
It seems to accept the following syntax,
Copy code
python_sources(
    resolve=parametrize("default", "airflow"),
    dependencies=parametrize(default_deps=["deps:default#redis"],airflow_deps= ["deps:airflow#redis"])
)
but getting an error while running pants pylint:
* pdl.lib.clients.local_redis.LocalRedis (line: 13)
* pdl.lib.clients.redis.PDL_Redis (line: 14)
`These imports are not in the resolve used by the target (
default
), but they were present in other resolves:`
* pdl.lib.clients.local_redis.LocalRedis: 'airflow' from src/pdl/lib/clients/local_redis.py@dependencies=airflow_deps,resolve=airflow, 'airflow' from src/pdl/lib/clients/local_redis.py@dependencies=default_deps,resolve=airflow
* pdl.lib.clients.redis.PDL_Redis: 'airflow' from src/pdl/lib/clients/redis.py@dependencies=airflow_deps,resolve=airflow, 'airflow' from src/pdl/lib/clients/redis.py@dependencies=default_deps,resolve=airflow
Looks like its taking all combinations but not mapping the dependencies to each resolve correctly.