quick-lighter-52296
01/20/2023, 6:13 AM--with retry so that they are retried only in case of platform/infra errors and not user-level errors? IIRC metaflow retries both in case of user raised exceptions and platform errors, this is good for production but for our staging/test environments we want the flows to fail fast and fail early. If we remove all retries then the issue is that the flow sometimes fail due to infra issues / provisioning timeouts from ECS, etc. that we still want to avoidvictorious-lawyer-58417
01/20/2023, 6:41 AMtry .. except block that captures and handles all user-level errors specially. All remaining errors, i.e. platform errors, can be handled as usual.
This custom @platform_retry decorator should do the trick:
import sys
import time
import traceback
from functools import wraps
from metaflow import FlowSpec, step, retry
from metaflow.exception import METAFLOW_EXIT_DISALLOW_RETRY
def platform_retry(f):
@wraps(f)
def wrapper(self):
try:
f(self)
except:
traceback.print_exc()
sys.exit(METAFLOW_EXIT_DISALLOW_RETRY)
return retry(wrapper)
class PlatformRetryFlow(FlowSpec):
@platform_retry
@step
def start(self):
time.sleep(10)
print('fail', 1 / 0)
self.next(self.end)
@platform_retry
@step
def end(self):
print("done!")
if __name__ == '__main__':
PlatformRetryFlow()victorious-lawyer-58417
01/20/2023, 6:47 AMquick-lighter-52296
01/20/2023, 9:20 AMMETAFLOW_EXIT_DISALLOW_RETRY exit code. Neat trick, yep that works, thanks!victorious-lawyer-58417
01/20/2023, 3:29 PMelegant-carpenter-7681
06/01/2023, 2:17 PMplatform_retry on a scheduled Flow on Argo?straight-shampoo-11124
06/08/2023, 3:13 PMcalm-energy-78015
06/08/2023, 3:14 PMvictorious-lawyer-58417
06/08/2023, 3:35 PMvictorious-lawyer-58417
06/08/2023, 3:36 PM