runpod: fix a NameError in the provision path, and test for the whole class

The 150 GB warning's call site in _provision_one used a name that did not exist
in that scope. The helper was unit-tested and passed; every pod test then failed
in two seconds with "name 'entry' is not defined" before renting anything. A
helper can be correct while the line that calls it is not.

The entry is looked up the way the rest of the pool does it. And since pyflakes
sees exactly this class of bug, a test now runs it over the modules a pod boot
goes through, so an undefined name in that path fails the suite instead of the
first real request.
Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182DhR1eFNPQyGmDrpHbedY
parent 9539b3ef
...@@ -1533,7 +1533,8 @@ class RunpodPodPool: ...@@ -1533,7 +1533,8 @@ class RunpodPodPool:
# …and from every SIBLING engine's reaper, which cannot see the set # …and from every SIBLING engine's reaper, which cannot see the set
# above: each engine has its own pools and its own reaper. # above: each engine has its own pools and its own reaper.
register_pod(pod_id, str(self.model_key), api_key=self.api_key) # url once ready register_pod(pod_id, str(self.model_key), api_key=self.api_key) # url once ready
_warn = weight_transfer_warning(entry, self.mcfg, self.account) _warn = weight_transfer_warning(_model_entry(self.served or self.model_key),
self.mcfg, self.account)
if _warn: if _warn:
print("[runpod] " + "!" * 68, flush=True) print("[runpod] " + "!" * 68, flush=True)
for _line in _warn.split(". "): for _line in _warn.split(". "):
......
...@@ -700,3 +700,21 @@ def test_a_150gb_model_warns_before_anyone_rents_a_card(): ...@@ -700,3 +700,21 @@ def test_a_150gb_model_warns_before_anyone_rents_a_card():
# And an ordinary capability model says nothing at all. # And an ordinary capability model says nothing at all.
assert weight_transfer_warning( assert weight_transfer_warning(
{"path": "bge-m3"}, parse_model_runpod({"engine": "coderai"})) == "" {"path": "bge-m3"}, parse_model_runpod({"engine": "coderai"})) == ""
def test_the_provision_path_itself_is_free_of_undefined_names():
"""The 150 GB warning was unit-tested and passed — and then every pod test
failed in two seconds with NameError: name 'entry' is not defined, because
the call site in _provision_one used a name that did not exist there. A
helper can be correct while the line that calls it is not. pyflakes sees
exactly this class of bug, so run it on the modules a pod boot goes through."""
import subprocess, sys
from pathlib import Path
root = Path(__file__).resolve().parents[1]
mods = ["codai/api/runpod_worker.py", "codai/api/remote_gateway.py",
"codai/api/model_test.py", "codai/api/runpod_client.py"]
out = subprocess.run([sys.executable, "-m", "pyflakes", *mods],
cwd=root, capture_output=True, text=True).stdout
undefined = [l for l in out.splitlines() if "undefined name" in l]
assert not undefined, "\n".join(undefined)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment