Skip to content

Commit

Permalink
Sync Diff Client (#290)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thaqibm authored Nov 16, 2023
1 parent 42e9391 commit 100eeab
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions fennel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 8 additions & 1 deletion fennel/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def sync(
self,
datasets: Optional[List[Dataset]] = None,
featuresets: Optional[List[Featureset]] = None,
preview=False,
tier: Optional[str] = None,
):
"""
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion fennel/test_lib/integration_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def sync(
self,
datasets: List[Dataset] = [],
featuresets: List[Featureset] = [],
preview: bool = False,
):
self.to_register_objects = []
self.to_register = set()
Expand All @@ -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")

Expand Down
1 change: 1 addition & 0 deletions fennel/test_lib/mock_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 13 additions & 6 deletions fennel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
packages = [{ include = "fennel" }]
Expand Down

0 comments on commit 100eeab

Please sign in to comment.