happy-kitchen-89482
09/16/2022, 9:02 PMhappy-kitchen-89482
09/16/2022, 9:03 PMoutput
) should be empty simply because the sandbox starts out empty, and is populated with just the input digestloud-laptop-17949
09/16/2022, 9:49 PMdependees
? I am trying to get a map of dependees for a bunch of files and am either faced with running through a loop and calling dependees for each (slow) or using xargs to ./pants
and calling dependees once, losing track of which target the dependee came from.
Ideally I could call dependees
(and maybe other commands like it) once with a bunch of targets and get something like a json map of which target has which dependee.straight-action-80318
09/16/2022, 10:03 PM{
"errorMessage": "the 'package' argument is required to perform a relative import for '.app.lambdex_handler'",
"errorType": "TypeError",
"requestId": "",
"stackTrace": [
" File \"/var/lang/lib/python3.9/importlib/__init__.py\", line 122, in import_module\n raise TypeError(msg.format(name))\n"
]
}
I have re-created the repo based on the docs here: https://github.com/nharada1/lambda-aws-pants-demo
My only changes are I’m using Python 3.9 instead of 3.8curved-farmer-66180
09/17/2022, 3:03 AMdjango-ninja>=0.19.1
2. lockfile
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
// {
// "version": 2,
// "valid_for_interpreter_constraints": [
// "CPython>=3.7"
// ],
// "generated_with_requirements": [
// "ansicolors>=1.0.2",
// "django-ninja>=0.19.1",
// "django-stubs>=1.10.0",
// "django<4,>=3.2.13",
// "gunicorn>=20.1.0",
// "protobuf>=3.11.3",
// "pytest>=6.0.1",
// "requests>=2.25.1",
// "setuptools>=42.0.0",
// "translate>=3.2.1",
// "types-requests>=2.25.1"
// ]
// }
3. BUILD
# Copyright 2021 Pants project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).
python_sources(
name="lib",
dependencies=[
"helloworld/person/migrations",
]
)
python_tests(
name="tests",
dependencies=[
"helloworld", # For settings.py.
],
)
python_test_utils(
name="test_utils",
)
4. api.py
from ninja import NinjaAPI
api = NinjaAPI()
@api.get("/add")
def add(request, a:int, b:int):
return {"result": a + b}
broad-processor-92400
09/18/2022, 11:52 PMtouch path/to/file
)
• changing a file that the running task(s) do not (transitively) depend on
For either of these, I'd expect the running tasks to keep running, and it's annoying that fiddling on some unrelated part of a codebase forces things to restart. Is this the expected behaviour?handsome-sunset-98068
09/19/2022, 5:05 AMcreamy-truck-92790
09/19/2022, 8:41 AMNote that only Django core commands are listed as settings are not properly configured (error: No module named 'test_config').
Even though ./pants depedencies ::
shows that test_config is included, just as backend/test_config/
.creamy-truck-92790
09/19/2022, 1:38 PM./pants run backend/modules/mod1:manage -- shell
). However when I do runserver (e.g. ./pants run backend/modules/mod1:manage -- runserver
) it complains that django is not installed. (No module found...)
Any idea why?
it seems to disregard all installed side-packages...adamant-coat-28831
09/19/2022, 2:46 PM./pants check ::
would list any dangling targets, ie targets that aren't used anywhere because they are misconfigured.creamy-truck-92790
09/19/2022, 3:50 PMBUILD
files in all subdirectories that I need or can I also just aggregate all files with:
python_sources(
name="lib",
sources=["folder/**/*.py"],
)
When I do this, I get the error ImportError: No module named manage
, but I am not sure if this is because this is not allowed or because I am doing something else that is wrong.mysterious-waiter-14207
09/19/2022, 6:44 PMremote_cache
which default to true and false on some very light processes?
2. Should some process not speculate (local process race with remote cache) because they are too heavy to start? I'm thinking mainly nailgun, java processes or tests.gorgeous-addition-6562
09/19/2022, 8:55 PMpants.toml
but that doesn't help:
[python-bootstrap]
search_path = ["/usr/bin/python3"]
brainy-solstice-27042
09/19/2022, 9:14 PMclever-hamburger-59716
09/19/2022, 9:37 PMpython_requirement(
name="client-lib",
requirements=["client-lib.whl"],
)
pex_binary(
name="service",
entry_point="service.py",
platforms=[
'current',
'manylinux2014-x86_64-cp-39-cp39',
'macosx-12.0-x86_64-cp-39-cp39',
],
dependencies=[":client-lib"],
)
This errors out with `Requirement 'client-lib....whl' looks like a filename, but the file does not exist`.
1. Is this the right way to package a local wheel into a pex_binary
2. If so, what is the right way to specify the path?
3. If not, would love some help on how to go about doing this.
TIA
ambitious-actor-36781
09/19/2022, 10:17 PM[mypy].extra_type_stubs
doesn't seem to contribute to any lockfiles. Is this intentional? (2.12.0)gorgeous-addition-6562
09/19/2022, 10:31 PM./pants run
with python subprocess
, but it doesn't allow me to do that since a pants process is already running. I've also tried to subprocess.run
python (sys.executable
) my scripts but it looks like that doesn't pick up the dependencies correctly (fail to import third party packages))straight-action-80318
09/19/2022, 11:22 PM./pants package
that lets me bundle everything together, and then use EMR’s Docker support to run my code remotely? I’m not sure how to create an environment for the workers, although I assume there’s a way to install the Pants repo into the docker such that it’s available for the workers?
I think if I wasn’t using Pants, what I would do is setup a docker container such that my repo has been pip install
’d, that way all of the imports work for the Python.plain-carpet-73994
09/20/2022, 12:07 AMpants repl
interacts with distribution targets. I have a sample library that depends on pyyaml
. That library has a target named lib
which is just a python_sources
goal and a target named example_lib
which is a python_distribution
target. If I do:
./pants repl src/example_lib/:lib
everything works fine. But suppose I want a repl with all the libs in my monorepo available. The obvious way to do that would be ./pants repl ::
but that gives me:
$ ./pants repl ::
Traceback (most recent call last):
File "/home/oliver/.pyenv/versions/3.10.0a7/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/oliver/.pyenv/versions/3.10.0a7/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/__main__.py", line 103, in <module>
bootstrap_pex(__entry_point__, execute=__execute__, venv_dir=__venv_dir__)
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/pex_bootstrapper.py", line 601, in bootstrap_pex
pex.PEX(entry_point).execute()
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/pex.py", line 519, in execute
self.activate()
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/pex.py", line 156, in activate
self._activated_dists = self._activate()
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/pex.py", line 143, in _activate
activated_dists.extend(env.activate())
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/environment.py", line 321, in activate
self._activated_dists = self._activate()
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/environment.py", line 671, in _activate
resolved = self.resolve()
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/environment.py", line 502, in resolve
for fingerprinted_distribution in self.resolve_dists(all_reqs)
File "/home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/aa78b3981cc88964a18a80d8fa2d708ffe5155b2/.bootstrap/pex/environment.py", line 589, in resolve_dists
raise ResolveError(
pex.environment.ResolveError: Failed to resolve requirements from PEX environment @ /home/oliver/.cache/pants/named_caches/pex_root/unzipped_pexes/452071acbd3c0c2b132caf245582cb4d49e6d821.
Needed cp310-cp310-manylinux_2_31_x86_64 compatible dependencies for:
1: pyyaml
Required by:
example-lib 1.0.0
But this pex had no ProjectName(raw='pyyaml', normalized='pyyaml') distributions.
2: types-PyYAML
Required by:
example-lib 1.0.0
But this pex had no ProjectName(raw='types-PyYAML', normalized='types-pyyaml') distributions.
Note that the actual built distribution has its dependencies specified correctly:
$ tar -O -zxvf dist/example_lib-1.0.0.tar.gz example_lib-1.0.0/setup.py
example_lib-1.0.0/setup.py
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
# Target: src/example_lib:example_lib
from setuptools import setup
setup(**{
'install_requires': (
'pyyaml',
'types-PyYAML',
),
'name': 'example_lib',
'namespace_packages': (
),
'package_data': {
},
'packages': (
'example_lib',
),
'python_requires': '==3.10.*',
'version': '1.0.0',
})
Is there no way to do a pants repl
for all libraries in a repo that has one or more distribution targets?plain-summer-72727
09/20/2022, 12:23 AMpython_sources(
name="lib",
dependencies=[
"//:root#auth0-python",
"//:root#django-admin-rangefilter",
...,
],
)
pex_binary(
name="manage",
entry_point="manage.py",
dependencies=[
":lib",
],
restartable=True,
)
My Django application has various HTML files, SQL files, and other non-Python files that are required for it to function. What's the typical pattern to make sure that these files are present in the PEX when running ./pants package src/myapp/manage.py
?ambitious-actor-36781
09/20/2022, 3:53 AM./pants package something/that/uses:grpcio
works.
but under our "other" image we're being forced to use, something gets upset and tries to compile grpcio, and subsequently fails.
Yet when I run pip3 install grpcio
it seems to download a compiled version.incalculable-grass-76623
09/20/2022, 7:00 AMdocker_image(
name="docker_image",
repository="my-image-name",
image_tags=[the_version()],
dependencies=[":the_python_pkg", ":docker_resources"],
)
where the_version()
is coming from a rule generated in a plugin
This is the "test plugin" i have written:
# pants-plugin/versioning/register.py
import os
from pants.engine.rules import collect_rules, rule
@rule
async def the_version() -> str:
return os.popen('git --no-pager describe --always --dirty --broken').read()
def rules():
return collect_rules()
However when ./pants package path/to:docker
is run I am expecting the docker_image tag to pickup the "string" from the the_version()
however pant` does not register the rule as a symbol ? (maybe it's not a rule I need)
MappingError: Failed to parse ./services/my-image/BUILD:
Name 'the_version' is not defined.
If you expect to see more symbols activated in the below list, refer to <https://www.pantsbuild.org/v2.13/docs/enabling-backends> for all available backends to activate.
All registered symbols: ['_generator_sources_helper', 'archive', 'build_file_dir', 'docker_image', 'experimental_run_shell_command', 'experimental_shell_command', 'file', 'files', 'helm_artifact', 'helm_chart', 'helm_unittest_test', 'helm_unittest_tests', 'http_source', 'parametrize', 'pex_binaries', 'pex_binary', 'pipenv_requirements', 'poetry_requirements', 'python_artifact', 'python_distribution', 'python_requirement', 'python_requirements', 'python_source', 'python_sources', 'python_test', 'python_test_utils', 'python_tests', 'relocated_files', 'resource', 'resources', 'setup_py', 'shell_source', 'shell_sources', 'shunit2_test', 'shunit2_tests', 'target']
My goal for this first step is to get pants
to "auto collect" the "GIT_COMMIT" version
ref: https://www.pantsbuild.org/v2.11/docs/tagging-docker-images#using-env-vars-to-include-dynamic-data-in-tags
and provide it as a variable or via a function (like I tried above).
Such that
./pants package src/example:demo
Builds a docker image with demo:$(git rev-parse HEAD)
cool-yacht-37128
09/20/2022, 7:32 AMcreamy-truck-92790
09/20/2022, 7:43 AMgentle-sugar-52379
09/20/2022, 9:09 AMbulky-mouse-48830
09/20/2022, 2:20 PMtarget-system
for lockfile generation. I am only interested in linux
as a target system, but Pants seems to fail because it wants dependencies to be resolved for all platforms.plain-carpet-73994
09/20/2022, 4:11 PMcurved-television-6568
09/20/2022, 5:49 PMincalculable-hydrogen-44003
09/20/2022, 5:54 PMadmin.py
files are getting pulled in (as well as other magic dependencies). Does anybody have any tips on how to solve this?rough-vase-83553
09/20/2022, 7:08 PM