Sundara Moorthy
07/31/2023, 10:01 PMowen
07/31/2023, 11:52 PMSundara Moorthy
08/01/2023, 1:14 PMfrom dagster import graph, op
from dagster import (
In, Out,
repository,
Output,
ResourceDefinition,
DependencyDefinition,
OpDefinition,
GraphDefinition,
in_process_executor,
multiprocess_executor,
graph, reconstructable,DagsterInstance,execute_job,
RetryPolicy,Backoff,Jitter,
RetryRequested,
DagsterExecutionInterruptedError,
Failure
)
def x_solid(context,inputs):
try:
<http://context.log.info|context.log.info>("Starting the op's")
try:
<http://context.log.info|context.log.info>("Start the process")
count=1
while True:
<http://context.log.info|context.log.info>("Pls raise the interrupt :{}".format(count))
count+=1
yield Output(key="str_output",value="SUCCESS")
except DagsterExecutionInterruptedError:
<http://context.log.info|context.log.info>("Propagating dagster error to the root level >>")
raise DagsterExecutionInterruptedError
except Exception as e:
<http://context.log.info|context.log.info>("Exception in the retry :"+str(e))
yield Output(key="str_output",value="FAILED")
except DagsterExecutionInterruptedError:
<http://context.log.info|context.log.info>(">>>>>>>>>>>> RETRY >>>>>>>>>>>>>")
raise DagsterExecutionInterruptedError
except Exception as e:
<http://context.log.info|context.log.info>("Completed>>>")
yield Output(key="str_output",value="FAILED")
def get_op():
return [OpDefinition(
name="key",
compute_fn=x_solid,
outs={"str_output":Out()},
retry_policy=RetryPolicy(
max_retries=1,
delay=0.2, # 200ms
backoff=Backoff.EXPONENTIAL,
jitter=Jitter.PLUS_MINUS,
),
tags={
"max_retries": 3,
"retry_strategy": "ALL_STEPS"}
)]
def get_job():
graph_def = GraphDefinition(
name="job",
node_defs=get_op()
)
return graph_def.to_job(
executor_def=multiprocess_executor #multiprocess_executor,
)
@repository
def example_repo():
return [
get_job()]
# dagster version = 1.1.14
# dagster dev -f test.py
Sundara Moorthy
08/03/2023, 11:53 AMowen
08/03/2023, 8:14 PMSundara Moorthy
08/03/2023, 9:16 PMowen
08/03/2023, 9:41 PMSundara Moorthy
08/03/2023, 11:42 PMSundara Moorthy
08/05/2023, 2:18 PMowen
08/07/2023, 11:46 PM