chore: 迁移服务器前同步本地修改
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
"""ray_submit:把分析脚本提交到 Ray(distributed)或 subprocess(standalone)执行。
|
||||
"""ray_submit:把分析脚本提交到子进程执行。
|
||||
|
||||
凭证以 ``AWS_*`` 环境变量注入子进程,让 boto3/pandas-s3 自然读到。
|
||||
脚本走 ``kilostar.utils.sandbox.validate_python_code`` 的静态屏蔽兜底。
|
||||
名字沿用历史(原设计走 Ray);当前后端为本地子进程,未来要接远程算力只需替换
|
||||
执行器,工具签名不变。凭证以 ``AWS_*`` 环境变量注入子进程,让 boto3/pandas-s3
|
||||
自然读到。脚本走 ``kilostar.utils.sandbox.validate_python_code`` 的静态屏蔽兜底。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -11,7 +12,6 @@ import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from kilostar.utils.ray_compat import _STANDALONE
|
||||
from kilostar.utils.sandbox import (
|
||||
CodeViolation,
|
||||
get_python_timeout,
|
||||
@@ -33,7 +33,7 @@ def _build_env(creds) -> dict:
|
||||
|
||||
|
||||
async def ray_submit(script: str, timeout: int = 300) -> str:
|
||||
"""提交 Python 脚本到 Ray(分布式)或子进程(单机)执行。
|
||||
"""提交 Python 脚本到子进程执行。
|
||||
|
||||
脚本中可直接 ``import boto3`` 读 S3(凭证已通过环境变量注入);可用
|
||||
pandas / polars / numpy 等已安装的依赖。**只读**——不要尝试 put/delete。
|
||||
@@ -83,8 +83,6 @@ async def ray_submit(script: str, timeout: int = 300) -> str:
|
||||
if proc.returncode != 0:
|
||||
result += f"\n[exit code: {proc.returncode}]"
|
||||
result = result.strip() or "(no output)"
|
||||
if not _STANDALONE:
|
||||
result = f"[mode: ray-cluster (subprocess)]\n{result}"
|
||||
return result
|
||||
except asyncio.TimeoutError:
|
||||
return f"[Error] ray_submit 执行超时({timeout}s)"
|
||||
|
||||
Reference in New Issue
Block a user