|
|
@@ -132,23 +132,23 @@ print(json.dumps({{'generated_text': gen}}))
|
|
|
|
|
|
script_b64 = base64.b64encode(script.encode()).decode()
|
|
|
|
|
|
- # 先将脚本写入容器内的临时文件,再执行,避免 echo | pipe 的缓冲区限制
|
|
|
+ # 通过 docker exec -i 将解码后的脚本内容传入容器内的 cat,写入临时文件后执行
|
|
|
script_path = f"/tmp/test_model_{model_id.replace('/', '_')}.py"
|
|
|
- write_cmd = (
|
|
|
- f"echo {script_b64} | base64 -d > {script_path} && "
|
|
|
- f"docker exec -w {workdir} "
|
|
|
+ remote_cmd = (
|
|
|
+ f"echo '{script_b64}' | base64 -d | "
|
|
|
+ f"docker exec -i -w {workdir} "
|
|
|
f"-e MODEL_ID={model_id} "
|
|
|
f"-e PROMPT_B64={prompt_b64} "
|
|
|
f"-e MAX_TOKENS={max_new_tokens} "
|
|
|
f"-e TEMPERATURE={temperature} "
|
|
|
f"-e TOP_P={top_p} "
|
|
|
f"-e DO_SAMPLE={do_sample} "
|
|
|
- f"{container} {python} {script_path}"
|
|
|
+ f"{container} bash -c 'cat > {script_path} && {python} {script_path}'"
|
|
|
)
|
|
|
|
|
|
- code, stdout, stderr = ssh_exec(write_cmd, timeout=600)
|
|
|
+ code, stdout, stderr = ssh_exec(remote_cmd, timeout=600)
|
|
|
|
|
|
- # 清理临时文件
|
|
|
+ # 清理容器内临时文件
|
|
|
ssh_exec(f"docker exec {container} rm -f {script_path}", timeout=5)
|
|
|
|
|
|
logger.info(f"Remote test result: code={code}, stdout_len={len(stdout)}, stderr_len={len(stderr)}")
|