Skip to content

Commit

Permalink
[das-query-engine#333] Review the way our libraries are checked in cl…
Browse files Browse the repository at this point in the history
…ient/server connection (#155)

* das-query-engine-333: Move handshake validation to the client-side.

* Update CHANGELOG file

* das-query-engine-333: remove unecessary files

* das-query-engine-333: fix unit tests

* das-query-engine-333: Update CHANGELOG file
  • Loading branch information
levisingularity authored Oct 2, 2024
1 parent 137cfde commit 32ee77e
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 139 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[HOTFIX] Fixes after DAS api change in atom-db/#216
[das-query-engine#333] Move handshake validation to the client-side. The server will now only send the expected library versions.
3 changes: 1 addition & 2 deletions das-query-engine/action_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
GetLinkValidator,
GetNodeByNameStartingWith,
GetNodeValidator,
HandshakeValidator,
QueryValidator,
)

Expand All @@ -36,7 +35,7 @@ def _build_dispatcher(self):
},
ActionType.HANDSHAKE: {
"action": actions.handshake,
"validator": HandshakeValidator,
"validator": None,
},
ActionType.COUNT_ATOMS: {
"action": actions.count_atoms,
Expand Down
22 changes: 1 addition & 21 deletions das-query-engine/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import hyperon_das.link_filters as link_filters
from hyperon_das_atomdb import exceptions as atom_db_exceptions
from utils.decorators import execution_time_tracker, remove_none_args
from utils.version import compare_minor_versions


class ActionType(str, Enum):
Expand Down Expand Up @@ -62,29 +61,10 @@ def ping(self) -> Tuple[dict, int]:
return dict(message="pong"), HTTPStatus.OK

@execution_time_tracker
def handshake(self, das_version: str, atomdb_version: str) -> Tuple[dict, int]:
def handshake(self) -> Tuple[dict, int]:
remote_info = self.das.about()
http_status_code = HTTPStatus.OK

remote_das_version = remote_info["das"]["version"]
remote_atomdb_version = remote_info["atom_db"]["version"]

comparison_das_version_result = compare_minor_versions(remote_das_version, das_version)
if comparison_das_version_result is None or comparison_das_version_result != 0:
logger().error(
f"The version sent by the on-premises Hyperon-DAS is {das_version}, but the expected version on the remote server is {remote_das_version}."
)
http_status_code = HTTPStatus.CONFLICT

comparison_atomdb_version_result = compare_minor_versions(
remote_atomdb_version, atomdb_version
)
if comparison_atomdb_version_result is None or comparison_atomdb_version_result != 0:
logger().error(
f"The version sent by the on-premises Hyperon-DAS-AtomDB is {atomdb_version}, but the expected version on the remote server is {remote_atomdb_version}."
)
http_status_code = HTTPStatus.CONFLICT

return remote_info, http_status_code

@execution_time_tracker
Expand Down
2 changes: 1 addition & 1 deletion das-query-engine/tests/unit/test_action_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_build_dispatcher_handshake_action():

assert isinstance(dispatchers, dict)
assert dispatchers[ActionType.HANDSHAKE]["action"] == expected_actions.handshake
assert hasattr(dispatchers[ActionType.HANDSHAKE]["validator"], "validate")
assert dispatchers[ActionType.PING]["validator"] is None


def test_build_dispatcher_ping_action():
Expand Down
62 changes: 0 additions & 62 deletions das-query-engine/tests/unit/test_version.py

This file was deleted.

46 changes: 0 additions & 46 deletions das-query-engine/utils/version.py

This file was deleted.

7 changes: 0 additions & 7 deletions das-query-engine/validators/actions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from incoming import PayloadValidator, datatypes


class HandshakeValidator(PayloadValidator):
strict = True

das_version = datatypes.String(required=True)
atomdb_version = datatypes.String(required=True)


class GetAtomValidator(PayloadValidator):
strict = True

Expand Down

0 comments on commit 32ee77e

Please sign in to comment.