diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 10d6f229..9cb4ecb4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.11 +current_version = 0.3.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+) serialize = {major}.{minor}.{patch} diff --git a/docker/syftbox.dockerfile b/docker/syftbox.dockerfile index 27f47fb7..1e9e98d1 100644 --- a/docker/syftbox.dockerfile +++ b/docker/syftbox.dockerfile @@ -2,7 +2,7 @@ FROM cgr.dev/chainguard/wolfi-base ARG PYTHON_VERSION="3.12" ARG UV_VERSION="0.4.20-r0" -ARG SYFT_VERSION="0.2.11" +ARG SYFT_VERSION="0.3.0" RUN apk update && apk upgrade && \ apk add --no-cache python-$PYTHON_VERSION uv=$UV_VERSION diff --git a/pyproject.toml b/pyproject.toml index 674be69b..b8c6cc53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "syftbox" -version = "0.2.11" +version = "0.3.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.9" diff --git a/syftbox/__init__.py b/syftbox/__init__.py index 8b67357d..c25a5f18 100644 --- a/syftbox/__init__.py +++ b/syftbox/__init__.py @@ -5,4 +5,4 @@ # |____/ \__, |_| \__|____/ \___/_/\_\ # |___/ -__version__ = "0.2.11" +__version__ = "0.3.0" diff --git a/syftbox/server/middleware.py b/syftbox/server/middleware.py index 4984549d..8251c2ce 100644 --- a/syftbox/server/middleware.py +++ b/syftbox/server/middleware.py @@ -54,24 +54,24 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response: class VersionCheckMiddleware(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next: Callable) -> Response: - logger.info(request.headers) - client_version = request.headers.get(HEADER_SYFTBOX_VERSION) - if not client_version: - return Response( - status_code=status.HTTP_400_BAD_REQUEST, - content="Client version not provided. Please include the 'Version' header.", - ) + user_agent = request.headers.get("User-Agent") + if user_agent.startswith("SyftBox"): + client_version = request.headers.get(HEADER_SYFTBOX_VERSION) - version_range = get_range_for_version(client_version) - lower_bound_version = version_range[0] - # upper_bound_version = version_range[1] - print(client_version, lower_bound_version) + if not client_version: + return Response( + status_code=status.HTTP_400_BAD_REQUEST, + content="Client version not provided. Please include the 'Version' header.", + ) - if version.parse(client_version) < version.parse(lower_bound_version): - return Response( - status_code=status.HTTP_426_UPGRADE_REQUIRED, - content=f"Client version is too old. Minimum version required is {lower_bound_version}", - ) + version_range = get_range_for_version(client_version) + lower_bound_version = version_range[0] + + if version.parse(client_version) < version.parse(lower_bound_version): + return Response( + status_code=status.HTTP_426_UPGRADE_REQUIRED, + content=f"Client version is too old. Minimum version required is {lower_bound_version}", + ) response = await call_next(request) response.headers[HEADER_SYFTBOX_VERSION] = __version__ diff --git a/syftbox/server/migrations.py b/syftbox/server/migrations.py index 64c501ec..a279a41a 100644 --- a/syftbox/server/migrations.py +++ b/syftbox/server/migrations.py @@ -1,5 +1,6 @@ import yaml from loguru import logger +from packaging import version from syftbox import __version__ from syftbox.lib.constants import PERM_FILE @@ -20,7 +21,7 @@ def run_migrations(settings: ServerSettings) -> None: def init_db(settings: ServerSettings) -> None: # remove this after the upcoming release - if __version__ in ["0.2.11", "0.2.12"]: + if version.parse(__version__) > version.parse("0.2.10"): # Delete existing DB to avoid conflicts db_path = settings.file_db_path.absolute() if db_path.exists(): diff --git a/syftbox/server2client_version.json b/syftbox/server2client_version.json index 500b4d96..9cfa1224 100644 --- a/syftbox/server2client_version.json +++ b/syftbox/server2client_version.json @@ -24,16 +24,17 @@ "0.1.22": ["0.1.0", "0.2.0"], "0.1.23": ["0.1.0", "0.2.0"], "0.1.24": ["0.1.0", "0.2.0"], - "0.2.0": ["0.2.0", ""], - "0.2.1": ["0.2.0", ""], - "0.2.2": ["0.2.0", ""], - "0.2.3": ["0.2.0", ""], - "0.2.4": ["0.2.0", ""], - "0.2.5": ["0.2.0", ""], - "0.2.6": ["0.2.0", ""], - "0.2.7": ["0.2.0", ""], - "0.2.8": ["0.2.0", ""], - "0.2.9": ["0.2.0", ""], - "0.2.10": ["0.2.0", ""], - "0.2.11": ["0.2.0", ""] + "0.2.0": ["0.2.0", "0.3.0"], + "0.2.1": ["0.2.0", "0.3.0"], + "0.2.2": ["0.2.0", "0.3.0"], + "0.2.3": ["0.2.0", "0.3.0"], + "0.2.4": ["0.2.0", "0.3.0"], + "0.2.5": ["0.2.0", "0.3.0"], + "0.2.6": ["0.2.0", "0.3.0"], + "0.2.7": ["0.2.0", "0.3.0"], + "0.2.8": ["0.2.0", "0.3.0"], + "0.2.9": ["0.2.0", "0.3.0"], + "0.2.10": ["0.2.0", "0.3.0"], + "0.2.11": ["0.2.0", "0.3.0"], + "0.3.0": ["0.3.0", ""] } diff --git a/uv.lock b/uv.lock index 3ad3edf2..202def58 100644 --- a/uv.lock +++ b/uv.lock @@ -504,7 +504,7 @@ name = "click" version = "8.1.7" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "colorama", marker = "platform_system == 'Windows'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 } wheels = [ @@ -1270,7 +1270,7 @@ name = "ipykernel" version = "6.29.5" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "appnope", marker = "platform_system == 'Darwin'" }, { name = "comm" }, { name = "debugpy" }, { name = "ipython" }, @@ -2737,7 +2737,7 @@ wheels = [ [[package]] name = "syftbox" -version = "0.2.11" +version = "0.3.0" source = { editable = "." } dependencies = [ { name = "aiofiles" }, @@ -2948,7 +2948,7 @@ name = "tqdm" version = "4.67.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "colorama", marker = "platform_system == 'Windows'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737 } wheels = [