Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions env_service/environments/appworld/setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and to avoid the $'...' bashism, you could use a single-line Python command with a semicolon for this short script. This makes the command more straightforward.

Suggested change
conda run -n appworld python -c $'from appworld.install import install_package\ninstall_package()\n'
conda run -n appworld python -c 'from appworld.install import install_package; install_package()'


# 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This inline Python script is quite long, which harms readability and makes it hard to maintain. For multi-line scripts inside a shell script, using a here-doc is a much more readable and standard practice.

I recommend refactoring this if statement to use one. You would replace the current line 44 with the following block:

if ! conda run -n appworld python <<'EOF'
import os
from appworld import update_root
from appworld.download import download_data
root = os.environ.get("APPWORLD_ROOT") or "."
update_root(root)
download_data()
EOF
then

This makes the Python code much easier to read and edit.

echo "⚠️ 自动下载失败,尝试从备用地址获取数据..."
wget -O "$APPWORLD_ROOT/appworld_data.zip" "https://dail-wlcb.oss-accelerate.aliyuncs.com/eric.czq/appworld_data.zip"
mkdir -p /tmp/unziptemp
Expand Down