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

Add recursive directory watch #488

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

dobrac
Copy link

@dobrac dobrac commented Dec 2, 2024

Adds recursive directory watch to the SDK and documentation section. Requires merging and deploying e2b-dev/infra#210 first.

Proposed API change:

JS

await sandbox.files.watchDir(dirname, handler, {
  recursive: true
})

Python

sandbox.files.watch_dir(dirname, recursive=True)

Notes

Python SDK was generated using buf.build/protocolbuffers/python:v28.3. The runtime check was removed for now. Further tests might be required to make sure the runtime is at least the generated version before including the runtime check.
Changing the following in the file spec/envd/buf-python.gen.yaml (generator) allows using different protoc-gen-python version:
From: plugin: python
To: plugin: buf.build/protocolbuffers/python:v28.3

Copy link

changeset-bot bot commented Dec 2, 2024

⚠️ No Changeset found

Latest commit: 091ada1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mlejva mlejva requested a review from 0div December 2, 2024 21:34
@dobrac dobrac marked this pull request as ready for review December 2, 2024 23:10
Copy link
Contributor

@0div 0div left a comment

Choose a reason for hiding this comment

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

Overall this looks good from a code perspective 👍

From a product perspective, do you think it would be better not to make recursive an option and just always watch recursively ? Also taking into account that the instructions said:

Make as few changes to the communication between envd and SDKs as possible

@ValentaTomas ValentaTomas added feature New feature or request sdk Improvements or additions to SDKs labels Dec 10, 2024
@dobrac dobrac force-pushed the watch-dir-recursive branch from 666b3d4 to 724e857 Compare December 19, 2024 08:56
Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

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

The envd version check is missing in Python SDK

Copy link
Member

@jakubno jakubno left a comment

Choose a reason for hiding this comment

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

Some last polishing, I will merge after we merge the envd part

Comment on lines 121 to 124
apiUrl: this.envdApiUrl,
logger: opts?.logger,
},
opts?.envdVersion
Copy link
Member

Choose a reason for hiding this comment

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

why not like this?

Suggested change
apiUrl: this.envdApiUrl,
logger: opts?.logger,
},
opts?.envdVersion
apiUrl: this.envdApiUrl,
logger: opts?.logger,
envdVersion: opts?.envdVersion
},

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking it may be different scope than "ConnectionConfig" (maybe in the future part of some Metadata interface?), but If you want, I can move it there

Copy link
Author

Choose a reason for hiding this comment

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

Resolved by wrapping envdVersion to the metadata object

const newContent = 'This file has been modified.'

await sandbox.files.makeDir(`${dirname}/${nestedDirname}`)
onTestFinished(() => sandbox.files.remove(dirname))
Copy link
Member

Choose a reason for hiding this comment

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

Technically correct, but not really necessary, the sandbox is killed after the test ends. This will only add one call to sandbox, but you could do this for local testing. Locally the same sandbox is reused

Suggested change
onTestFinished(() => sandbox.files.remove(dirname))
if (isDebug) {
onTestFinished(() => sandbox.files.remove(dirname))
}

Copy link
Author

Choose a reason for hiding this comment

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

👍

const content = 'This file will be watched.'

await sandbox.files.makeDir(dirname)
onTestFinished(() => sandbox.files.remove(dirname))
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Author

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request sdk Improvements or additions to SDKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants