Getting this error when trying to use my custom ta...
# plugins
r
Getting this error when trying to use my custom target type and field set with
TargetRootsToFieldSets
- what am I missing here?
Copy code
10:45:22.46 [ERROR] 1 Exception encountered:

Engine traceback:
  in select
    ..
  in plugins.splat.goals.my_plugin_goal
    `my-plugin-goal` goal

Traceback (most recent call last):
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/Users/nick.dellosa/Projects/data-platform/pants-plugins/plugins/myplugin/goals.py", line 385, in splat_deploy
    target_roots_to_splat_deploy_field_sets = await Get(
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 118, in __await__
    result = yield self
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/engine/internals/specs_rules.py", line 552, in find_valid_field_sets_for_target_roots
    field_set_types=union_membership[request.field_set_superclass],
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/engine/unions.py", line 134, in __getitem__
    return self.union_rules[union_type]  # type: ignore[return-value]
  File "/Users/nick.dellosa/Library/Caches/nce/4ce2ab7b680d1a68593ba94c1a1eb8a45d8b6cc2fd7c215163282f168119ea3d/bindings/venvs/2.18.0.dev7/lib/python3.9/site-packages/pants/util/frozendict.py", line 77, in __getitem__
    return self._data[k]
KeyError: <class 'plugins.myplugin.targets.MyPluginFieldSet'>
Does the field set need to be part of a union to use this? My field set is not.
c
yea, I think that’s the common way to use field sets.. I’m surprised it’s not mentioned on the FieldSet base class, so maybe it depends on how it’s used. Normally you get the fieldset via some union base type, but if you have your field set already I guess that’s not required, so then it’s the stuff you do with it that may have assumptions about the field set being registered as a union..
r
I added it to an arbitrary union but am still getting the error. What's the advantage of using
TargetRootsToFieldSets
as opposed to just filtering from
Targets
? I'm assuming it handles parametrization?
Oh I see the issue, it's expecting you to be looking for target roots of the union class itself
I'm guessing I'm using this wrong and what it's actually for is finding targets matching field sets that are unions with some arbitrary base class?
👍 1
like
PackageFieldSet
and
PublishFieldSet