Stefan Adelbert
03/19/2023, 10:27 PMimport dagster
@dagster.op
def child_op(context):
context.log.debug("child op")
@dagster.op
def parent_op(context):
context.log.debug("parent op")
child_op() # Compute function of op 'child_op' has context argument, but no context was provided when invoking.
#child_op(context) # Compute function of op 'child_op' has context argument, but no context was provided when invoking.
@dagster.graph
def graph():
parent_op()
job = graph.to_job()
job.execute_in_process()
But I'm getting an error,
dagster._core.errors.DagsterInvalidInvocationError: Compute function of op 'child_op' has context argument, but no context was provided when invoking.
File ~/.cache/pypoetry/virtualenvs/westhaven-notebooks-b3nFTxXM-py3.10/lib/python3.10/site-packages/dagster/_core/definitions/op_definition.py:410, in OpDefinition.__call__(self, *args, **kwargs)
408 if len(args) > 0:
409 if args[0] is not None and not isinstance(args[0], UnboundOpExecutionContext):
--> 410 raise DagsterInvalidInvocationError(
411 f"Compute function of {node_label} '{self.name}' has context argument, "
412 "but no context was provided when invoking."
413 )
414 context = args[0]
415 return op_invocation_result(self, context, *args[1:], **kwargs)
A solution could be for child_op
to be a plain function, but in reality child_op
needs a context to be able to log and access resources.
Any thoughts?Oliver Sellwood
03/19/2023, 10:59 PMStefan Adelbert
03/19/2023, 11:19 PMStefan Adelbert
03/19/2023, 11:20 PMStefan Adelbert
03/19/2023, 11:32 PMOliver Sellwood
03/20/2023, 4:22 AMStefan Adelbert
03/20/2023, 4:58 AM