Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add stream output to exec_run #1625

Merged

Conversation

iFurySt
Copy link
Collaborator

@iFurySt iFurySt commented May 7, 2024

  • Using command timeout to control the exec_box's timeout.
Screen.Recording.2024-05-07.at.22.38.44.mov

i found the init is too long and haven't feedback, and IMO i think the init does not even need to control the timeout. i failed to init a few times yesterday because my network seems poor, it made me a bit confused ~

i added the stream output for feedback and kept the timeout but changed to use the timeout command.

@codecov-commenter
Copy link

codecov-commenter commented May 7, 2024

Codecov Report

Attention: Patch coverage is 78.37838% with 32 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@eba5ef8). Click here to learn what that means.

Files Patch % Lines
opendevin/runtime/docker/exec_box.py 67.56% 12 Missing ⚠️
opendevin/runtime/docker/ssh_box.py 84.12% 10 Missing ⚠️
opendevin/runtime/plugins/mixin.py 75.00% 4 Missing ⚠️
opendevin/core/schema/stream.py 84.21% 3 Missing ⚠️
opendevin/runtime/e2b/sandbox.py 66.66% 1 Missing ⚠️
opendevin/server/agent/agent.py 0.00% 1 Missing ⚠️
opendevin/server/session/manager.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1625   +/-   ##
=======================================
  Coverage        ?   64.73%           
=======================================
  Files           ?      100           
  Lines           ?     4143           
  Branches        ?        0           
=======================================
  Hits            ?     2682           
  Misses          ?     1461           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rbren
Copy link
Collaborator

rbren commented May 9, 2024

This is very cool!

I'm a little worried about changing the footprint of execute, which hypothetically should be the same for every box. But I don't think it affects much here.

Do you think it'd be possible to add this to SSH box too?

And do you think it'd be possible to use this to stream output to the FE?

@iFurySt
Copy link
Collaborator Author

iFurySt commented May 10, 2024

I'm a little worried about changing the footprint of execute, which hypothetically should be the same for every box.

i think every box should have a stream output as much as possible, they can easily implement the CancellableStream. (but i'm not so sure that will be the case for all in the future🤯)

Do you think it'd be possible to add this to the SSH box too?

yes, i wanna apply the stream to the SSH box. but i was too busy the last few days, i think i can work at it by the end of the week.

And do you think it'd be possible to use this to stream output to the FE?

i think so, but it may have a bit of trouble when the concurrent sends messages from the BE to FE.

@iFurySt iFurySt marked this pull request as draft May 10, 2024 15:51
* Using command timeout to control the exec_box's timeout.
* add bash -c to source command to compatible for sh.

Signed-off-by: ifuryst <ifuryst@gmail.com>
@iFurySt iFurySt force-pushed the feat-add-stream-output-for-exec_run branch from 73430bd to d680218 Compare May 11, 2024 07:58
@iFurySt iFurySt force-pushed the feat-add-stream-output-for-exec_run branch from 0687d13 to ef08149 Compare May 13, 2024 03:21
Signed-off-by: ifuryst <ifuryst@gmail.com>
@iFurySt iFurySt force-pushed the feat-add-stream-output-for-exec_run branch from ef08149 to 1f561b0 Compare May 13, 2024 03:37
@iFurySt iFurySt marked this pull request as ready for review May 13, 2024 03:41
Signed-off-by: ifuryst <ifuryst@gmail.com>
@iFurySt
Copy link
Collaborator Author

iFurySt commented May 13, 2024

SSH.Box.execute.with.stream.output.screen.recording.mp4

ignores the error for BrowserEnv, it has nothing to do with this pr. #350

TypeError: BrowserEnv.__init__() got an unexpected keyword argument 'start_url' was raised from the environment creator for browsergym/openended with kwargs ({'start_url': 'about:blank', 'wait_for_user_message': False, 'headless': True})

@iFurySt
Copy link
Collaborator Author

iFurySt commented May 13, 2024

@rbren @xingyaoww feel free to review it whenever you have time.

@rbren
Copy link
Collaborator

rbren commented May 14, 2024

This is looking good to me!

I'm mostly worried about the complicated logic for parsing the SSH stream--nothing we can leverage from pexpect or another SSH lib?

@iFurySt
Copy link
Collaborator Author

iFurySt commented May 15, 2024

I'm mostly worried about the complicated logic for parsing the SSH stream--nothing we can leverage from pexpect or another SSH lib?

i can't found related lib to use. paramiko with paramiko-expect are similar with expect. the parse logic just buffer the output and then return line by line, and remove the PROMPT([PEXPECT]) finally.

@iFurySt iFurySt enabled auto-merge (squash) May 16, 2024 14:35
@iFurySt iFurySt merged commit e89cc8f into All-Hands-AI:main May 16, 2024
4 checks passed
@@ -344,21 +412,25 @@ def _send_interrupt(
f'Command: "{cmd}" timed out. Sending SIGINT to the process: {command_output}',
)

def execute(self, cmd: str, timeout: int | None = None) -> tuple[int, str]:
def execute(
self, cmd: str, stream: bool = False, timeout: int | None = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Why stream is disabled by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think streaming output makes sense for initialization or time-consuming operations to get feedback. Currently, we don't support streaming output to the frontend. And the agent prefers not to receive the streaming output.

Copy link
Contributor

@SmartManoj SmartManoj May 24, 2024

Choose a reason for hiding this comment

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

How about only streaming the output to the logs?

@SmartManoj
Copy link
Contributor

related lib

@iFurySt Paramiko with continuous stdout You were looking for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants