struggling a bit here - let’s say i’ve got 2x lamb...
# general
b
struggling a bit here - let’s say i’ve got 2x lambdas that i’ve used
poetry
to set up the directory structure/added dependencies for. each lambda has a dependency on the same 3p library, ie
geohash_hilbert
- i’m getting some warnings if i run
./pants dependencies ::
or
./pants package ::
revolving around this:
Copy code
23:36:47.01 [WARN] The target lambdas/LAMBDA-A/src/LAMBDA_A/handler.py:handler.py imports `geohash_hilbert`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['lambdas/LAMBDA-A#geohash-hilbert', 'lambdas/LAMBDA-B#geohash-hilbert'].
Is the accepted solution for this to just run separate lockfiles, one per Lambda? I’m currently using a single lockfile.
d
Can you share your directory layout? I think 'the Pants way' is to have a single file with dependency list (be it poetry or plain requirements.txt), it looks like you have two `pyproject.toml`s?
b
i do, stand by
Copy code
root@archdev:~/pants-testing# tree .
.
├── README.md
├── bandit.yml
├── lambdas
│   ├── create-base-listing
│   │   ├── BUILD
│   │   ├── README.md
│   │   ├── poetry.lock
│   │   ├── pyproject.toml
│   │   ├── src
│   │   │   └── create_base_listing
│   │   │       ├── BUILD
│   │   │       ├── __init__.py
│   │   │       └── handler.py
│   │   └── tests
│   │       ├── BUILD
│   │       ├── __init__.py
│   │       ├── events
│   │       │   └── sampleEvent_01.json
│   │       └── test_handler.py
│   ├── create-listing-from-menu-item
│   │   ├── BUILD
│   │   ├── README.md
│   │   ├── poetry.lock
│   │   ├── pyproject.toml
│   │   ├── src
│   │   │   └── create_listing_from_menu_item
│   │   │       ├── BUILD
│   │   │       ├── __init__.py
│   │   │       └── handler.py
│   │   └── tests
│   │       ├── BUILD
│   │       ├── __init__.py
│   │       ├── events
│   │       │   └── sampleEvent_01.json
│   │       └── test_handler.py
│   └── qr-generator
│       ├── BUILD
│       ├── README.md
│       ├── poetry.lock
│       ├── pyproject.toml
│       ├── src
│       │   └── qr_generator
│       │       ├── BUILD
│       │       ├── __init__.py
│       │       └── handler.py
│       └── tests
│           ├── BUILD
│           ├── __init__.py
│           ├── events
│           │   └── sampleEvent_01.json
│           └── test_handler.py
├── libs
│   └── nom
│       ├── BUILD
│       ├── README.md
│       ├── poetry.lock
│       ├── pyproject.toml
│       ├── src
│       │   └── nom
│       │       ├── BUILD
│       │       ├── __init__.py
│       │       └── dummy.py
│       └── tests
│           ├── BUILD
│           ├── __init__.py
│           └── test_nom.py
├── mypy.ini
├── pants
├── pants.ci.toml
├── pants.toml
└── python-default.lock
l
You can just use one dependency file. Just add all dependencies there. Pants will infer the required ones for each lambda.
b
so in other words i really just need a single
pyproject.toml
file for everything?
d
so in other words i really just need a single
pyproject.toml
file for everything?
yes
b
cheers, i’ll give that a go! thank you!
is there a way to exclude dependencies from a Lambdex package?
ie - i want to use boto3/botocore for test/dev, but i don’t want them included in the Lambdex because boto3/botocore are included in the Lambda runtime
(i might try using
!
in the
dependencies
field)
l
@bright-monitor-59146 I think you can not exclude third party dependencies with
!
, at least it did not work for me. Even if boto3 is included it is not on the newest version. I think aws even says that you should include your own version.
b
cheers, thanks @lemon-yak-80782!
all right - i’ve solved this with a single requirements file for my 3p dependencies, but then i broke my first party code. should i be adjusting my
BUILD
file for this to export some kind of distribution? with
poetry_requirements
it just kind of worked
nevermind, figured it out