many-processor-72561
12/02/2024, 7:40 AMretry
decorator? I want to run some code, allow it to retry and only if it fails on all retries I want to send a wehook to github.
I know that I can use catch
and check in the next step if an exception was raised, but that makes the process more complected + the failed step will be the second one instead of the first one.
Thankscrooked-jordan-29960
12/02/2024, 8:04 AMtask_finished
lifecycle hook.dry-beach-38304
12/02/2024, 8:25 AMmany-processor-72561
12/02/2024, 5:36 PMRetryDecorator
with my own code and there add my implementation of task_finished
that will send the Github hook?
@dry-beach-38304 If I mix retry
and catch
decorators I will get an "extra try" from catch
and their I can check the counter and send message. something like:
@retry(times=MAX_RETRIES, minutes_between_retries=0)
@catch(var="demo_ex")
@step
def a(self):
print('the data artifact is: %s' % self.my_var)
if current.retry_count == MAX_RETRIES:
print(f'Failed all tries and will update github action')
raise Exception()
self.next(self.end)
on the other end, it will mark a
task with green making it hard to know from where the fail came on large flows.crooked-jordan-29960
12/02/2024, 10:41 PMdry-beach-38304
12/02/2024, 11:17 PMdry-beach-38304
12/02/2024, 11:23 PMdef send_on_last_error(f):
@wraps(f)
def wrapper(*args, **kwargs):
try:
f(*args, **kwargs)
except:
if current.retry_count == MAX_RETRIES:
print("Do whatever in github")
but it will probably not work just as is (some internal issues with identifying a step). Let me try something out a little later if I have some time.