fresh-account-42296
12/10/2021, 3:49 PMfresh-account-42296
12/10/2021, 3:52 PMTwoStepPex
and PexInterpreterConstraints
but even if I start from scratch (by deleting ~/.cache/pants
) I get an panic at 'Loop subgraph
errorfresh-account-42296
12/10/2021, 3:53 PM16:29:21.41 [ERROR] panic at 'Loop subgraph: digraph {
0 [ label = "NodeIndex(46885): Deleted(reason: Monomorphized, ParamsLabeled(node: @rule(pants.engine.process:244:fallible_to_exec_result_or_raise(FallibleProcessResult, ProductDescription) -> ProcessResult), in: (Process), out: ((PrefilledSetupKwargsRequest, Process, PytestCoverageDataCollection, Specs))))" ]
1 [ label = "NodeIndex(46896): Deleted(reason: Monomorphized, ParamsLabeled(node: @rule(pants.engine.process:233:get_multi_platform_request_description(MultiPlatformProcess) -> ProductDescription), in: (Process), out: ((PrefilledSetupKwargsRequest, Process, PytestCoverageDataCollection, Specs))))" ]
2 [ label = "NodeIndex(46897): Deleted(reason: Monomorphized, ParamsLabeled(node: @rule(pants.engine.process:266:remove_platform_information(FallibleProcessResultWithPlatform) -> FallibleProcessResult), in: (Process), out: ((PrefilledSetupKwargsRequest, Process, PytestCoverageDataCollection, Specs))))" ]
3 [ label = "NodeIndex(46910): ParamsLabeled(node: @rule(pants.engine.process:504:find_binary(BinaryPathRequest) -> BinaryPaths, gets=[Get(BashBinary, BashBinaryRequest), Get(PyDigest, CreateDigest), Get(ProcessResult, Process), Get(FallibleProcessResult, Process)]), in: (BinaryPathRequest), out: ((BinaryPathRequest, PrefilledSetupKwargsRequest, PytestCoverageDataCollection, Specs)))" ]
4 [ label = "NodeIndex(46919): Deleted(reason: Monomorphized, ParamsLabeled(node: @rule(pants.engine.process:484:find_bash(BashBinaryRequest) -> BashBinary, gets=[Get(BinaryPaths, BinaryPathRequest)]), in: (BashBinaryRequest), out: ((BashBinaryRequest, PrefilledSetupKwargsRequest, PytestCoverageDataCollection, Specs))))" ]
5 [ label = "NodeIndex(46920): Deleted(reason: Monomorphized, ParamsLabeled(node: @rule(pants.engine.process:498:get_bash() -> BashBinary, gets=[Get(BashBinary, BashBinaryRequest)]), in: (()), out: ((BashBinaryRequest, PrefilledSetupKwargsRequest, PytestCoverageDataCollection, Specs))))" ]
0 -> 1 [ label = "ProductDescription" ]
0 -> 2 [ label = "FallibleProcessResult" ]
3 -> 2 [ label = "Get(FallibleProcessResult, Process)" ]
3 -> 0 [ label = "Get(ProcessResult, Process)" ]
3 -> 4 [ label = "Get(BashBinary, BashBinaryRequest)" ]
3 -> 5 [ label = "Get(BashBinary, BashBinaryRequest)" ]
5 -> 4 [ label = "Get(BashBinary, BashBinaryRequest)" ]
5 -> 5 [ label = "Get(BashBinary, BashBinaryRequest)" ]
4 -> 3 [ label = "Get(BinaryPaths, BinaryPathRequest)" ]
}
', /__w/pants/pants/src/rust/engine/rule_graph/src/builder.rs:706
16:29:21.41 [ERROR] Please set RUST_BACKTRACE=1, re-run, and then file a bug at <https://github.com/pantsbuild/pants/issues>.
16:29:21.48 [ERROR] Rust panic
fresh-account-42296
12/10/2021, 3:53 PMhappy-kitchen-89482
12/10/2021, 4:05 PMfresh-account-42296
12/10/2021, 4:57 PMfresh-account-42296
12/10/2021, 5:22 PMhappy-kitchen-89482
12/10/2021, 5:30 PMenough-analyst-54434
12/10/2021, 5:43 PMenough-analyst-54434
12/10/2021, 5:44 PMfresh-account-42296
12/10/2021, 5:56 PM./pants --version
runs throughhappy-kitchen-89482
12/10/2021, 6:03 PMhappy-kitchen-89482
12/10/2021, 6:04 PMfresh-account-42296
12/10/2021, 8:41 PMfresh-account-42296
12/10/2021, 9:32 PMhundreds-father-404
12/13/2021, 7:42 PMfresh-account-42296
12/14/2021, 7:06 AMfresh-account-42296
12/14/2021, 1:33 PMdef rules():
return [
*collect_rules(),
# Register a custom KwargsRequest as a possible alternative to the default
# Since the `is_applicable` method of our custom type always returns True,
# Pants will always choose PrefilledSetupKwargsRequest over
# SetupKwargsRequest.
# UnionRule(SetupKwargsRequest, PrefilledSetupKwargsRequest),
]
@dataclass
class Pep440Version:
version: str
class PrefilledSetupKwargsRequest(SetupKwargsRequest):
"""Custom Pants type for providing default arguments for the `setup_py` target."""
@classmethod
def is_applicable(cls, target: Target) -> bool:
return True
@rule
async def setup_kwargs_plugin(request: PrefilledSetupKwargsRequest) -> SetupKwargs:
if "version" in request.explicit_kwargs:
raise ValueError(
f"The version argument is specified in the setup_py arguments of "
f'"{request.target.address}", but it is supposed to be derived from the '
f"VCS tags. Please remove the version specifier and let this plugin handle "
f"the versioning."
)
address_path = request.target.address.spec_path
pep440_version = await Get(Pep440Version, SourceRootRequest(PurePath(address_path)))
return SetupKwargs(
{"version": pep440_version.version, **request.explicit_kwargs},
address=request.target.address,
)
fresh-account-42296
12/14/2021, 1:34 PMhappy-kitchen-89482
12/14/2021, 8:40 PMhappy-kitchen-89482
12/14/2021, 8:46 PMhundreds-father-404
12/14/2021, 11:44 PMhundreds-father-404
12/15/2021, 12:19 AMfresh-account-42296
12/15/2021, 6:45 AMhundreds-father-404
12/15/2021, 4:35 PMSourceRootRequest -> SourceRoot-> Pep440Version
. For whatever reason, the engine didn't like that when used inside the CustomSetupPyKwargs
plugin hook. It wasn't actually necessary though, they were only using SourceRootRequest
as a "newtype" for PurePath
and because they liked a classmethod it had. Fix was to add Pep440VersionRequest
to "newtype" PurePath
• There are other migration things they still have to do. Ralf plans to upgrade to 2.6 and land that, and then 2.7, then 2.8
• I encouraged Ralf to still reach out for help if they hit any other roadblocks 🙂
Ralf, fyi I had a WIP yesterday to upgrade your Sphinx plugin to Pants 2.8 with the changes made to the SourcesField
. I didn't finish it, but gives you a head start. Will DM the diffhappy-kitchen-89482
12/15/2021, 8:25 PMhundreds-father-404
12/15/2021, 8:27 PMfresh-account-42296
12/15/2021, 8:30 PMfresh-account-42296
12/15/2021, 8:42 PMfresh-account-42296
12/16/2021, 4:14 PMhappy-kitchen-89482
12/16/2021, 6:01 PMfresh-account-42296
12/20/2021, 9:43 AMhappy-kitchen-89482
12/20/2021, 10:48 AMfresh-account-42296
12/20/2021, 10:51 AMhundreds-father-404
12/20/2021, 4:20 PMfresh-account-42296
12/20/2021, 4:26 PMhundreds-father-404
12/20/2021, 11:15 PMpants.backend.python
to be able to use VenvPex
in your ruleshundreds-father-404
12/21/2021, 12:16 AMartifacts.py
packages = await MultiGet(
Get(BuiltPackage, PackageFieldSet, field_set)
for field_set in field_sets_per_target.field_sets
)
You're essentially invoking the package
goal inside the codegen plugin hook. That creates a cycle between package <-> codegen. Packaging often depends on codegen as a precursor. And now you're saying that that codegen first depends on building the relevant packages.
Now, sometimes you can have circular dependencies in a graph like this, which is probably why it worked in Pants 2.5. But often it causes issues like this
To fix this, two options:
1. Give up on your artifacts
target
2. Make the codegen rule less general so that you don't try to build any arbitrary package, only ones you've "blessed" to not use codegen. You could still use await Get(FieldSetsPerTarget, FieldSetsPerTargetRequest)
, but then inspect the returning FieldSets
, like split PexBinaryFieldSet
vs ArchiveFieldSet
. Rather than using the generic "union" Get(BuiltPackage, PackageFieldSet
, use a couple more specific calls like Get(BuiltPackage, ArchiveFieldSet)
. Warn or error if the field has any targets that are not
"blessed"
cc @witty-crayon-22786 - does this all sound right?witty-crayon-22786
12/21/2021, 12:17 AMhundreds-father-404
12/21/2021, 12:18 AMwitty-crayon-22786
12/21/2021, 4:08 PMwitty-crayon-22786
12/21/2021, 4:10 PMwitty-crayon-22786
12/21/2021, 4:13 PMhundreds-father-404
12/21/2021, 4:16 PMfresh-account-42296
12/21/2021, 4:28 PMfresh-account-42296
12/21/2021, 10:33 PMartifacts
plugin more specific I ran into another problem (which is probably very easy to solve).
As an intermediate attempt, I adapted the code as follows:
packages = []
for field_set in field_sets_per_target.field_sets:
if isinstance(field_set, NpmBuildFieldSet):
package = await Get(
BuiltPackage, NpmBuildFieldSet, field_set
)
packages.append(package)
elif isinstance(field_set, PexBinaryFieldSet):
package = await Get(
BuiltPackage, PexBinaryFieldSet, field_set
)
packages.append(package)
else:
logger.warn(f"[WARN] No package is built currently for {field_set} as input PackageFieldSet")
Running this code in one target that only uses the NpmBuildFieldSet
works fine.
However, running this code on another target that also uses PexBinaryFieldSet
, I receive the following error:
Exception: Invalid Get. Because the second argument to `Get(BuiltPackage, PexBinaryFieldSet, PexBinaryFieldSet(address=Address(fleetsim:app), entry_point=<class 'pants.backend.python.target_types.PexEntryPointField'>(alias='entry_point', address=fleetsim:app, value={repr(self.value)}, default={repr(self.default)}), output_path=<class 'pants.core.goals.package.OutputPathField'>(alias='output_path', value='fleetsim/fleetsim.pex', default=None), always_write_cache=<class 'pants.backend.python.target_types.PexAlwaysWriteCacheField'>(alias='always_write_cache', value=False, default=False), emit_warnings=<class 'pants.backend.python.target_types.PexEmitWarningsField'>(alias='emit_warnings', value=None, default=None), ignore_errors=<class 'pants.backend.python.target_types.PexIgnoreErrorsField'>(alias='ignore_errors', value=False, default=False), inherit_path=<class 'pants.backend.python.target_types.PexInheritPathField'>(alias='inherit_path', value=None, default=None), shebang=<class 'pants.backend.python.target_types.PexShebangField'>(alias='shebang', value=None, default=None), zip_safe=<class 'pants.backend.python.target_types.PexZipSafeField'>(alias='zip_safe', value=False, default=True), platforms=<class 'pants.backend.python.target_types.PexPlatformsField'>(alias='platforms', value=None, default=None), execution_mode=<class 'pants.backend.python.target_types.PexExecutionModeField'>(alias='execution_mode', value='zipapp', default='zipapp'), include_tools=<class 'pants.backend.python.target_types.PexIncludeToolsField'>(alias='include_tools', value=False, default=False)))` is annotated with `@union`, the third argument should be a member of that union. Did you intend to register `UnionRule(PexBinaryFieldSet, PexBinaryFieldSet)`? If not, you may be using the wrong type (PexBinaryFieldSet) for the third argument.
Is there something I oversaw? Or did I misunderstood your suggestion?hundreds-father-404
12/21/2021, 10:41 PMfresh-account-42296
12/21/2021, 10:55 PM