fresh-cat-90827
05/15/2022, 2:02 PMisort
doesn’t support saving the output error messages into a file (in the same way you can do flake8 --output-file=reports/flake8.txt
). If I’d be calling isort
on its own, I could just tee
, but since it happens in the ./pants lint
call, I can’t do that. Have I overlooked anything in the options and it’s actually possible to produce a file report? Is it something we could extend in Pants itself to produce such a report?breezy-cat-52718
05/15/2022, 8:05 PMrestartable=True
doesn't wait until the previous docker container stops.
I'll provide an example:
src/docker/BUILD
docker_image(
name="app",
dependencies=["src/python/app:bin"],
restartable=True
)
src/python/app/BUILD
python_sources()
pex_binary(
name="bin",
entry_point="main.py"
)
src/docker/Dockerfile
FROM python:3.9-slim
COPY <http://src.python.app/bin.pex|src.python.app/bin.pex> /app/bin
ENTRYPOINT [ "/app/bin" ]
Then running as:
./pants run --docker-run-args="-p 8000:8000" src/docker:app
Runs fine, but fails when any file is modified:
docker: Error response from daemon: driver failed programming external connectivity on endpoint cool_gould (5a6265badca64afa4e304e6475119f912621ee8cddf8e195d36a6d0d55b7854f): Bind for 0.0.0.0:8000 failed: port is already allocated.
./pants run --docker-run-args="-p 8000:8000 --name=app" src/docker:app
Also runs fine, but fails when any file is modified:
docker: Error response from daemon: Conflict. The container name "/app" is already in use by container "e003d8f7b8c1e963e1f540ab49a06b67a21530938ac1f9092862e858e800dcfe". You have to remove (or rename) that container to be able to reuse that name.passing --rm to the --docker-run-args gives the same result
rhythmic-morning-87313
05/16/2022, 7:41 AMbulky-alarm-94027
05/16/2022, 9:47 AMgit describe
hundreds-father-404
05/16/2022, 1:55 PMname=
field less confusing & target addresses simpler..would you be willing to run this script and report back on what it says?
(warning it may take ~3-15 minutes probably, and you can't run other Pants commands while doing it)witty-family-13337
05/16/2022, 2:05 PMdeploy_jar
, etc), to have dependencies on file
targets as well as in resources
? The case that I’m thinking of is one in which I would like to launch a subprocess (generated at an earlier stage) at the start of a test suite. Being a runnable file, I can not run it from inside a JAR so I can’t use a dependency on a `resource`…thousands-ability-24126
05/16/2022, 4:14 PMpants run
has some built-in tools for that.
Thanks!rough-electrician-21871
05/16/2022, 4:58 PMpants
? In conventional CI tool I'd just docker-compose up
stuff and run my pytest
bitter-ability-32190
05/16/2022, 5:48 PM./pants --dependencies --transitive some/other:tgt
busy-vase-39202
05/16/2022, 6:56 PMfull-student-91825
05/16/2022, 7:40 PM./pants fmt ::
and ./pants test
for multiple Python versions? Something equivalent to Nox sessions.brainy-solstice-27042
05/16/2022, 8:13 PMhappy-kitchen-89482
05/16/2022, 8:54 PMambitious-actor-36781
05/16/2022, 9:28 PMpython_tests()
in my BUILD files have tags. but only the .py
files have them when doing a ./pants peek
Which means ./pants --tags=-integration_tests ::
picks //tests/python/integration:tests
and subsequently all the tests within.rapid-exabyte-76685
05/17/2022, 6:22 AM--test-output=all
is still only giving me the stdout from the test that fails… is there something that I could be doing wrong here? Also is it true that both --test-output=all
and --output=all
do the same thing?rapid-exabyte-76685
05/17/2022, 6:27 AMtest_<xxx>.py
files - and my tests fail depending on the order in which Pants decides to run the files, so making it a bit time-consuming to force a run that triggers the race conditionrhythmic-morning-87313
05/17/2022, 8:50 AMcold-soccer-63228
05/17/2022, 3:12 PMInferDependenciesRequest
, what is the difference between from_sources
and infer_from
? The docstring description and example for https://github.com/pantsbuild/pants/blob/c73b9f68b7e05ac455057142ae50c75f2560d06b/src/python/pants/engine/target.py#L2529-L2559 seem to contradict each otherkind-hydrogen-975
05/17/2022, 5:06 PM./pants test <some_app_that_puts_files_to_s3>
locally, it works. inside circleCI, same exact command fails on creds.. The credentials for AWS are working in CircleCI because other non-pants apps are using them.
Any hint anyone? I'm assuming the test runs in sort of a "chrooted" environment, but why does it work locally but not in circleCI? thanks 🙂hundreds-father-404
05/17/2022, 10:49 PMdocs
, docsgen
, docs-gen
, gen-docs
?
2. Where do we write the result? dist/docs/<project_name>
?thousands-ability-24126
05/17/2022, 11:36 PMpants run
errors print the original source path in a Python stacktrace, instead of the …/.pants.d/tmp…
source path?happy-kitchen-89482
05/18/2022, 4:39 AMcheck
on python code with [mypy].interpreter_constraints is set, we don't actually use those constraints on targets that have their own ICscold-soccer-63228
05/18/2022, 2:37 PMpath/to/service/graphql/BUILD
files, where *.graphql
files are siblings in the directories by subclassing PutativeTargetsRequest
.
resources(
name="graphql_schema",
sources=[
"*.graphql",
],
)
I'm interested in making it so that Python sources that invoke ariadne.load_schema_by_path
have dependencies on all GraphQL resources in my codebase, e.g. the targets specified in each path/to/service/graphql/BUILD
file. (This is necessary because the ariadne.load_schema_by_path
function opens GraphQL file paths.)
I think the BUILD
file I want to generate should look something like the following:
python_sources(
dependencies=[
"path/to/service_a/graphql:graphql_schema",
"path/to/service_b/graphql:graphql_schema",
"path/to/service_c/graphql:graphql_schema",
...
]
)
I see that infer_python_dependencies_via_source is a rule that already exists in the Python backend. I was wondering if I could leverage this.
To solve my problem, would it be valid to create an additional rule, e.g. infer_python_graphql_dependencies
that awaits Get(InferredDependencies, ...)
, and then looks through the dependencies, and adds dependencies on all "path/to/service/graphql:graphql_schema"
targets whenever an ariadne
dependency is found?
So far, I have the following (not working) code that I'm trying to play with.
class InferPythonGraphQLResourceDependenciesRequest(InferDependenciesRequest):
infer_from = PythonSourceField
@rule(desc="Inferring Python GraphQL dependencies by analyzing source")
async def infer_python_graphql_dependencies(
request: InferPythonGraphQLResourceDependenciesRequest,
python_infer_subsystem: PythonInferSubsystem,
python_setup: PythonSetup,
) -> InferredDependencies:
if not python_infer_subsystem.imports and not python_infer_subsystem.assets:
return InferredDependencies([])
_wrapped_tgt = await Get(WrappedTarget, Address, request.sources_field.address)
tgt = _wrapped_tgt.target
return await Get(InferredDependencies, DependenciesRequest(tgt[Dependencies]))
def rules() -> Iterable[Rule]:
return [
infer_python_graphql_dependencies,
UnionRule(InferDependenciesRequest, InferPythonGraphQLResourceDependenciesRequest),
]
The issue with this code are errors that look like the following:
No installed rules return the type InferConftestDependencies
No installed rules return the type InferInitDependencies
No installed rules return the type InferPythonGraphQLResourceDependenciesRequest
Do I perhaps I need to re-register rules the rules()
function defined in my dependency inference declarations?limited-insurance-37393
05/18/2022, 3:19 PM⇉ ./pants tailor
11:16:35.25 [INFO] Initializing scheduler...
11:16:35.36 [INFO] Scheduler initialized.
11:16:35.42 [ERROR] 1 Exception encountered:
Exception: Failed to read link "/home/tmacey/code/mit/data/ol-data-platform/.venv/bin/python": Absolute symlink: "/home/tmacey/.pyenv/versions/3.9.9/bin/python"
happy-kitchen-89482
05/18/2022, 3:32 PM# type: ignore
to help it along), but fails slowly under Pants (partly because those # type: ignore
are unneeded)bitter-ability-32190
05/18/2022, 6:41 PMpants.toml
with build_file_prelude_globs
which in it I put type hints (because I'm used to it).
Specifically I used foo: str | None = None
. Myself and all my devs use py 3.8. I can see py3.8
being used in the Pants bootstrap env.
I use the macro in a few places.
...and yet nothing errors (It should, the union syntax for the types wasn't added until 3.10). Until now. Someone just got the error.
What's happening? I'm bewildered.cold-soccer-63228
05/18/2022, 7:24 PMfrom pants.testutil.rule_runner import RuleRunner
Is there any way I can use this? I want to write some tests for my plugins. I'm getting the following error.
Import "pants.testutil.rule_runner" could not be resolved
rapid-bird-79300
05/18/2022, 9:15 PM2.11.0
.
I recently upgraded my go version 1.17->1.18
and when running Pants I'm seeing this error:
BinaryNotFoundError: Cannot find a `go` binary with the expected version of 1.18 (set by `[golang].expected_version`).
Found these `go` binaries, but they had different versions:
* /usr/local/bin/go: 1.17
To fix, please install the expected version (<https://golang.org/doc/install>) and ensure that it is discoverable via the option `[golang].go_search_paths`, or change `[golang].expected_version`.
When inspecting the go version it seems to be correct
$/usr/local/bin/go version
go version go1.18.2 darwin/amd64
Not sure if it's pants related at all but any help is appreciatedhigh-yak-85899
05/18/2022, 10:10 PM--colors
shouldn't be the default. Any tips for what I might have changed or done to make it think this?hundreds-father-404
05/19/2022, 12:33 AM!
? E.g. ./pants test 'project/*.py' '!project/ignore.py'
*Edit: this is not about the sources
field in BUILD files. Only CLI arguments
👎 I had no idea
➖ yes, but I've never used
👍 yes, and I've used at least once