thankful-father-61351
09/12/2023, 11:21 AM--with kubernetes since this affects all steps.)mammoth-rainbow-82717
09/12/2023, 11:46 AMcalm-energy-78015
09/13/2023, 10:31 AMfor deco in decos:
if deco.name != "kubernetes":
continue
deco.attributes["gpu"] = self.attributes["gpu"]
deco.attributes["tolerations"] = self.attributes["tolerations"]
[...]
Has the advantage of retaining the default behaviour of attaching @kubernetes, though I can see that the solution by @mammoth-rainbow-82717 is more elegant.thankful-father-61351
09/14/2023, 5:08 AMthankful-father-61351
09/15/2023, 8:37 AM# previously in our code
@kubernetes(disk=5 * 1024, tmpfs="/something")
# now in our code
@kubernetes_with_toggle(disk=5 * 1024, tmpfs="/something")
Using this custom decorator will allow you to run eg.
python flow.py run --without kubernetes
To achieve this, kubernetes_with_toggle is defined like so:
class kubernetes_with_toggle:
arg_pairs = list(zip(sys.argv, sys.argv[1:]))
try:
idx = arg_pairs.index(("--without", "kubernetes"))
except ValueError:
run_with_k8s = True
else:
run_with_k8s = False
del sys.argv[idx] # "--without"
del sys.argv[idx] # "kubernetes"
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
def __call__(self, func):
if self.run_with_k8s:
return kubernetes(*self.args, **self.kwargs)(func)
return functhankful-father-61351
09/15/2023, 8:40 AM@adaptable_resources decorator which allows for arguments like tmpfs , and the having it morph into a kubernetes decorator at runtime if "argo-workflow" or "kubernetes" is found in sys.argv.