Hi, We're importing one util service as a package ...
# general
w
Hi, We're importing one util service as a package into another. The imported package uses a specific lock file, while the rest of the services use a default lock file to resolve third-party packages. Since these are different resolves, the docker image is unsure which one to use. Has anyone encountered this kind of issue before or have suggestions for handling conflicting resolves? Thanks in advance.
BUILD file
Copy code
python_sources(
    name = "pkg",

    # Source code folders.
    sources = [
        "service/**/*.py",
    ],
  
    dependencies = [
        # 3rd party dependencies
        "3rdparty/python:poetry#pydantic",
        "3rdparty/python:poetry#easydict",

        # Internal dependencies (libraries, etc.)
        "python/pkg/service:pkg",             # Uses util service lock file to resolve packages
        "python/pkg/common:pkg",          # User python default lock file to resolve packages
    ],
    resolve=parametrize("python-default", "python-util-service")
)
pex_binary(
    name = "app",
    entry_point = "service/main.py",
    
    dependencies = [
        ":pkg",
    ],
    layout = "packed",
)
docker_image(
    name = "docker",
    image_tags = [
        "{build_args.GITHUB_SHA}",
    ],

    source = "docker/Dockerfile",

    # Container registry details
    registries = [
        "@service_registry",
    ],

    # Pants-target dependencies
    dependencies = [
        ":pkg",
        ":app",
    ],
)
`ERROR`:
Copy code
06:06:05.55 [ERROR] 1 Exception encountered:

Engine traceback:
  in package goal

ValueError: The explicit dependency <service>:pkg of the target at <service>:docker does not provide enough address parameters to identify which parametrization of the dependency target should be used.
c
Pants views resolves as universes of dependencies. By separating the resolves of the "common" and "service", Pants can't unite them in one usage. To illustrate, imagine "common" requires
my-package~=1.0
and "service" requires
my-package==1.2.3
. The "common" resolve might choose version 1.0.0, while "service" will choose 1.2.3. They can't be combined, because the locked versions aren't the same. One solution is to include them both in the same resolve. That way, both sets of constraints will be evaluated and the correct version chosen. If you want to share "common" with many services, you can use "parametrize" on the resolve for "common" to all the services' resolves. See the section on multiple lockfiles in our docs
In you case, the "parametrise" on the "pkg" doesn't allow you to select from both resolves at the same time, it says (in effect) that there should be 2 versions of the "pkg" target, one in each resolve.