E2B icon indicating copy to clipboard operation
E2B copied to clipboard

Unable to use recursive=True on watch_dir for beta version with persistence

Open suhjohn opened this issue 8 months ago • 5 comments

    |   File "/Users/johnsuh/code/internal-chat/backend/.venv/lib/python3.12/site-packages/starlette/responses.py", line 253, in wrap
    |     await func()
    |   File "/Users/johnsuh/code/internal-chat/backend/.venv/lib/python3.12/site-packages/starlette/responses.py", line 242, in stream_response
    |     async for chunk in self.body_iterator:
    |   File "/Users/johnsuh/code/internal-chat/backend/app/services/conversation_service.py", line 363, in create_message_service
    |     raise e
    |   File "/Users/johnsuh/code/internal-chat/backend/app/services/conversation_service.py", line 340, in create_message_service
    |     async for res in fn(db, context):
    |   File "/Users/johnsuh/code/internal-chat/backend/app/services/pipelines/handlers.py", line 315, in yield_agentic_anthropic
    |     async for response in yield_step(
    |   File "/Users/johnsuh/code/internal-chat/backend/app/services/pipelines/handlers.py", line 351, in yield_step
    |     file_watch_handler = await sandbox.files.watch_dir(
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^
    | TypeError: Filesystem.watch_dir() got an unexpected keyword argument 'recursive'

on + e2b-code-interpreter==1.2.0b1

suhjohn avatar Apr 10 '25 02:04 suhjohn

Hey @suhjohn, can you try updating to version https://pypi.org/project/e2b-code-interpreter/1.2.0b2/ ?

ValentaTomas avatar Apr 10 '25 03:04 ValentaTomas

Amazing. Thank you

suhjohn avatar Apr 10 '25 17:04 suhjohn

actually - I think there might be a regression unless the specs changed:


    async def handle_event(event: FilesystemEvent):  # type: ignore
        print(f"[handlers.py::yield_step] Filesystem event: {to_json_dict(event)}")  # type: ignore

    await sandbox.commands.run(
        f"mkdir -p /home/user/{agent_context['conversation_id']}"
    )
    file_watch_handler = await sandbox.files.watch_dir(
        f"/home/user/{agent_context['conversation_id']}",
        on_event=handle_event,
        recursive=True,
    )

This code used to work, but now it's not printing anything.

suhjohn avatar Apr 10 '25 17:04 suhjohn

Actually, just figured out a way to write a version of it on my own using cli commands

suhjohn avatar Apr 10 '25 19:04 suhjohn

Is this still an issue? Have you tried the latest beta version (1.2.0b6)?

mishushakov avatar May 13 '25 12:05 mishushakov

@suhjohn , are you still experiencing the issue? I think it's been resolved, so I'll close it for now. If the problem persists, please comment, and I'll reopen it.

jakubno avatar Jul 09 '25 15:07 jakubno