p6_cli_probe: locate lm_eval via a child process -- a user-site dir created mid-run is not on the parent's sys.path
Browse files- kernels/p6_cli_probe.py +10 -1
kernels/p6_cli_probe.py
CHANGED
|
@@ -68,7 +68,16 @@ print("FLAGS_MISSING", missing, flush=True)
|
|
| 68 |
|
| 69 |
import yaml # shipped with the image and a dependency of lm_eval
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
def load_yaml(path):
|
|
|
|
| 68 |
|
| 69 |
import yaml # shipped with the image and a dependency of lm_eval
|
| 70 |
|
| 71 |
+
# The user-site directory pip created a minute ago is not on *this* process's sys.path: `site` adds it only
|
| 72 |
+
# if it exists at interpreter start, which it did not in a fresh container (the same reason the earlier probe
|
| 73 |
+
# only ever touched lm_eval through subprocesses). Ask a child where the package lives and read files from
|
| 74 |
+
# the parent -- reading a YAML needs no import.
|
| 75 |
+
rc, out = sh([sys.executable, "-c", "import lm_eval, os; print(os.path.dirname(lm_eval.__file__))"], 300)
|
| 76 |
+
loc = next((l.strip() for l in (out or "").splitlines() if l.strip().endswith("lm_eval")), "")
|
| 77 |
+
if not loc:
|
| 78 |
+
print("LM_EVAL_PATH_FAILED", repr((out or "")[-400:]), flush=True)
|
| 79 |
+
raise SystemExit(8)
|
| 80 |
+
tasks_dir = os.path.join(loc, "tasks")
|
| 81 |
|
| 82 |
|
| 83 |
def load_yaml(path):
|