From 100eeab2c53bdd2c50f8591e58278e16f417d94b Mon Sep 17 00:00:00 2001 From: Thaqib <65588695+thaqibm@users.noreply.github.com> Date: Wed, 15 Nov 2023 21:37:30 -0800 Subject: [PATCH] Sync Diff Client (#290) * add printing diffs * Add dry run param to sync * Increment version and add to changelog * add dry run to ntegration_client * change dry_run -> preview * Add preview to integration_client --- fennel/CHANGELOG.md | 4 ++++ fennel/client/client.py | 9 ++++++++- fennel/test_lib/integration_client.py | 3 ++- fennel/test_lib/mock_client.py | 1 + fennel/utils.py | 19 +++++++++++++------ pyproject.toml | 2 +- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/fennel/CHANGELOG.md b/fennel/CHANGELOG.md index cd34ccae0..153a465eb 100644 --- a/fennel/CHANGELOG.md +++ b/fennel/CHANGELOG.md @@ -12,6 +12,10 @@ ## [0.18.11] - 2023-11-08 - Add support for tier selectors. +## [0.18.10] - 2023-10-30 +- Added `preview` parameter to sync. +- Show entity diffs on sync. + ## [0.18.10] - 2023-10-30 - Add support for `since` in S3 source. diff --git a/fennel/client/client.py b/fennel/client/client.py index c6194f801..0690d04d8 100644 --- a/fennel/client/client.py +++ b/fennel/client/client.py @@ -60,6 +60,7 @@ def sync( self, datasets: Optional[List[Dataset]] = None, featuresets: Optional[List[Featureset]] = None, + preview=False, tier: Optional[str] = None, ): """ @@ -95,12 +96,18 @@ def sync( self.add(featureset) sync_request = self._get_sync_request_proto(tier) response = self._post_bytes( - "{}/sync".format(V1_API), + "{}/sync?preview={}".format(V1_API, str(preview).lower()), sync_request.SerializeToString(), False, 300, ) check_response(response) + if response.headers.get("content-type") == "application/json": + res_json = response.json() + if "diffs" in res_json: + diffs = res_json["diffs"] + for line in diffs: + print(line, end="") def log( self, diff --git a/fennel/test_lib/integration_client.py b/fennel/test_lib/integration_client.py index 47391000e..cf34cf8d8 100644 --- a/fennel/test_lib/integration_client.py +++ b/fennel/test_lib/integration_client.py @@ -72,6 +72,7 @@ def sync( self, datasets: List[Dataset] = [], featuresets: List[Featureset] = [], + preview: bool = False, ): self.to_register_objects = [] self.to_register = set() @@ -81,7 +82,7 @@ def sync( self.add(featureset) sync_request = self._get_sync_request_proto() - self._client.sync(sync_request.SerializeToString(), _dry_run=False) + self._client.sync(sync_request.SerializeToString(), preview) time.sleep(1.1) return FakeResponse(200, "OK") diff --git a/fennel/test_lib/mock_client.py b/fennel/test_lib/mock_client.py index 632071b21..dc02871c7 100644 --- a/fennel/test_lib/mock_client.py +++ b/fennel/test_lib/mock_client.py @@ -344,6 +344,7 @@ def sync( self, datasets: Optional[List[Dataset]] = None, featuresets: Optional[List[Featureset]] = None, + preview=False, tier: Optional[str] = None, ): self._reset() diff --git a/fennel/utils.py b/fennel/utils.py index 072b2a4a2..02aed707b 100644 --- a/fennel/utils.py +++ b/fennel/utils.py @@ -76,13 +76,20 @@ def fennel_get_source(obj: Any) -> str: def check_response(response: requests.Response): # type: ignore """Check the response from the server and raise an exception if the response is not OK""" if response.status_code != 200: - print( - "Server returned: {}, {}, {}".format( - response.status_code, - response.reason, - response.text, + if response.headers.get("content-type") == "application/json": + print( + "Server returned: {}, {}".format( + response.status_code, response.reason + ) + ) + else: + print( + "Server returned: {}, {}, {}".format( + response.status_code, + response.reason, + response.text, + ) ) - ) def del_namespace(obj, depth): diff --git a/pyproject.toml b/pyproject.toml index 0fdb4692f..f5ae3f25d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fennel-ai" -version = "0.18.17" +version = "0.18.18" description = "The modern realtime feature engineering platform" authors = ["Fennel AI "] packages = [{ include = "fennel" }]