forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#2988] feat(client-python): Gravitino python client support ba…
…ckward compatibility (apache#3712) ### What changes were proposed in this pull request? Ref to: apache#2866 * Add a check when creating GravitonClient to ensure that the client version is less than or equal to the server version * Unlike ObjectMapping in Java, if we add new field in XXXDTO, old client in Python can still deserialize the object using `dataclass_json`and ignore the new fields, so we only need to check the versions. ### Why are the changes needed? Fix: apache#2988 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Add UTs and enable version check in ITs --------- Co-authored-by: TimWang <tim.wang@pranaq.com>
- Loading branch information
1 parent
ba6588f
commit be6405b
Showing
17 changed files
with
331 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ venv | |
dist | ||
build | ||
README.md | ||
version.ini | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
|
||
include requirements.txt | ||
include requirements-dev.txt | ||
include README.md | ||
include README.md | ||
include version.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" | ||
|
||
from enum import Enum | ||
from pathlib import Path | ||
|
||
PROJECT_HOME = Path(__file__).parent.parent.parent | ||
VERSION_INI = PROJECT_HOME / "version.ini" | ||
SETUP_FILE = PROJECT_HOME / "setup.py" | ||
|
||
|
||
class Version(Enum): | ||
VERSION = "version" | ||
GIT_COMMIT = "gitCommit" | ||
COMPILE_DATE = "compileDate" |
39 changes: 39 additions & 0 deletions
39
clients/client-python/gravitino/dto/responses/version_response.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" | ||
|
||
from dataclasses import dataclass, field | ||
from dataclasses_json import config | ||
|
||
from .base_response import BaseResponse | ||
from ..version_dto import VersionDTO | ||
|
||
|
||
@dataclass | ||
class VersionResponse(BaseResponse): | ||
"""Represents a response containing version of Gravitino.""" | ||
|
||
_version: VersionDTO = field(metadata=config(field_name="version")) | ||
|
||
def version(self) -> VersionDTO: | ||
return self._version | ||
|
||
def validate(self): | ||
"""Validates the response data. | ||
Raise: | ||
IllegalArgumentException if name or audit information is not set. | ||
""" | ||
super().validate() | ||
|
||
assert self._version is not None, "version must be non-null" | ||
assert ( | ||
self._version.version() is not None | ||
), "version 'version' must not be null and empty" | ||
assert ( | ||
self._version.compile_date() is not None | ||
), "version 'compile_date' must not be null and empty" | ||
assert ( | ||
self._version.git_commit() is not None | ||
), "version 'git_commit' must not be null and empty" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Copyright 2024 Datastrato Pvt Ltd. | ||
This software is licensed under the Apache License version 2. | ||
""" |
Oops, something went wrong.