diff --git a/env_service/environments/appworld/setup.sh b/env_service/environments/appworld/setup.sh old mode 100644 new mode 100755 index cbbe4d2..04d5d7c --- a/env_service/environments/appworld/setup.sh +++ b/env_service/environments/appworld/setup.sh @@ -37,11 +37,11 @@ conda run -n appworld pip install -r "$SCRIPT_DIR/requirements.txt" # 5. 初始化 appworld echo "📁 初始化 appworld..." -conda run -n appworld appworld install +conda run -n appworld python -c $'from appworld.install import install_package\ninstall_package()\n' # 6. 下载数据 echo "📦 下载数据(失败则使用备用下载)..." -if ! conda run -n appworld appworld download data; then +if ! conda run -n appworld python -c $'import os\nfrom appworld import update_root\nfrom appworld.download import download_data\nroot = os.environ.get("APPWORLD_ROOT") or "."\nupdate_root(root)\ndownload_data()\n'; then echo "⚠️ 自动下载失败,尝试从备用地址获取数据..." wget -O "$APPWORLD_ROOT/appworld_data.zip" "https://dail-wlcb.oss-accelerate.aliyuncs.com/eric.czq/appworld_data.zip" mkdir -p /tmp/unziptemp diff --git a/launcher.py b/launcher.py index 49ebda7..bb689a8 100644 --- a/launcher.py +++ b/launcher.py @@ -7,6 +7,7 @@ import os import signal import shlex +from pathlib import Path from dotenv import load_dotenv from agentevolver.utils.daemon import LaunchCommandWhenAbsent @@ -98,9 +99,32 @@ def parse_args(): return parser.parse_args() +def _require_service_env(service_name: str): + """Return (path, script) for the companion service, validating env vars.""" + env_prefix = service_name.upper() + service_path = os.environ.get(f'{env_prefix}_PATH') + service_script = os.environ.get(f'{env_prefix}_SCRIPT') + missing = [] + if not service_path: + missing.append(f'{env_prefix}_PATH') + if not service_script: + missing.append(f'{env_prefix}_SCRIPT') + if missing: + example_hint = "" + example_env = Path("example.env") + if example_env.exists(): + example_hint = ( + f" Copy the relevant entries from {example_env} into your .env file." + ) + raise RuntimeError( + f"Missing environment variable(s) required to launch '{service_name}': " + f"{', '.join(missing)}.{example_hint}" + ) + return service_path, service_script + + def pty_launch(service_name: str, success_std_string="Starting server on"): - service_path = os.environ.get(f'{service_name.upper()}_PATH') - service_script = os.environ.get(f'{service_name.upper()}_SCRIPT') + service_path, service_script = _require_service_env(service_name) companion = LaunchCommandWhenAbsent( full_argument_list=[service_script], dir=service_path, @@ -393,4 +417,4 @@ def main(): sys.exit(1) if __name__ == "__main__": - main() \ No newline at end of file + main()