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
5 changes: 4 additions & 1 deletion examples/experimental/swe-agent-v2/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class ScriptArgs(U.ExecuteTrainConfig):
agent_model_name: str = os.environ.get("AGENT_MODEL_NAME", "model")
harbor_tasks_dir: str = os.environ.get("HARBOR_TASKS_DIR", "/root/harbor_tasks")
router_external_host: str = os.environ.get("MILES_ROUTER_EXTERNAL_HOST", socket.gethostname()) # public IP
miles_host_ip: str = os.environ.get("MILES_HOST_IP", socket.gethostname()) # cluster/pod IP
# Prefer explicit MILES_HOST_IP; else MASTER_ADDR when set (avoids unresolvable pod hostnames on workers).
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP") or os.environ.get("MASTER_ADDR", "").strip() or socket.gethostname()
)
Comment on lines +52 to +54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for determining miles_host_ip can be simplified and made more robust. Currently, it doesn't handle potential whitespace in the MILES_HOST_IP environment variable, and the nested or with strip() for MASTER_ADDR is slightly redundant. Using os.environ.get(key, "").strip() is a cleaner and more idiomatic way to handle missing or whitespace-only environment variables in Python.

Suggested change
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP")
or (os.environ.get("MASTER_ADDR") or "").strip()
or socket.gethostname()
)
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP", "").strip()
or os.environ.get("MASTER_ADDR", "").strip()
or socket.gethostname()
)


# W&B settings
wandb_key: str = os.environ.get("WANDB_KEY", os.environ.get("WANDB_API_KEY", ""))
Expand Down
Loading