Deividas Jodogalvis
02/12/2024, 12:53 PMScout
02/12/2024, 12:53 PMOutput
object with the is_required
parameter set to False
. This allows you to yield an Output
conditionally, effectively skipping the op's main action without causing a failure. Here's an example from the documentation: python from dagster import op, Out, Output @op(out=Out(is_required=False)) def conditional_op(context): if should_skip(): <http://context.log.info|context.log.info>("Skipping op execution") return # Otherwise, perform the op's action yield Output(result)
In this example, should_skip()
is a placeholder for your custom logic that determines whether to skip the op's action. If the condition is met, the op logs a message and returns without yielding an Output
, effectively skipping its action. If you want to skip the execution of an entire job or a set of ops, you would typically use a sensor or schedule with a SkipReason
. Sensors and schedules can return a SkipReason
to indicate why no runs were requested. This is not the same as marking a run as skipped, but it is a way to programmatically prevent runs from being initiated. For more complex scenarios, such as handling run failures or cancellations, you might need to implement custom logic within your ops or use hooks and sensors to respond to run status changes. If you need to mark a run as skipped after it has started, which is not a typical use case in Dagster, you would likely need to handle this outside of the standard op execution flow, potentially by interacting with the Dagster instance's run storage to update the run's status, which is not a documented or recommended approach.