Skip to content

Commit 903381f

Browse files
authored
Add back jupyter PWD env var for agentskills (#2327)
* add back jupyter pwd env var for agentskills * add unit test for pwd change in execute_cli
1 parent c3c2b2d commit 903381f

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
22
# Run the Python script with the specified interpreter
3+
export JUPYTER_PWD=$(pwd)
34
$OPENDEVIN_PYTHON_INTERPRETER /opendevin/plugins/jupyter/execute_cli.py

tests/unit/test_sandbox.py

+49-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from opendevin.runtime.docker.exec_box import DockerExecBox
1010
from opendevin.runtime.docker.local_box import LocalBox
1111
from opendevin.runtime.docker.ssh_box import DockerSSHBox, split_bash_commands
12-
from opendevin.runtime.plugins import JupyterRequirement
12+
from opendevin.runtime.plugins import AgentSkillsRequirement, JupyterRequirement
1313

1414

1515
@pytest.fixture
@@ -293,3 +293,51 @@ def test_sandbox_jupyter_plugin(temp_dir):
293293
+ box.__class__.__name__
294294
)
295295
box.close()
296+
297+
298+
def test_sandbox_jupyter_agentskills_fileop_pwd(temp_dir):
299+
# get a temporary directory
300+
with patch.object(config, 'workspace_base', new=temp_dir), patch.object(
301+
config, 'workspace_mount_path', new=temp_dir
302+
), patch.object(config, 'run_as_devin', new='true'), patch.object(
303+
config, 'sandbox_type', new='ssh'
304+
):
305+
for box in [DockerSSHBox()]:
306+
box.init_plugins([AgentSkillsRequirement, JupyterRequirement])
307+
exit_code, output = box.execute('mkdir test')
308+
print(output)
309+
assert exit_code == 0, (
310+
'The exit code should be 0 for ' + box.__class__.__name__
311+
)
312+
313+
exit_code, output = box.execute(
314+
'echo "create_file(\'a.txt\')" | execute_cli'
315+
)
316+
print(output)
317+
assert exit_code == 0, (
318+
'The exit code should be 0 for ' + box.__class__.__name__
319+
)
320+
assert output.strip().split('\r\n') == (
321+
'[File: /workspace/a.txt (1 lines total)]\r\n'
322+
'1|\r\n'
323+
'[File a.txt created.]'
324+
).strip().split('\r\n')
325+
326+
exit_code, output = box.execute('cd test')
327+
print(output)
328+
assert exit_code == 0, (
329+
'The exit code should be 0 for ' + box.__class__.__name__
330+
)
331+
332+
exit_code, output = box.execute(
333+
'echo "create_file(\'a.txt\')" | execute_cli'
334+
)
335+
print(output)
336+
assert exit_code == 0, (
337+
'The exit code should be 0 for ' + box.__class__.__name__
338+
)
339+
assert output.strip().split('\r\n') == (
340+
'[File: /workspace/test/a.txt (1 lines total)]\r\n'
341+
'1|\r\n'
342+
'[File a.txt created.]'
343+
).strip().split('\r\n')

0 commit comments

Comments
 (0)