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 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix versions to match updated envd version
  • Loading branch information
jakubno committed Jan 13, 2025
commit f4369e17613fbc439c3db99c355800787eba2dcf
1 change: 1 addition & 0 deletions packages/js-sdk/src/envd/versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 1 @@
export const ENVD_VERSION_RECURSIVE_WATCH = '0.1.4'
3 changes: 2 additions & 1 deletion packages/js-sdk/src/sandbox/filesystem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 24,7 @@ import { WatchHandle, FilesystemEvent } from './watchHandle'

import { compareVersions } from 'compare-versions'
import { TemplateError } from '../../errors'
import {ENVD_VERSION_RECURSIVE_WATCH} from '../../envd/versions'

/**
* Sandbox filesystem object information.
Expand Down Expand Up @@ -442,7 443,7 @@ export class Filesystem {
onEvent: (event: FilesystemEvent) => void | Promise<void>,
opts?: WatchOpts
): Promise<WatchHandle> {
if (opts?.recursive && this.envdApi.version && compareVersions(this.envdApi.version, '0.1.3') < 0) {
if (opts?.recursive && this.envdApi.version && compareVersions(this.envdApi.version, ENVD_VERSION_RECURSIVE_WATCH) < 0) {
throw new TemplateError(
'You need to update the template to use recursive watching. '
'You can do this by running `e2b template build` in the directory with the template.'
Expand Down
3 changes: 3 additions & 0 deletions packages/python-sdk/e2b/envd/versions.py
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
from packaging.version import Version

ENVD_VERSION_RECURSIVE_WATCH = Version("0.1.4")
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 14,7 @@
from e2b.envd.api import ENVD_API_FILES_ROUTE, ahandle_envd_api_exception
from e2b.envd.filesystem import filesystem_connect, filesystem_pb2
from e2b.envd.rpc import authentication_header, handle_rpc_exception
from e2b.envd.versions import ENVD_VERSION_RECURSIVE_WATCH
from e2b.exceptions import SandboxException, TemplateException
from e2b.sandbox.filesystem.filesystem import EntryInfo, map_file_type
from e2b.sandbox.filesystem.watch_handle import FilesystemEvent
Expand Down Expand Up @@ -361,7 362,11 @@ async def watch_dir(

:return: `AsyncWatchHandle` object for stopping watching directory
"""
if recursive and self._envd_version is not None and Version(self._envd_version) < Version("0.1.3"):
if (
recursive
and self._envd_version is not None
and Version(self._envd_version) < ENVD_VERSION_RECURSIVE_WATCH
):
raise TemplateException(
"You need to update the template to use recursive watching. "
"You can do this by running `e2b template build` in the directory with the template."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@
import httpx
from packaging.version import Version

from e2b.envd.versions import ENVD_VERSION_RECURSIVE_WATCH
from e2b.exceptions import TemplateException
from e2b.connection_config import (
ConnectionConfig,
Expand Down Expand Up @@ -353,7 354,11 @@ def watch_dir(

:return: `WatchHandle` object for stopping watching directory
"""
if recursive and self._envd_version is not None and Version(self._envd_version) < Version("0.1.3"):
if (
recursive
and self._envd_version is not None
and Version(self._envd_version) < ENVD_VERSION_RECURSIVE_WATCH
):
raise TemplateException(
"You need to update the template to use recursive watching. "
"You can do this by running `e2b template build` in the directory with the template."
Expand Down
Loading