curved-magazine-45623
10/31/2022, 8:15 PMcurved-magazine-45623
10/31/2022, 8:15 PMBuiltPackage
is throwing the following graph error on a basic package command (truncated to respect the Slack character limit):
$./pants package --no-local-cache test_docker:dockerized_flask_app
15:10:38.24 [INFO] Initializing scheduler...
15:10:38.61 [ERROR] Encountered 51 rule graph errors:
No installed rules return the type ArchiveFieldSet, and it was not provided by potential callers of @rule(pants.core.target_types:657:package_archive_target(ArchiveFieldSet) -> BuiltPackage, gets=[Get(Targets, UnparsedAddressInputs), Get(FieldSetsPerTarget, FieldSetsPerTargetRequest), Get(HydratedSources, HydrateSourcesRequest), Get(Snapshot, MergeDigests), Get(Digest, CreateArchive)]).
If that type should be computed by a rule, ensure that that rule is installed.
If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
No installed rules return the type DockerFilesFS, and it was not provided by potential callers of @rule(sendwave.pants_docker.sources:55:get_files(DockerFilesFS) -> DockerComponent, gets=[Get(StrippedSourceFiles, SourceFilesRequest)]).
If that type should be computed by a rule, ensure that that rule is installed.
If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
...
The --print-stacktrace
and -ldebug
flags don’t add anything notable to me, but I’m happy to post the output if you think there might be clues there. Based on trial-and-error (commenting things out until it works), this is the code block in the rule that raises the graph error:
pip_requirement_targets = []
for target in transitive_targets.dependencies:
if isinstance(target, PythonRequirementTarget):
for value in target.get(PythonRequirementsField).value:
pip_requirement_targets.append(value)
pip_requirements_component = await Get(
DockerComponent,
PythonRequirementsFS(requirements=tuple(pip_requirement_targets)),
)
Adding some logging reveals that the first loop to generate the pip_requirement_targets
array works fine; the problem is the Get
call to turn a PythonRequirementsFS
into a DockerComponent
. Here’s the edits we made to that rule, which really don’t change anything other than using a subsystem option to switch up the way that we format the pip install command in the image definition.
@rule
async def get_requirements(
field_set: PythonRequirementsFS, setup: PythonSetup, repos: PythonRepos, docker: Docker
) -> DockerComponent:
...
Any thoughts on how we can proceed with debugging? TL;DR: We have a rule that generates DockerComponent
from PythonRequirementsFS
, but executing that rule via a Get
call seems to raise a graph error implying that no rules were registered at all. The fact that the error is reporting all the rules to be missing rather than the offending one, plus the general tendency of graph errors to be opaque, makes me think there’s some other problem here that’s being suppressed.witty-crayon-22786
10/31/2022, 8:18 PMseems to raise a graph error implying that no rules were registered at all.rule graph errors are unfortunately quite terrible: sorry for the trouble. it’s generally the case that a small breakage causes many dozens-to-hundreds of errors.
curved-magazine-45623
10/31/2022, 8:19 PMwitty-crayon-22786
10/31/2022, 8:19 PM-ltrace --no-pantsd
, as it will render a dot graph for the error witty-crayon-22786
10/31/2022, 8:20 PMcurved-magazine-45623
10/31/2022, 8:24 PMerrored subgraph
is probably the most helpful part of that message, so I’ve attached it here in a txtfile.witty-crayon-22786
10/31/2022, 8:29 PMcurved-magazine-45623
10/31/2022, 8:30 PMwitty-crayon-22786
10/31/2022, 8:31 PMDocker
type a Subsystem?witty-crayon-22786
10/31/2022, 8:32 PMcurved-magazine-45623
10/31/2022, 8:33 PMcurved-magazine-45623
10/31/2022, 8:33 PMwitty-crayon-22786
10/31/2022, 8:40 PMBased on trial-and-error (commenting things out until it works), this is the code block in the rule that raises the graph error:assuming that this is accurate, then the relevant subgraph is here… unfortunately, a symptom of the error messages being terrible is that you have to take all of this with a grain of salt. but it looks like it is attempting to use
sendwave.pants_docker.python_requirement:74:get_requirements
to compute Get(DockerComponent, PythonRequirementsFS)
, but failing for some reason. unfortunately, it is claiming that all of the things it needed are missing, which is unlikely.witty-crayon-22786
10/31/2022, 8:41 PMcurved-magazine-45623
10/31/2022, 8:44 PMget_requirements
is failing?witty-crayon-22786
10/31/2022, 8:45 PMwitty-crayon-22786
10/31/2022, 8:54 PMUnionRule(DockerComponentFieldSet, PythonRequirementsFS)
witty-crayon-22786
10/31/2022, 8:55 PMpackage_into_image
will already be solving Get(DockerComponent, ..)
for all members of DockerComponentFieldSet
witty-crayon-22786
10/31/2022, 8:55 PMGet(DockerComponent, PythonRequirementsFS)
witty-crayon-22786
10/31/2022, 8:56 PMGet(DockerComponent, DockerComponentFieldSet, PythonRequirementsFS(..))
witty-crayon-22786
10/31/2022, 8:56 PMcurved-magazine-45623
10/31/2022, 9:02 PM./pants --print-stacktrace package test_docker:dockerized_flask_app 1 err | 7s | remit-srv py | 04:01:20 PM
16:01:32.69 [INFO] Initializing scheduler...
16:01:33.06 [INFO] Scheduler initialized.
16:01:35.12 [ERROR] 1 Exception encountered:
Engine traceback:
in select
in pants.core.goals.package.package_asset
in sendwave.pants_docker.package.package_into_image (test_docker:dockerized_flask_app)
Traceback (no traceback):
<pants native internals>
Exception: Invalid Get. Because the second argument to `Get(DockerComponent, DockerComponentFieldSet, PythonRequirementsFS(requirements=(<pants.backend.python.pip_requirement.PipRequirement object at 0x10b8f84f0>, <pants.backend.python.pip_requirement.PipRequirement object at 0x10b8f8520>, <pants.backend.python.pip_requirement.PipRequirement object at 0x10b89caf0>)))` is annotated with `@union`, the third argument should be a member of that union. Did you intend to register `UnionRule(DockerComponentFieldSet, PythonRequirementsFS)`? If not, you may be using the wrong type (PythonRequirementsFS) for the third argument.
witty-crayon-22786
10/31/2022, 9:04 PMcurved-magazine-45623
10/31/2022, 9:09 PMrules
definition, which hasn’t changed during this PR: https://github.com/waveremit/pants-docker/blob/e20083ffc4445f105fdf0ad0bef7aab4aa6[…]4deb0/pants_plugins/sendwave/pants_docker/python_requirement.py
def rules():
return [
UnionRule(DockerComponentFieldSet, PythonRequirementsFS),
*collect_rules(),
]
curved-magazine-45623
11/01/2022, 2:26 PM<http://logger.info|logger.info>("Running python_requirement rules")
call in there to see if the rules
function was getting executed, and I confirmed it is:
$ ./pants --print-stacktrace package test_docker:dockerized_flask_app 1 err | 7s | remit-srv py | 09:15:57 AM
09:16:19.18 [INFO] Running python_requirement rules
...
Based on the error, I expect this is the block of Rust code that’s raising the exception: https://github.com/pantsbuild/pants/blob/2adf6ed862403d69ad053f29a36c7928f8cced93/src/rust/engine/src/nodes.rs#L1057-L1080 I’m not totally sure what’s going on here but it seems like the select query is being adjusted to include “in scope types” when searching the edges
object, which is turning up empty and hence falling through to the union exception. Is there any way I can inspect the edges
object directly to see where PythonREquirementsFS
is registered?witty-crayon-22786
11/01/2022, 4:12 PMin scope typesthese are only in 2.15.x + i think… shouldn’t be in any released versions
witty-crayon-22786
11/01/2022, 4:13 PMwitty-crayon-22786
11/01/2022, 4:14 PMcurved-magazine-45623
11/01/2022, 4:34 PMPythonRequirementsFS
object from the installed package in the virtualenv rather than from the development source code, and the object had a different structure in the installed package 🤦♀️ We fixed the import and it works great now!witty-crayon-22786
11/01/2022, 4:35 PMwitty-crayon-22786
11/01/2022, 4:35 PMwitty-crayon-22786
11/01/2022, 4:35 PM