adamant-airport-25400
05/04/2022, 7:13 PMruntime
should be one of the values from https://docs.aws.amazon.com/lambda/latest/dg/lambda-python.html. ”
So basically, it’s the Python version.
Also, It is required to define the lambda handler, which, as the runtime, I have to redefine in my IaC tool.hundreds-father-404
05/04/2022, 7:15 PMhigh-yak-85899
05/04/2022, 7:16 PMwitty-crayon-22786
05/04/2022, 7:17 PMarchive
anymorehundreds-father-404
05/04/2022, 7:18 PMhigh-yak-85899
05/04/2022, 7:20 PM<repo name>-venv
so that people have awareness if they're using the wrong venv when switching between repos (since we're not fully monorepo integrated yet)high-yak-85899
05/04/2022, 7:21 PMhundreds-father-404
05/04/2022, 7:23 PMadamant-airport-25400
05/04/2022, 7:23 PMconst fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
It requires a runtime, a handler and an asset. Currently in my case, the asset is the archive file generated by our internal tool. My idea was to replace this asset by one generated by Pants.
The idea of a target generator seems interesting. I’ll have to work more on the doc. I just started playing with Pants some hours ago. Do you have any useful resources for this ?hundreds-father-404
05/04/2022, 7:29 PMpex_binaries
, but even simpler because you are generating 1->1 rather than 1->n so no need for things like the overrides
field
https://github.com/pantsbuild/pants/blob/cf172080a5de8140b4e244e15a2f6265498e957e/src/python/pants/backend/python/target_types_rules.py#L77-L124dazzling-petabyte-91122
05/04/2022, 7:40 PMFROM golang:alpine as builder
WORKDIR /app
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
RUN update-ca-certificates
ADD . /app/
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags="-s -w" -installsuffix cgo -o my-app .
FROM scratch
COPY --from=builder /app/my-app .
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["./my-app"]
However when using the docker integration, it fails saying that my-app
and ca-certificates
aren't in the Docker build context. Is there a way to copy files using --from
with a multi stage build?happy-kitchen-89482
05/04/2022, 8:19 PMhappy-kitchen-89482
05/04/2022, 8:20 PMwide-midnight-78598
05/04/2022, 8:52 PMwide-midnight-78598
05/04/2022, 9:07 PMFROM nginx/unit:1.26.1-python3.9
COPY backend/apigateway/config.json /docker-entrypoint.d/config.json
COPY backend/apigateway/apigateway.pex /apigateway.pex
RUN PEX_TOOLS=1 /apigateway.pex venv /app
WORKDIR /app
16:58:54.10 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Building docker image apigateway-container:latest' failed with exit code 1.
stdout:
stderr:
#1 [internal] load build definition from Dockerfile
#1 sha256:dd05a256bf0a700475eee66e2bab7b409dfa252f9d5b9c512a20570645e0a542
#1 transferring dockerfile: 259B done
#1 DONE 0.0s
#2 [internal] load .dockerignore
#2 sha256:61b1ab8a8d14acfdedce93b66af15c72891c34a5899e37ffb9c6f9628f63a840
#2 transferring context: 2B done
#2 DONE 0.0s
#3 [internal] load metadata for <http://docker.io/nginx/unit:1.26.1-python3.9|docker.io/nginx/unit:1.26.1-python3.9>
#3 sha256:29341916069df22232847ba48ae4db61f24890c7b9ecbd26801c5739bc6e7b2b
#3 DONE 0.2s
#4 [1/5] FROM <http://docker.io/nginx/unit:1.26.1-python3.9@sha256:fd65503ce126888587050d2ab77d9324bed7fd5cb84a7da29b926303a3b3beba|docker.io/nginx/unit:1.26.1-python3.9@sha256:fd65503ce126888587050d2ab77d9324bed7fd5cb84a7da29b926303a3b3beba>
#4 sha256:cc3caab62ea82004335d0ff18f5f40e1ae0b0ee6932679be1c7144e8ad4072f7
#4 DONE 0.0s
#5 [internal] load build context
#5 sha256:f07b09714c1c81e44b9534d3b0fdf55d4bbbd51b1d5d730df0f29b1d51ed34a4
#5 transferring context: 17.83MB 4.6s
#5 transferring context: 20.00MB 5.4s done
#5 DONE 5.4s
#6 [2/5] COPY backend/apigateway/config.json /docker-entrypoint.d/config.json
#6 sha256:8663783c824d8e671e1c968f89cc4d12ba24ea91acd6a8508e756eabd479b8bf
#6 CACHED
#7 [3/5] COPY backend/apigateway/apigateway.pex /apigateway.pex
#7 sha256:ba50617df623b8c168123d021d61454e8f26c99e35650d16eb3d614370e5bd53
#7 CACHED
#8 [4/5] RUN PEX_TOOLS=1 /apigateway.pex venv /app
#8 sha256:caaa14b420888270c8c3bff91403db9f760633ee2c61e9340a947bc1761729cb
#8 0.639 /usr/bin/env: 'python3.10': No such file or directory
#8 ERROR: executor failed running [/bin/sh -c PEX_TOOLS=1 /apigateway.pex venv /app]: exit code: 127
------
> [4/5] RUN PEX_TOOLS=1 /apigateway.pex venv /app:
------
executor failed running [/bin/sh -c PEX_TOOLS=1 /apigateway.pex venv /app]: exit code: 127
purple-umbrella-89891
05/05/2022, 7:16 AMparametrize
to work around my issue with coverage (see here). However I'm not able to use parametrize
on extra_env_vars
.
Here are the options I tried with their respective errors:
# 1st try:
python_tests(
name=name,
extra_env_vars=parametrize(["MODE=1"], ["MODE=2"]),
)
Exception: Failed to parametrize `//:tests0`:
In parametrize(['MODE=1'], ['MODE=2']:
Positional arguments must be strings, but `['MODE=1']` was a `list`.
# 2nd try:
python_tests(
name=name,
extra_env_vars=parametrize("MODE=1", "MODE=2"),
)
Exception: Failed to parametrize `//:tests0`:
In parametrize(MODE=1, MODE=2:
Positional argument `MODE=1` contained separator characters (`=`).
To use `{arg}` as a parameter, you can pass it as a keyword argument to give it an alias. For example: `parametrize(short_memorable_name='{arg}')`
# 3rd try:
python_tests(
name=name,
extra_env_vars=[parametrize("MODE=1", "MODE=2")],
)
InvalidFieldTypeException: The 'extra_env_vars' field in target xyz.py:tests must be an iterable of strings (e.g. a list of strings), but was `[parametrize(MODE=1, MODE=2]` with type `list`.
By the way, a small functionally irrelevant bug in the error output in parametrize.py:59-60, those two lines should be f-strings. (Small PR opened here)rhythmic-morning-87313
05/05/2022, 9:19 AM./pants --version
to ./pants --version --no-verify-config
, it says another error as in the second screenshot. Why is pants complaining about my pants.toml and how to fix this seem-to-be-bogus error?
Here is my pants.toml.bitter-tiger-53933
05/05/2022, 10:42 AMpip install playwright
and then run playwright install
. I've been trying to use the experimental_run_shell_command
to run the playwright install
part but pants runs this before installing the pip dependencies. Can this be done using experimental_run_shell_command
or should i be using something else?echoing-farmer-15630
05/05/2022, 12:55 PMjax
, that needs some extras in most contexts (jax[cpu]
) and in one particular context needs different extras (jax[mystical_cuda_requirements]
). Honestly this should be true for torch
as well but the cuda/cpu builds there are hellacious (and this is why we can't have nice things like sub-2GB containers).
Anyway.
We have pinned versions of packages in a constraints file, but at least a while ago you couldn't put extras in there (haven't tried again under the new resolvers). I generate a python_requirements
based on that constraints.txt file, but if I have jax
in the constraints file, it creates a target without any extras which does no one any good.
I can't figure out how to have extras in a python_requirements
rule, so I have a separate requirement as
python_requirement(
name="jax", requirements=["jax[cpu]==0.3.10"], modules=["jax", "jaxlib"]
)
...and my guess for when I need the cuda version is to create a name="jaxcuda"
which also provides the same modules and resolve in the necessary target. Maybe.
Is there a clean way to handle this sort of situation? I scanned the documentation but got mildly confused... I'd really prefer a "use the CPU unless specifically declared otherwise" rather than two separate "jax" targets which have to be resolved for every client target if we can...calm-ambulance-65371
05/05/2022, 3:45 PMpydantic[email]
), which I have in the requirements.txt
, but dep inference doesn't seem smart enough to pull it inrhythmic-morning-87313
05/05/2022, 3:56 PM./pants check ::
still says there is no type stubs found for dateutil, yaml, etc. Am I missing something? Also, should I include type-stub packages in both requirements.txt
and the python_requirements()
target?rhythmic-morning-87313
05/05/2022, 4:50 PM--changed-since
option in GitHub Actions CI.
suggestion) The doc says ./pants --changed-since=... lint
but this fails with missing target error and ./pants --changed-since=... lint ::
fails since the --changed-since
flag and explicit target args are mutually exclusive. I could workaround it by using ./pants lint --changed-since=...
. I believe that the docs should be updated.
question) I'm going to use origin/$GITHUB_BASE_REF
as the argument of --changed-since
. But it says fatal: bad revision 'origin/main...HEAD'
in a PR. This may be due to the highly limited fetch-depth (default: 1). How could I fetch the commits that are exactly required for --changed-since
?bitter-ability-32190
05/05/2022, 5:09 PMexclusive
tag for tests? We have one test which if it doesn't get sufficient CPU resources will become flaky.hundreds-father-404
05/05/2022, 8:58 PM[python-infer].unowned_dependency_behavior = "error"
, which errors when a dependency cannot be inferred.
We're thinking of defaulting to warning or error because this error is hopefully much better than a cryptic runtime ModuleNotFoundErrror
Feedback welcomed!fresh-cat-90827
05/06/2022, 4:22 PMpants.toml
file by pants.ci.toml
file? The use case: I’d like to suppress the warnings for local users, but keep them in the CI builds.
pants.ci.toml
[GLOBAL]
ignore_warnings = []
---
pants.toml
[GLOBAL]
ignore_warnings = ["$regex$."]
It seems to work in CI and locally fine, however, I am curious if I am playing a lottery as I am not sure in what order the options are read and used.ambitious-actor-36781
05/08/2022, 9:43 PMbitter-ability-32190
05/09/2022, 3:27 PMCycleException
(only if I use explicit python_source
though).
a.py depends on b.py depends (for type-checking) on a.py
BUILD.pants
# no error
python_sources()
# Error
python_source(name="a", source="a.py")
python_source(name="b", source="b.py")
# Also no error
python_sources(name="a", sources=["a.py"])
python_sources(name="b", sources=["b.py"])
This seems... unexpecteddazzling-petabyte-91122
05/09/2022, 3:37 PMbitter-ability-32190
05/09/2022, 4:19 PMraise ValueError
in a macro, but am getting Name 'valueerror' is not defined.
high-yak-85899
05/09/2022, 7:35 PMpip install -U pip
). Has anyone done this before and, if so, how?