Skip to content

Commit

Permalink
Revert non-server directory changes
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Feb 18, 2025
1 parent 04873cf commit 260a0ab
Show file tree
Hide file tree
Showing 34 changed files with 13,003 additions and 2,242 deletions.
3,420 changes: 1,793 additions & 1,627 deletions poetry.lock

Large diffs are not rendered by default.

692 changes: 692 additions & 0 deletions tests/runtime/test_aci_edit.py

Large diffs are not rendered by default.

64 changes: 0 additions & 64 deletions tests/runtime/test_ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
from openhands.core.logger import openhands_logger as logger
from openhands.events.action import (
CmdRunAction,
FileEditAction,
FileReadAction,
FileWriteAction,
IPythonRunCellAction,
)
from openhands.events.event import FileEditSource
from openhands.events.observation import (
CmdOutputObservation,
ErrorObservation,
Expand Down Expand Up @@ -310,65 +308,3 @@ def test_ipython_file_editor_permissions_as_openhands(temp_dir, runtime_cls):
assert obs.exit_code == 0

_close_test_runtime(runtime)


def test_file_read_and_edit_via_oh_aci(runtime_cls, run_as_openhands):
runtime, config = _load_runtime(None, runtime_cls, run_as_openhands)
sandbox_dir = '/workspace'

actions = [
{
'command': 'create',
'test_code': f"print(file_editor(command='create', path='{sandbox_dir}/test.txt', file_text='Line 1\\nLine 2\\nLine 3'))",
'action_cls': FileEditAction,
'assertions': ['File created successfully'],
},
{
'command': 'view',
'test_code': f"print(file_editor(command='view', path='{sandbox_dir}/test.txt'))",
'action_cls': FileReadAction,
'assertions': ['Line 1', 'Line 2', 'Line 3'],
},
{
'command': 'str_replace',
'test_code': f"print(file_editor(command='str_replace', path='{sandbox_dir}/test.txt', old_str='Line 2', new_str='New Line 2'))",
'action_cls': FileEditAction,
'assertions': ['New Line 2'],
},
{
'command': 'undo_edit',
'test_code': f"print(file_editor(command='undo_edit', path='{sandbox_dir}/test.txt'))",
'action_cls': FileEditAction,
'assertions': ['Last edit to', 'undone successfully'],
},
{
'command': 'insert',
'test_code': f"print(file_editor(command='insert', path='{sandbox_dir}/test.txt', insert_line=2, new_str='Line 4'))",
'action_cls': FileEditAction,
'assertions': ['Line 4'],
},
]

for action_info in actions:
action_cls = action_info['action_cls']

kwargs = {
'path': f'{sandbox_dir}/test.txt',
'translated_ipython_code': action_info['test_code'],
'impl_source': FileEditSource.OH_ACI,
}
if action_info['action_cls'] == FileEditAction:
kwargs['content'] = '' # dummy value required for FileEditAction

action = action_cls(**kwargs)

logger.info(action, extra={'msg_type': 'ACTION'})
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
for assertion in action_info['assertions']:
if action_cls == FileReadAction:
assert assertion in obs.content
else:
assert assertion in str(obs)

_close_test_runtime(runtime)
Loading

0 comments on commit 260a0ab

Please sign in to comment.