Skip to content

Commit 9f6fbb1

Browse files
authored
W-16337942: updating update_endpoint_info to not increment endpoint version (#649)
* updating update_endpoint_info to not increment endpoint version * rename variable for better readability * responding to mr comments
1 parent 89a8936 commit 9f6fbb1

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

docs/tabpy-tools.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ client.update_endpoint_info('add',
210210
schema=updatedSchema)
211211
```
212212

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

216215
## Predeployed Functions
217216

tabpy/tabpy_server/handlers/endpoint_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ def put(self, name):
7171
self.finish()
7272
return
7373

74-
new_version = int(endpoints[name]["version"]) + 1
74+
version_after_update = int(endpoints[name]["version"])
75+
if request_data.get('should_update_version'):
76+
version_after_update += 1
7577
self.logger.log(logging.INFO, f"Endpoint info: {request_data}")
7678
err_msg = yield self._add_or_update_endpoint(
77-
"update", name, new_version, request_data
79+
"update", name, version_after_update, request_data
7880
)
7981
if err_msg:
8082
self.error_out(400, err_msg)

tabpy/tabpy_tools/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, is_publ
251251
if version == 1:
252252
self._service.add_endpoint(Endpoint(**obj))
253253
else:
254-
self._service.set_endpoint(Endpoint(**obj))
254+
self._service.set_endpoint(Endpoint(**obj), should_update_version=True)
255255

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

@@ -323,8 +323,7 @@ def update_endpoint_info(self, name, description=None, schema=None, is_public=No
323323
endpoint.src_path = os.path.join(
324324
dest_path, "endpoints", endpoint.name, str(endpoint.version)
325325
)
326-
327-
self._service.set_endpoint(endpoint)
326+
self._service.set_endpoint(endpoint, should_update_version=False)
328327

329328
def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_public=False):
330329
"""Generates an endpoint dict.

tabpy/tabpy_tools/rest_client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def add_endpoint(self, endpoint):
204204
"""
205205
return self.service_client.POST("endpoints", endpoint.to_json())
206206

207-
def set_endpoint(self, endpoint):
207+
def set_endpoint(self, endpoint, should_update_version=True):
208208
"""Updates an endpoint through the management API.
209209
210210
Parameters
@@ -213,8 +213,16 @@ def set_endpoint(self, endpoint):
213213
endpoint : Endpoint
214214
215215
The endpoint to update.
216+
217+
should_update_version : bool
218+
219+
Whether this update should increment the version.
220+
False if this is called from update_endpoint_info
221+
True if called from deploy
216222
"""
217-
return self.service_client.PUT("endpoints/" + endpoint.name, endpoint.to_json())
223+
request_body = endpoint.to_json()
224+
request_body["should_update_version"] = should_update_version
225+
return self.service_client.PUT("endpoints/" + endpoint.name, request_body)
218226

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

0 commit comments

Comments
 (0)