Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions rock/sdk/sandbox/agent/iflow_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ async def _install_npm(self):
error_msg="npm installation failed",
)

await self._sandbox.arun(
cmd=(
"mv runtime-env /opt/nodejs && "
"ln -sf /opt/nodejs/bin/npm /usr/local/bin/npm && "
"ln -sf /opt/nodejs/bin/npx /usr/local/bin/npx && "
"ln -sf /opt/nodejs/bin/corepack /usr/local/bin/corepack && "
"ln -sf /opt/nodejs/bin/node /usr/local/bin/node"
),
session=self.agent_session,
)

elapsed_step = time.time() - step_start
self._log_step("NPM installation finished", step_name="NPM Install", is_complete=True, elapsed=elapsed_step)

Expand Down Expand Up @@ -202,6 +213,11 @@ async def _install_iflow_cli_package(self):
error_msg="iflow-cli installation failed",
)

await self._sandbox.arun(
cmd="ln -s /opt/nodejs/bin/iflow /usr/local/bin/iflow",
session=self.agent_session,
)

elapsed_step = time.time() - step_start
self._log_step(
"IFlow CLI installation finished", step_name="IFlow Install", is_complete=True, elapsed=elapsed_step
Expand Down
12 changes: 6 additions & 6 deletions rock/sdk/sandbox/agent/openhands.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ class OpenhandsConfig(DefaultAgentConfig):

# Command to clone Openhands/benchmarks repository and install dependencies
openhands_sdk_install_cmd_list: list[str] = [
f"/openhands/python/bin/pip config set global.index-url {env_vars.ROCK_PIP_INDEX_URL}",
"/openhands/python/bin/pip install openhands-agent-server==1.6.0 openhands-sdk==1.6.0",
"/openhands/python/bin/pip install openhands-tools==1.6.0 openhands-workspace==1.6.0",
f"/openhands/runtime-env/bin/pip config set global.index-url {env_vars.ROCK_PIP_INDEX_URL}",
"/openhands/runtime-env/bin/pip install openhands-agent-server==1.6.0 openhands-sdk==1.6.0",
"/openhands/runtime-env/bin/pip install openhands-tools==1.6.0 openhands-workspace==1.6.0",
"rm -rf /openhands/benchmarks",
"git clone -b features/local_workspace_fix_early_stop https://github.com/shayue-wt/benchmarks.git /openhands/benchmarks",
"/openhands/python/bin/pip install datasets huggingface-hub jinja2 pandas Pillow toml swebench",
"/openhands/python/bin/pip install tqdm 'unidiff>=0.7.5,<0.8.0' 'modal>=1.1.4' commit0 pytest-json-report",
"/openhands/runtime-env/bin/pip install datasets huggingface-hub jinja2 pandas Pillow toml swebench",
"/openhands/runtime-env/bin/pip install tqdm 'unidiff>=0.7.5,<0.8.0' 'modal>=1.1.4' commit0 pytest-json-report",
]

python_install_timeout: int = 300
Expand Down Expand Up @@ -417,7 +417,7 @@ async def run(
agent_run_cmd = (
f"cd {self.config.agent_workdir}/benchmarks && "
"export PYTHONPATH='.' && "
f"{self.config.agent_workdir}/python/bin/python "
f"{self.config.agent_workdir}/runtime-env/bin/python "
"./benchmarks/swebench/run_infer.py "
".llm_config.json --dataset eval --split test --note rock_rollout "
f"--select ./{instance_config} --max-iterations {self.config.max_iteration}"
Expand Down
6 changes: 3 additions & 3 deletions rock/sdk/sandbox/agent/swe_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SweAgentConfig(DefaultAgentConfig):

swe_agent_workdir: str = "/tmp_sweagent"

python_install_cmd: str = env_vars.ROCK_RTENV_PYTHON_V31114_INSTALL_CMD
python_install_cmd: str = env_vars.ROCK_RTENV_PYTHON_V31212_INSTALL_CMD

swe_agent_install_cmd: str = (
"[ -d SWE-agent ] && rm -rf SWE-agent; "
Expand Down Expand Up @@ -273,7 +273,7 @@ async def _install_swe_agent_package(self):
self._log_step("Installing SWE-agent repository", step_name="SWE-agent Install")

swe_agent_install_cmd = (
f"export PATH={self.config.swe_agent_workdir}/python/bin:$PATH && "
f"export PATH={self.config.swe_agent_workdir}/runtime-env/bin:$PATH && "
f"cd {self.config.swe_agent_workdir} && "
f"{self.config.swe_agent_install_cmd}"
)
Expand Down Expand Up @@ -428,7 +428,7 @@ async def run(

swe_agent_run_cmd = (
f"cd {self.config.swe_agent_workdir} && "
f"{self.config.swe_agent_workdir}/python/bin/sweagent run --config {config_filename}"
f"{self.config.swe_agent_workdir}/runtime-env/bin/sweagent run --config {config_filename}"
)
full_cmd = f"bash -c {shlex.quote(swe_agent_run_cmd)}"
logger.debug(
Expand Down
12 changes: 6 additions & 6 deletions rock/sdk/sandbox/model_service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def install(self) -> None:
# Step 4: Install model service
step_start_time = time.time()
model_service_install_cmd = (
f"export PATH={self.config.workdir}/python/bin:$PATH && "
f"export PATH={self.config.workdir}/runtime-env/bin:$PATH && "
f"cd {self.config.workdir} && {self.config.model_service_install_cmd}"
)
bash_service_cmd = f"bash -c {shlex.quote(model_service_install_cmd)}"
Expand Down Expand Up @@ -219,8 +219,8 @@ async def start(self) -> None:
start_cmd = (
f"export ROCK_LOGGING_PATH={self.config.logging_path} && "
f"export ROCK_LOGGING_FILE_NAME={self.config.logging_file_name} && "
f"{self.config.workdir}/python/bin/{self.config.stop_cmd} && "
f"{self.config.workdir}/python/bin/{self.config.start_cmd.format(model_service_type=self.config.model_service_type)}"
f"{self.config.workdir}/runtime-env/bin/{self.config.stop_cmd} && "
f"{self.config.workdir}/runtime-env/bin/{self.config.start_cmd.format(model_service_type=self.config.model_service_type)}"
)
bash_start_cmd = f"bash -c {shlex.quote(start_cmd)}"
logger.debug(f"[{sandbox_id}] Model service Start command: {bash_start_cmd}")
Expand Down Expand Up @@ -262,7 +262,7 @@ async def stop(self) -> None:
try:
logger.info(f"[{sandbox_id}] Stopping model service")

stop_cmd = f"{self.config.workdir}/python/bin/{self.config.stop_cmd}"
stop_cmd = f"{self.config.workdir}/runtime-env/bin/{self.config.stop_cmd}"
bash_stop_cmd = f"bash -c {shlex.quote(stop_cmd)}"

await self._sandbox.arun(
Expand Down Expand Up @@ -301,7 +301,7 @@ async def watch_agent(self, pid: str) -> None:
raise RuntimeError(error_msg)

try:
watch_agent_cmd = f"{self.config.workdir}/python/bin/{self.config.watch_agent_cmd.format(pid=pid)}"
watch_agent_cmd = f"{self.config.workdir}/runtime-env/bin/{self.config.watch_agent_cmd.format(pid=pid)}"
bash_watch_cmd = f"bash -c {shlex.quote(watch_agent_cmd)}"
logger.debug(f"[{sandbox_id}] Model service watch agent with pid={pid}, cmd: {bash_watch_cmd}")

Expand Down Expand Up @@ -369,7 +369,7 @@ async def anti_call_llm(
else:
cmd = self.config.anti_call_llm_cmd_no_response.format(index=index)

full_cmd = f"{self.config.workdir}/python/bin/{cmd}"
full_cmd = f"{self.config.workdir}/runtime-env/bin/{cmd}"
bash_cmd = f"bash -c {shlex.quote(full_cmd)}"
logger.debug(f"[{sandbox_id}] Executing command: {bash_cmd}")

Expand Down
10 changes: 4 additions & 6 deletions tests/integration/sdk/sandbox/agent/swe_agent/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async def _verify_exists(sandbox: Sandbox, directory_path: str, items: set[str])
logger.info(f"Directory {directory_path} contents: {result.stdout}")


@pytest.mark.skip
@pytest.mark.need_admin
@SKIP_IF_NO_DOCKER
@pytest.mark.asyncio
Expand All @@ -52,14 +51,13 @@ async def test_swe_agent_initialization(sandbox_instance: Sandbox):
await _verify_exists(sandbox_instance, "/", {agent_dir_name})

# 4. Verify agent installation directories
await _verify_exists(sandbox_instance, swe_agent_config.swe_agent_workdir, {"python", "SWE-agent"})
await _verify_exists(sandbox_instance, swe_agent_config.swe_agent_workdir, {"runtime-env", "SWE-agent"})

# 5. Verify Python executables
python_bin_path = f"{swe_agent_config.swe_agent_workdir}/python/bin"
python_bin_path = f"{swe_agent_config.swe_agent_workdir}/runtime-env/bin"
await _verify_exists(sandbox_instance, python_bin_path, {"sweagent"})


@pytest.mark.skip
@pytest.mark.need_admin
@SKIP_IF_NO_DOCKER
@pytest.mark.asyncio
Expand Down Expand Up @@ -87,8 +85,8 @@ async def test_swe_agent_with_model_service(sandbox_instance: Sandbox):
await _verify_exists(sandbox_instance, "/", {agent_dir_name, model_service_dir_name})

# 4. Verify agent installation directories
await _verify_exists(sandbox_instance, swe_agent_config.swe_agent_workdir, {"python", "SWE-agent"})
await _verify_exists(sandbox_instance, swe_agent_config.swe_agent_workdir, {"runtime-env", "SWE-agent"})

# 5. Verify Python executables
python_bin_path = f"{swe_agent_config.swe_agent_workdir}/python/bin"
python_bin_path = f"{swe_agent_config.swe_agent_workdir}/runtime-env/bin"
await _verify_exists(sandbox_instance, python_bin_path, {"sweagent"})
1 change: 0 additions & 1 deletion tests/integration/sdk/sandbox/agent/swe_agent/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async def _init_git_repository(sandbox: Sandbox, repo_path: str) -> None:
raise RuntimeError(f"Failed to execute: {cmd}")


@pytest.mark.skip
@pytest.mark.need_admin
@SKIP_IF_NO_DOCKER
@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
logger = init_logger(__name__)


@pytest.mark.skip
@pytest.mark.need_admin
@SKIP_IF_NO_DOCKER
@pytest.mark.asyncio
Expand All @@ -36,10 +35,10 @@ async def test_model_service_install_and_start(sandbox_instance: Sandbox):
logger.info(f"Work directory contents: {result.stdout}")
assert result.exit_code == 0
assert "cpython31114.tar.gz" in result.stdout, "Tar archive file missing"
assert "python" in result.stdout, "Python directory missing"
assert "runtime-env" in result.stdout, "Python directory missing"

# 5. Verify Python executables
python_bin_path = f"{model_service_config.workdir}/python/bin"
python_bin_path = f"{model_service_config.workdir}/runtime-env/bin"
result = await sandbox_instance.execute(Command(command="ls", cwd=python_bin_path))
logger.info(f"Python bin directory contents: {result.stdout}")
assert result.exit_code == 0
Expand Down
Loading