Skip to content

Commit

Permalink
W-16337942: updating update_endpoint_info to not increment endpoint v…
Browse files Browse the repository at this point in the history
…ersion (#649)

* updating update_endpoint_info to not increment endpoint version

* rename variable for better readability

* responding to mr comments
  • Loading branch information
jmoens authored Sep 23, 2024
1 parent 89a8936 commit 9f6fbb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions docs/tabpy-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ client.update_endpoint_info('add',
schema=updatedSchema)
```

Each update of an endpoint will increment its version number, which is also
returned as part of the query result.
Updating endpoints via `update_endpoint_info` will NOT increment version number

## Predeployed Functions

Expand Down
6 changes: 4 additions & 2 deletions tabpy/tabpy_server/handlers/endpoint_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ def put(self, name):
self.finish()
return

new_version = int(endpoints[name]["version"]) + 1
version_after_update = int(endpoints[name]["version"])
if request_data.get('should_update_version'):
version_after_update += 1
self.logger.log(logging.INFO, f"Endpoint info: {request_data}")
err_msg = yield self._add_or_update_endpoint(
"update", name, new_version, request_data
"update", name, version_after_update, request_data
)
if err_msg:
self.error_out(400, err_msg)
Expand Down
5 changes: 2 additions & 3 deletions tabpy/tabpy_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, is_publ
if version == 1:
self._service.add_endpoint(Endpoint(**obj))
else:
self._service.set_endpoint(Endpoint(**obj))
self._service.set_endpoint(Endpoint(**obj), should_update_version=True)

self._wait_for_endpoint_deployment(obj["name"], obj["version"])

Expand Down Expand Up @@ -323,8 +323,7 @@ def update_endpoint_info(self, name, description=None, schema=None, is_public=No
endpoint.src_path = os.path.join(
dest_path, "endpoints", endpoint.name, str(endpoint.version)
)

self._service.set_endpoint(endpoint)
self._service.set_endpoint(endpoint, should_update_version=False)

def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_public=False):
"""Generates an endpoint dict.
Expand Down
12 changes: 10 additions & 2 deletions tabpy/tabpy_tools/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def add_endpoint(self, endpoint):
"""
return self.service_client.POST("endpoints", endpoint.to_json())

def set_endpoint(self, endpoint):
def set_endpoint(self, endpoint, should_update_version=True):
"""Updates an endpoint through the management API.
Parameters
Expand All @@ -213,8 +213,16 @@ def set_endpoint(self, endpoint):
endpoint : Endpoint
The endpoint to update.
should_update_version : bool
Whether this update should increment the version.
False if this is called from update_endpoint_info
True if called from deploy
"""
return self.service_client.PUT("endpoints/" + endpoint.name, endpoint.to_json())
request_body = endpoint.to_json()
request_body["should_update_version"] = should_update_version
return self.service_client.PUT("endpoints/" + endpoint.name, request_body)

def remove_endpoint(self, endpoint_name):
"""Deletes an endpoint through the management API.
Expand Down

0 comments on commit 9f6fbb1

Please sign in to comment.