Hi I've added `celery[sqs]` and `celery[redis]` pa...
# general
w
Hi I've added
celery[sqs]
and
celery[redis]
package in poetry (
pyproject.toml
) config. I can able to generate
python_default.lock
file. However I'm not sure how to add this extras as dependancy in BUILD file. Can someone please guide me how to configure this?
Copy code
# pyproject.toml
[tool.poetry.group.pkg-celery_worker.dependencies]
celery = {extras = ["redis", "sqs"], version = "^5.3.6"}
Copy code
# BUILD file
python_sources(
    name="pkg",
    sources=["celery/**/*.py"],
    dependencies=[
        "3rdparty/python:poetry#boto3",
        "3rdparty/python:poetry#celery",
        "3rdparty/python:poetry#redis",
    ],
)
b
I think all references to
3rdparty/python:poetry#celery
will activate those extras (i.e. include the dependencies implied); are you observing something different?
w
Yes. It seems it's not added by default. I'm getting this error
Copy code
raise ImportError('The curl client requires the pycurl library.')
ImportError: The curl client requires the pycurl library.
b
Ah I know nothing about celery, but just confirming that error is related to the Sqs or redis extras, because it’s not obviously? Either way, maybe the poetry requirements target doesn’t import extras? I don’t know… If you can create a reduced example (eg one dependency, one extra and one source file) you can share, that’ll help narrow it down.
w
Sure. I have one more question. If I add a dependency with markers like this in
pyproject.toml
, will it be installed only if the platform is Linux and skipped for macOS?
Copy code
triton = [
    { version = "2.1.0", markers = 'sys_platform == "linux"' },
]
I noticed that this package isn't available for macOS. Is it possible to skip installing it for macOS and only install it for Linux OS?
I want to install this only to avoid this error. My code is not directly using this package. openai-whisper requires this package.
Copy code
Engine traceback:
  in `check` goal

ProcessExecutionFailure: Process 'Building requirements_venv.pex' failed with exit code 1.
stdout:

stderr:
Failed to resolve requirements from PEX environment @ /home/runner/.cache/pants/named_caches/pex_root/unzipped_pexes/3d7a856ceb2854e125d946d7405388e8f27e501b.
Needed cp39-cp39-manylinux_2_35_x86_64 compatible dependencies for:
 1: triton<3,>=2.0.0
    Required by:
      openai-whisper 20231117
    But this pex had no ProjectName(raw='triton', normalized='triton') distributions.



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
c
If I add a dependency with markers like this in
pyproject.toml
, will it be installed only if the platform is Linux and skipped for macOS?
that’s supposed to work, yes.
Yes. It seems it’s not added by default. I’m getting this error
``` raise ImportError('The curl client requires the pycurl library.')
ImportError: The curl client requires the pycurl library.```
without knowing what you’re importing, it’s difficult to replicate..
w
Thanks for your reply. The Triton package is only available on the Linux platform. My development environment is MacOS, and I'm using an Ubuntu machine to deploy the service. The
pants generate-lockfiles --resolve=python-default
command adds Triton to the
python_default.lock
file when executed on the Ubuntu machine but not when executed on MacOS. I attempted to use the same lock file on both operating systems. However, when I run the
pants check lint
command from the CI (Ubuntu machine), it throws an error because the package was not added, given that the lock file was generated on MacOS. Should I keep two different lock files based on the operating system? How can I resolve this issue?
c
I don’t reproduce this. I get the exact same lockfile on both Mac OS and ubuntu (on WSL):
Copy code
❯ shasum 3rdparty/python/default.lock
01f6f30a3da04983372e2e41f13126422c3eca29  3rdparty/python/default.lock
Using this setup:
Copy code
# pants.toml
[GLOBAL]
pants_version = "2.18.1"
backend_packages.add = [
  "pants.backend.python",
]

[python]
enable_resolves=true
interpreter_constraints = ["==3.11.*"]

# pyproject.toml
[tool.poetry.dependencies]
triton = [
    { version = "2.1.0", markers = 'sys_platform == "linux"' },
]

# BUILD
poetry_requirements(name="lib")
And that is with the triton package in the list of known artifacts, and the platform marker preserved in the requirements..
w
Are you running an Ubuntu container or a VM? If you're using an Ubuntu container on MacOS, it will still generate the same lock file .But if you are running on Ubuntu EC2 machine it will generate a different lock file. I'm not sure how it will identify the system architecture. But it is generating different lock files on different system architecture.
I will send the screenshot
This is from Ec2 Machine(Ubuntu OS)
c
the ubuntu one was from a different machine (windows box, using the subsystem for linux on it)
w
Oh okay. Could you please find this line in your lock file
Copy code
"triton<3,>=2.0.0"
c
yea, was going to ask which project does that belong to?
as I don't have that, as I'm only using the triton package.
my guess is that you need that platform marker for that project as well, perhaps
w
this package is required by
openai-whisper
. I'm importing
openai-whisper
package but internally this package is depending on triton package.
c
so since that depends on triton, it too would only work on linux...
w
my guess is that you need that platform marker for that project as well, perhaps
Oh is it possible. I'm new to pants ecosystem. Could you please explain how I can configure that?
c
the same way you did for triton already..
w
so since that depends on triton, it too would only work on linux...
On MacOS, It's working without this triton package. I don't know how. When I try to install it on Ubuntu then it's throwing
triton
package not available.
Like this?
Copy code
# pyproject.toml file
[tool.poetry]
name = "3rdparty"
version = "0.1.0"
description = "3rdparty libs. Dependabot checks this file."
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9,<3.11"
triton = [
    { version = "2.1.0", markers = 'sys_platform == "linux"' },
]

[tool.poetry.group.project-whisper-speach-recognition.dependencies]
boto3 = "^1.29.2"
numpy = "^1.26.2"
ctranslate2 = "^3.22.0"
transformers = "^4.35.2"
triton = [
    { version = "2.1.0", markers = 'sys_platform == "linux"' },
]

[tool.poetry.group.pkg-celery_worker.dependencies]
celery = {extras = ["redis", "sqs"], version = "^5.3.6"}
pycurl = "^7.45.2"
redis = "^5.0.1"
c
I don't have the full picture here... but what my reduced example shows, is that it does not matter that a lib is linux only, it still produces a good lockfile for linux on Mac. So your issue is something else.
may very well be related, but it's not the triton package in itself.
w
Can you please run
pants check
command on both the systems? If you don't mind can you please share the sample lock file?
When I execute the
pants generate-lockfiles --resolve=python-default
command on Ubuntu, it adds the line
"triton<3,>=2.0.0"
to the lock file. However, when I run the same command on MacOS, this line is not added.
c
@white-twilight-61019 running
pants check
won’t do anything for me, as I don’t have any sources. It’ll be you that need to try things out, either start with my example and see how it behaves and go from there, or work with your repo trying to get a small enough reproduction you can share will make it easier to help you.
w
Sure, I'll try your method. If I still get same error, I will share reproducible code with you
👍 1