Run the worker subprocess; return (npz_dict | None, error_str | None).
(task, seed, steps, full=False, actions_b64="-")
| 142 | |
| 143 | |
| 144 | def _run_worker(task, seed, steps, full=False, actions_b64="-"): |
| 145 | """Run the worker subprocess; return (npz_dict | None, error_str | None).""" |
| 146 | proc = subprocess.run( |
| 147 | [sys.executable, "-c", _WORKER, task, str(seed), str(steps), "1" if full else "0", actions_b64], |
| 148 | check=False, |
| 149 | capture_output=True, |
| 150 | text=True, |
| 151 | ) |
| 152 | for line in proc.stdout.splitlines(): |
| 153 | if line.startswith("NPZ_B64:"): |
| 154 | data = np.load(io.BytesIO(base64.b64decode(line[len("NPZ_B64:") :])), allow_pickle=False) |
| 155 | return {k: data[k] for k in data.files}, None |
| 156 | if line.startswith("ERR_B64:"): |
| 157 | return None, base64.b64decode(line[len("ERR_B64:") :]).decode() |
| 158 | return None, (proc.stderr[-2000:] or "no NPZ emitted") |
| 159 | |
| 160 | |
| 161 | _SIG_KEYS = ["img_sum", "img_sq", "reward", "terminated", "truncated", "success", "instruction"] |
no test coverage detected