brief-engineer-67497
04/01/2019, 4:14 PMpython
class MyTarget(JvmTarget):
def __init__(self,
payload=None,
spec=None,
**kwargs):
payload = payload or Payload()
payload.add_fields({
'spec': PrimitiveField(spec),
})
if spec:
self.inject_dependency(Address.parse(spec))
super(ControllersLibrary, self).__init__(payload=payload,
**kwargs)
but I get :
Failed to instantiate Target with type <class 'MyTarget'>: 'MyTarget' object has no attribute '_build_graph'
aloof-angle-91616
04/01/2019, 5:01 PMbrief-engineer-67497
04/01/2019, 5:18 PMException message: Invalid target BuildFileAddress(my_target/BUILD, the_target): Failed to instantiate Target with type <class 'MyTarget'>: Cannot inject dependency from BuildFileAddress(my_target/BUILD, the_target) on the-spec:the-spec because the dependent is not in the BuildGraph.
All usage I see from inject_dependency
is within a task rather than a target. Here should I just add the element to the dependencies
list before passing it to the super constructor ?aloof-angle-91616
04/01/2019, 5:20 PMspec
arg, is there a reason you can't just add that spec to the dependencies
when making the target in a BUILD file? what is the spec for?brief-engineer-67497
04/01/2019, 5:31 PMbrief-engineer-67497
04/01/2019, 5:33 PMbrief-engineer-67497
04/01/2019, 5:33 PMbrief-engineer-67497
04/01/2019, 5:38 PMbrief-engineer-67497
04/01/2019, 5:41 PMaloof-angle-91616
04/01/2019, 10:47 PMspec
argument to the dependencies). i think you won't need to necessarily change any payload fields here then, and you could just add an entry to dependencies
before calling the super constructor.brief-engineer-67497
04/02/2019, 7:46 AMds = kwargs.pop('dependencies', [])
ds.append(spec)
kwargs.update({'dependencies': ds})
but it bakfired heavily. Do you know how I can add an entry to dependencies
aloof-angle-91616
04/04/2019, 6:54 AMdependencies
arg is a list of a different type than the spec
parameter (pants might be doing some magic, not sure)brief-engineer-67497
04/04/2019, 7:57 AMException message: Invalid target mytarget: MyTarget received unknown arguments:
dependencies = ['the_spec']
In the Target class a comment on the constructor says
# NB: dependencies are in the pydoc above as a BUILD dictionary hack only; implementation hides
# the dependencies via TargetAddressable.
But I have some pain finding out how TargetAddressable comes in play during the target buildingbrief-engineer-67497
04/04/2019, 8:59 AMinject_dependency
is a better trail however as explained earlier, when using it in the target constructor, I run into a Invalid target … because the dependent is not in the BuildGraph.
.
Looking at the usage of inject_dependency
it seems used in the task rather than the targets, however using it in the execute
seems too late because my real dependency is not SpecTarget
but a SyntheticSpecTarget
created by another task previously run …brief-engineer-67497
04/04/2019, 4:21 PMenough-analyst-54434
04/04/2019, 4:22 PMbrief-engineer-67497
04/04/2019, 4:22 PMenough-analyst-54434
04/04/2019, 4:26 PMenough-analyst-54434
04/04/2019, 4:26 PMbrief-engineer-67497
04/04/2019, 4:27 PMbrief-engineer-67497
04/04/2019, 4:27 PMenough-analyst-54434
04/04/2019, 4:27 PMenough-analyst-54434
04/04/2019, 4:27 PMbrief-engineer-67497
04/04/2019, 4:28 PM