thousands-plumber-33255
12/08/2022, 8:48 AMpants.toml
/services
/serviceA
BUILD
/tests
BUILD
example_test.py
In pants.toml
I have added this entry:
[environments-preview.names]
linux_docker = "//:local_qgis"
In `serviceA/BUILD`:
docker_environment(
name="local_qgis",
image="qgis/qgis:final-3_22_9",
)
In `serviceA/tests/BUILD`:
python_tests(
environment="local_qgis"
)
i am getting the followring error with `./pants test services/serviceA/tests/example_test.py`:
ResolveError: The address //:local_qgis from the option [environments-preview].names does not exist.
The target name ':local_qgis' is not defined in the directory . Did you mean one of these target names?
* :root
Quite sure I have missed something fundamental, but don't get it. Can someone help? 🙂refined-addition-53644
12/08/2022, 9:10 AMname
should be linux_docker
inside docker_environment
and in other places.thousands-plumber-33255
12/08/2022, 9:47 AMrefined-addition-53644
12/08/2022, 10:29 AMlocal_environment
is bit different.refined-addition-53644
12/08/2022, 10:33 AMpython_test
should use the linux_docker
. The docker_environment should be as it is.refined-addition-53644
12/08/2022, 10:40 AMdocker_environment
generates the target using the name
you provide and other target consumes it using the alias you set for the name
in pants.tomlthousands-plumber-33255
12/08/2022, 12:10 PMNew virtual environment successfully created at /home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0.dev4_py39
. all the time. Any idea? Cancelling it and install 2.14.0 works just finethousands-plumber-33255
12/08/2022, 12:32 PMvscode ➜ /nefino_li (feature/2087-add-tests-to-services-qgis-export-feature ✗) $ ./pants --no-pantsd --no-local-cache --print-stacktrace -ldebug --version
Bootstrapping Pants using /usr/bin/python3.9
Creating the virtualenv PEX.
Downloading the Pex PEX.
SHA256 fingerprint of <https://github.com/pantsbuild/pex/releases/download/v2.1.103/pex> verified.
Scrubbing PYTHONPATH
Installing pantsbuild.pants==2.15.0a1 into a virtual environment at /home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0a1_py39
Scrubbing PYTHONPATH
New virtual environment successfully created at /home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0a1_py39.
12:28:36.54 [DEBUG] File handle limit is: 1048576
12:28:36.55 [DEBUG] Using [bounded::CommandRunner { inner: SwitchedCommandRunner { .. }, .. }] for process execution.
12:28:37.18 [DEBUG] Launching 1 roots (poll=false).
Not getting any further. @curved-television-6568 Any idea?busy-vase-39202
12/08/2022, 12:42 PMrefined-addition-53644
12/08/2022, 12:56 PMthousands-plumber-33255
12/08/2022, 1:13 PMcurved-television-6568
12/08/2022, 1:24 PMthousands-plumber-33255
12/08/2022, 3:53 PMwitty-crayon-22786
12/08/2022, 5:52 PM.pants.d/pants.log
?thousands-plumber-33255
12/09/2022, 8:49 AM08:45:23.59 [INFO] handling request:
--pants-bin-name=./pants --pants-version=2.15.0a1 --version``thousands-plumber-33255
12/09/2022, 10:15 AM./pants --print-stacktrace -ldebug test services/qgis/tests/example_test.py
10:02:26.00 [DEBUG] acquiring lock: <pants.pantsd.lock.OwnerPrintingInterProcessFileLock object at 0x7f96edb4a9d0>
10:02:26.00 [DEBUG] terminating pantsd
10:02:26.00 [DEBUG] sending signal 15 to pid 3087
10:02:27.01 [DEBUG] successfully terminated pid 3087
10:02:27.01 [DEBUG] purging metadata directory: .pants/.pids/4b81b7112ed6/pantsd
10:02:27.01 [DEBUG] Launching pantsd
10:02:27.01 [DEBUG] purging metadata directory: .pants/.pids/4b81b7112ed6/pantsd
10:02:27.01 [DEBUG] pantsd command is: PANTS_DAEMON_ENTRYPOINT=pants.pantsd.pants_daemon:launch_new_pantsd_instance PYTHONPATH=/home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/pants.4UZp49/install/bin:/nefino_li/dist/export/python/virtualenvs/default/3.8.15/lib/python3.8/site-packages:/nefino_li:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0a1_py39/lib/python3.9/site-packages /home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0a1_py39/bin/python /home/vscode/.cache/pants/setup/bootstrap-Linux-x86_64/2.15.0a1_py39/bin/pants --pants-bin-name=./pants --pants-version=2.15.0a1 --print-stacktrace -ldebug test services/qgis/tests/example_test.py
10:02:28.91 [DEBUG] pantsd is running at pid 3786, pailgun port is 45317
10:02:28.91 [DEBUG] releasing lock: <pants.pantsd.lock.OwnerPrintingInterProcessFileLock object at 0x7f96edb4a9d0>
10:02:28.91 [DEBUG] Connecting to pantsd on port 45317
10:02:28.91 [DEBUG] Connecting to pantsd on port 45317 attempt 1/3
10:02:28.92 [DEBUG] Connected to pantsd
10:02:28.93 [DEBUG] Launching 1 roots (poll=false).
3. Tried again with `--no-pantsd`:
./pants --print-stacktrace -ldebug test --no-pantsd services/qgis/tests/example_test.py
10:04:27.84 [DEBUG] File handle limit is: 1048576
10:04:27.85 [DEBUG] Using [cache::CommandRunner { inner: bounded::CommandRunner { inner: SwitchedCommandRunner { .. }, .. }, .. }, cache::CommandRunner { inner: bounded::CommandRunner { inner: SwitchedCommandRunner { .. }, .. }, .. }] for process execution.
10:04:28.37 [DEBUG] Launching 1 roots (poll=false).
4. As still not working we were trying to use the latest successfull commit from 2.15.x branch. But now even ./pants --version
hangs again at this stage
All of that is running in a devcontainer with Dockerfile python-3.8.15-bullseye
witty-crayon-22786
12/09/2022, 4:20 PM-ltrace
might help give a bit more information? but most likely the next step is going to be to try to attach a debugger like gdb
or lldb
to see where threads are.
thanks again for testing the alphas, and sorry for the trouble!witty-crayon-22786
12/09/2022, 4:21 PMpantsd
process: it’s not necessary in general, but something strange is going on here.thousands-plumber-33255
12/12/2022, 7:47 AM-ltrace
really. I also tried using the 2.15.0rc0
, but still no success. Can you tell me what to run to give you more debug information with e.g. gdb
?witty-crayon-22786
12/12/2022, 5:43 PMgdb
, and then run:
thread apply all bt
witty-crayon-22786
12/12/2022, 6:49 PM--no-pantsd
run in a DM, that might be helpful.thousands-plumber-33255
12/13/2022, 11:36 AMwitty-crayon-22786
12/13/2022, 6:33 PMpy-spy dump -p $pid
to gather a python stacktrace, so we can see which function it’s inthousands-plumber-33255
12/14/2022, 8:32 AMthousands-plumber-33255
12/19/2022, 1:26 PMbuild_file_prelude_globs = ["pants_plugins/macros.py"]
and then no issue at all. My macros.py
looks as follows:
def http_service_image(name, service, **kwargs):
python_awslambda(
name=f"{service}-lambda",
runtime="python3.8",
handler=f"{service}/lambda_handler.py:handler",
# Otherwise pants cannot safely infer as dir name is the same in all services
dependencies=[f"//services/{service}/api", f"//services/{service}/lambda_handler.py"]
)
docker_image(
name=name,
dependencies=[f":{service}-lambda", ":entrypoint"],
image_tags=["{build_args.IMAGE_TAG}"],
extra_build_args=[f"SERVICE={service}"],
repository=f"{{build_args.{service.upper()}_REPO}}",
**kwargs
)
def env_vars_django(**kwargs):
return [
"ENVIRONMENT",
"DEBUG",
"ALLOWED_HOSTS",
"SECRET_KEY",
"DJANGO_LOGGING_ENABLED",
"DJANGO_LOG_LEVEL",
"DOMAIN",
]
When I comment out http_service_image
, it also works. Any idea what is wrong with that? @curved-television-6568 helped me setting this up here. It perfectly works with 2.14.0
.thousands-plumber-33255
12/19/2022, 2:42 PMpython_tests
target as suggested, but now I am getting:
14:37:59.83 [ERROR] 1 Exception encountered:
Engine traceback:
in `test` goal
in Run Pytest - (environment:linux_docker, services/qgis/tests/example_test.py)
ProcessExecutionFailure: Process 'Extract environment variables from the Docker image python:3.8-bullseye' failed with exit code 126.
stdout:
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/pants-sandbox/pants-sandbox-kqW2I5") set in config.json failed: no such file or directory: unknown
stderr:
thousands-plumber-33255
12/19/2022, 3:03 PM/var/run/docker.sock
. Do I need to mount something to the pants container as well such that files are correctly mounted from the host to the test container?refined-addition-53644
12/19/2022, 4:46 PMwitty-crayon-22786
12/19/2022, 6:12 PMthousands-plumber-33255
12/19/2022, 8:16 PMthousands-plumber-33255
12/20/2022, 11:33 AMthousands-plumber-33255
01/03/2023, 7:52 AMwitty-crayon-22786
01/03/2023, 6:14 PMwitty-crayon-22786
01/03/2023, 10:18 PMthousands-plumber-33255
01/04/2023, 8:15 AMthousands-plumber-33255
01/06/2023, 7:07 AMwitty-crayon-22786
01/06/2023, 7:35 PMwitty-crayon-22786
01/06/2023, 8:23 PM