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

Fixed compatibility checks with pre-release versions #1730

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
### Fixes
- Fixed `tqdm.notebook` import only in Notebook environment ([#1716](https://github.com/neptune-ai/neptune-client/pull/1716))
- Added `setuptools` to dependencies for `python >= 3.12` ([#1721](https://github.com/neptune-ai/neptune-client/pull/1721))
- Fixed compatibility checks with pre-release versions ([#1730](https://github.com/neptune-ai/neptune-client/pull/1730))


## neptune 1.10.0
Expand Down
16 changes: 12 additions & 4 deletions src/neptune/internal/backends/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,26 @@ def create_swagger_client(url: str, http_client: HttpClient) -> SwaggerClient:


def verify_client_version(client_config: ClientConfig, version: Version):
base_version = Version(f"{version.major}.{version.minor}.{version.micro}")
version_with_patch_0 = Version(replace_patch_version(str(version)))
if client_config.version_info.min_compatible and client_config.version_info.min_compatible > version:

min_compatible = client_config.version_info.min_compatible
max_compatible = client_config.version_info.max_compatible
min_recommended = client_config.version_info.min_recommended

if min_compatible and min_compatible > base_version:
raise NeptuneClientUpgradeRequiredError(version, min_version=client_config.version_info.min_compatible)
if client_config.version_info.max_compatible and client_config.version_info.max_compatible < version_with_patch_0:

if max_compatible and max_compatible < version_with_patch_0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why when checking whether client version is too big we extend possible micro versions?

Ex. if version = 1.5.10 and max_compatible = 1.5.0 we are not raising exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know :<. Maybe someone set 0.10.0 instead of 0.10.9999 for some already delivered self hosted environment and that was easier to do it in client.

raise NeptuneClientUpgradeRequiredError(version, max_version=client_config.version_info.max_compatible)
if client_config.version_info.min_recommended and client_config.version_info.min_recommended > version:

if min_recommended and min_recommended > version:
logger.warning(
"WARNING: Your version of the Neptune client library (%s) is deprecated,"
" and soon will no longer be supported by the Neptune server."
" We recommend upgrading to at least version %s.",
version,
client_config.version_info.min_recommended,
min_recommended,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,18 @@ def test_min_compatible_version_ok(self, swagger_client_factory):
# expect
HostedNeptuneBackend(credentials)

@patch(
"neptune.internal.backends.hosted_client.neptune_version",
Version("2.0.0-alpha4+dev1234"),
)
@patch("socket.gethostbyname", MagicMock(return_value="1.1.1.1"))
def test_min_compatible_pre_release_version_ok(self, swagger_client_factory):
# given
self._get_swagger_client_mock(swagger_client_factory, min_compatible="2.0.0")

# expect
HostedNeptuneBackend(credentials)

@patch(
"neptune.internal.backends.hosted_client.neptune_version",
Version("0.5.13"),
Expand Down
Loading