i've defined a rule with `@rule(CppObjects, [Selec...
# development
a
i've defined a rule with
@rule(CppObjects, [Select(Compiler), Select(CppObjectsRequest)])
and the function is one of the rules exposed to the scheduler i'm creating with mk_scheduler(), where
Compiler
is a singleton rule. i'm running
self.execute(self.scheduler, CppObjects, CppObjectsRequest(...))
, where self.scheduler is the result of mk_scheduler(), and self.execute() just executes the product request using *args to make the subject array. i would expect this to work since i am requesting exactly the product/subject pair that my rule defines, but this fails with:
Copy code
self = <pants_test.backend.native.subsystems.test_native_toolchain.TestNativeToolchain testMethod=test_hello_cpp>
                     scheduler = <pants.engine.scheduler.LocalScheduler object at 0x10828ef10>
                     product = <class 'pants.backend.native.rules.cpp_rules.CppObjects'>
                     subjects = (CppObjectsRequest(sources=CppSources(root_dir=u'/private/var/folders/j2/x6ckkb.../private/var/folders/j2/x6ckkbrn08g8536d6_n3_ywm0000gn/T/tmpHI3ltD_BUILD_ROOT'),)
                     request = ExecutionRequest(roots=((CppObjectsRequest(sources=CppSources(root_dir=u'/priv...native.rules.cpp_rules.CppObjects'>),), native=<cdata 'void *' 0x7fb2c8dd03d0>)
                     result = ExecutionResult(error=None, root_products=[((CppObjectsRequest(sources=CppSour...ts'>), Throw(exc=Exception(u'No task was available to compute the value.',)))])
                     _ = (CppObjectsRequest(sources=CppSources(root_dir=u'/private/var/folders/j2/x6ckkb.../private/var/folders/j2/x6ckkbrn08g8536d6_n3_ywm0000gn/T/tmpHI3ltD_BUILD_ROOT'), <class 'pants.backend.native.rules.cpp_rules.CppObjects'>)
                     
                         def execute(self, scheduler, product, *subjects):
                           """Runs an ExecutionRequest for the given product and subjects, and returns the result value."""
                           request = scheduler.execution_request([product], subjects)
                           result = scheduler.execute(request)
                           if result.error:
                             raise result.error
                           states = [state for _, state in result.root_products]
                           if any(type(state) is not Return for state in states):
                             with temporary_file_path(cleanup=False, suffix='.dot') as dot_file:
                               scheduler.visualize_graph_to_file(request, dot_file)
                     >         raise ValueError('At least one request failed: {}. Visualized as {}'.format(states, dot_file))
                     E         ValueError: At least one request failed: [Throw(exc=Exception(u'No task was available to compute the value.',))]. Visualized as /var/folders/j2/x6ckkbrn08g8536d6_n3_ywm0000gn/T/tmpWNplu6.dot
i get the same result if i just use
self.scheduler.product_request()
.