hundreds-father-404
09/01/2020, 8:46 AMminiature-lamp-45970
09/02/2020, 4:59 AMnarrow-activity-17405
09/02/2020, 6:44 AMrun_pants(["run", "src/python/package_A/script"])
Using this approach, is it possible to run multiple binaries at the same time? I will give it a try, thanks for the tip!hundreds-father-404
09/02/2020, 7:12 AMInitially, I thought it is only for testing of plugins but it can probably be used to run any script within the project, right?Typically, it’s designed for running on synthetic test projects created via
setup_tmpdir()
. I imagine you want to run on your actual project, rather than some contrived example, right?
This is where things would start to fall apart. Tests run in a chroot (tmpdir) in Pants, meaning that they will only copy over files that are known about through the dependencies()
field. (Why? This allows us to safely run tests in parallel and remote execution). So, your test would not have access to src/python/package_A/script
.
You could put a dependency on the python_binary
target in src/python/package_A/script
, but that won’t do what you’re expecting. That will copy over the Python files with the source roots stripped, like package_A/script
. It won’t copy over the raw file, and it won’t copy over the BUILD file either. So, run_pants(["run", "src/python/package_A/script"])
would complain “No BUILD file in src/python/package_A/script”.
You could work around that by declaring a files()
target owning that script, and owning its original BUILD file. A files()
target doesn’t strip source roots - the files get copied exactly as-is. Then, add a dependency to the files()
target to the python_tests()
.
That works fine, and we do that for several Pants integration tests. Unless…`src/python/package_A/script` depends on a bunch of other files, like most projects do. You would need a files()
target owning all of its transitive dependencies..which we’ve found is not feasible to do.
So, my suggestion is only helpful if either a) you’re okay with creating a synthetic target, or b) "src/python/package_A/script"
has very few dependencies. I suspect neither of those are true, unfortunately.
--
Given the above, Benjy is thinking through more robust ways to do what you’re askinggentle-engine-57253
09/02/2020, 9:18 AMgentle-engine-57253
09/02/2020, 9:22 AMgentle-engine-57253
09/02/2020, 9:24 AMgentle-engine-57253
09/02/2020, 9:25 AMwooden-thailand-8386
09/02/2020, 11:02 PMpython_app
is causing chaos and there isnt bundle
as a goal anymore. 😞 Did it become something else or we won’t have support for that on v2.0?important-librarian-62877
09/02/2020, 11:14 PMimportant-librarian-62877
09/02/2020, 11:17 PMWe redesigned it in 1.30.0 and are putting final polish on how coverage works in 2.0.0. See the PR description of <https://github.com/pantsbuild/pants/pull/10100> for how it works now
full-oyster-41619
09/03/2020, 1:13 PMnarrow-activity-17405
09/03/2020, 2:49 PMI imagine you want to run on your actual project, rather than some contrived example, rightExactly. Unfortunately, scripts have quite a lot of dependencies. Looking forward to hearing about some more robust way 🙂 At the moment I had to disable integration tests. Many thanks!
narrow-activity-17405
09/03/2020, 3:02 PMModuleNotFoundError: No module named 'A'
I tried running S1 with ./pants run S1 as well as "./dist/S1.pex" with the same result. How can this be solved? Maybe it is just a matter of PYTHONPATH or something like that? I thought that pex is "just" virtual environment so anything that runs within it should be able to import anything that is there 🙂
This can be "solved" by deploying packages through pypi but we also need to build docker images for our scripts and it would be nice if we can just copy one pex file into each docker image. Also, being able to easily test this functionality during development would be nice.narrow-activity-17405
09/04/2020, 2:00 PMpypath = ":".join(sys.path)
myenv = os.environ.copy()
myenv["PYTHONPATH"] = pypath
PROCESS = await asyncio.create_subprocess_exec(
script_path,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT,
env=myenv,
wooden-thailand-8386
09/04/2020, 6:14 PMWARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError("hostname
… seems like using PYTHONHTTPSVERIFY=0
would “fix” that but I’m not sure how to do that / if there’s a better workaroundhappy-kitchen-89482
09/04/2020, 7:03 PMdist/
. Feel free to bikeshed the scheme: https://github.com/pantsbuild/pants/pull/10735orange-beach-75711
09/05/2020, 6:34 AMFROM python:3.7.7-slim
RUN apt-get update \
&& apt-get install -y \
curl \
cmake \
build-essential \
&& apt-get clean
EXPOSE 3000
WORKDIR /app
RUN curl -L -o ./pants <https://pantsbuild.github.io/setup/pants> \
&& chmod +x ./pants
# Copy src dir and pants config files
COPY ./src /app/src/
COPY BUILD /app/
COPY pants_docker.toml /app/pants.toml
COPY requirements.txt /app/
COPY ./dist /app/dist/
RUN ./pants --version
RUN ./pants binary src/nabu/services/api:server
CMD ./dist/server.pex nabu.services.api.wsgi:app -c src/nabu/services/api/gunicorn.conf.py
abundant-byte-99983
09/07/2020, 3:39 PMacceptable-guitar-79854
09/08/2020, 8:37 PM./pants lint my_project/
acceptable-guitar-79854
09/08/2020, 8:38 PMacceptable-guitar-79854
09/08/2020, 8:38 PMacceptable-guitar-79854
09/08/2020, 8:39 PMacceptable-guitar-79854
09/08/2020, 8:39 PMacceptable-guitar-79854
09/08/2020, 8:39 PMacceptable-guitar-79854
09/08/2020, 8:40 PMwooden-thailand-8386
09/09/2020, 1:07 PMpants
is actually getting the .whl files from the folder. What I have on my toml file is:
[python-repos]
repos.add = "%(buildroot)s/.wheels
One of the reasons I’m doing this is to try to speed up the test/bundle by not having to download any dependency from the internet (we have tensorflow and other ML libraries) and under our proxy things take forever 😞plain-river-51682
09/09/2020, 3:00 PMplain-river-51682
09/09/2020, 3:00 PMwonderful-iron-54019
09/10/2020, 5:27 PMfmt
big stack trace in thread