diff --git a/sdk/cloud/deploy/modal/farm_plan.py b/sdk/cloud/deploy/modal/farm_plan.py index a090386d..5f848bbc 100644 --- a/sdk/cloud/deploy/modal/farm_plan.py +++ b/sdk/cloud/deploy/modal/farm_plan.py @@ -64,7 +64,11 @@ def waited(fn, log, *a, **kw): while True: try: return call.get(timeout=WAIT_SAY_S) - except timeouts: + except timeouts as e: + # Modal's FunctionTimeoutError is a TimeoutError too: the run itself ran out of time, so it goes up as + # .remote() raised it, not waited on again (it would answer the same at once, forever) + if type(e).__name__ == "FunctionTimeoutError": + raise log(f"raea farm: waiting {time.time() - t:.0f} s for a GPU run to answer (queued while the workspace's GPUs are busy, or still drawing)") diff --git a/sdk/cloud/test/farm_plan.py b/sdk/cloud/test/farm_plan.py index aa21d86d..9f534eff 100644 --- a/sdk/cloud/test/farm_plan.py +++ b/sdk/cloud/test/farm_plan.py @@ -174,4 +174,19 @@ assert fp.waited(SlowGpu(), log, "j4", ["render"]) == {"code": 0, "out": "drawn" assert sum("waiting" in l and "GPU run" in l for l in lines) == 2, lines ok("a GPU run that hasn't answered is said in the log every WAIT_SAY_S until it does") +# a GPU run that ran out of its own time fails the job, as .remote() did, instead of being waited on forever +class FunctionTimeoutError(TimeoutError): pass +class TimedOutCall: + def get(self, timeout=None): raise FunctionTimeoutError("Function timeout") +class TimedOutGpu: + def spawn(self, *a, **kw): return TimedOutCall() +lines.clear() +try: + fp.waited(TimedOutGpu(), log, "j5", ["render"]) + raise AssertionError("waited() swallowed a function timeout") +except FunctionTimeoutError: + pass +assert not any("waiting" in l for l in lines), lines +ok("a GPU run that timed out fails the job instead of being waited on forever") + shutil.rmtree(root)