From cdcb8dacbd939fd429ae7708ab3e1f9b38585bc9 Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Mon, 30 Nov 2026 07:41:25 -0800 Subject: [PATCH] The farm's GPU wait gives up on a run that ran out of its own time, as .remote() did Modal's FunctionTimeoutError is a subclass of its TimeoutError, so waited() caught a run's own timeout as "no answer yet" and asked again forever, logging "waiting" instead of failing the job. It now goes up as before. Test: a run that timed out fails the job with no wait lines. --- sdk/cloud/deploy/modal/farm_plan.py | 6 +++++- sdk/cloud/test/farm_plan.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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)