diff --git a/docs/tabpy-tools.md b/docs/tabpy-tools.md index 361d9215..fdc217e6 100755 --- a/docs/tabpy-tools.md +++ b/docs/tabpy-tools.md @@ -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 diff --git a/tabpy/tabpy_server/handlers/endpoint_handler.py b/tabpy/tabpy_server/handlers/endpoint_handler.py index 583b1762..d7f45f43 100644 --- a/tabpy/tabpy_server/handlers/endpoint_handler.py +++ b/tabpy/tabpy_server/handlers/endpoint_handler.py @@ -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) diff --git a/tabpy/tabpy_tools/client.py b/tabpy/tabpy_tools/client.py index f497a0ce..684fdc0e 100644 --- a/tabpy/tabpy_tools/client.py +++ b/tabpy/tabpy_tools/client.py @@ -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"]) @@ -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. diff --git a/tabpy/tabpy_tools/rest_client.py b/tabpy/tabpy_tools/rest_client.py index e3d5ac07..c3b7a526 100644 --- a/tabpy/tabpy_tools/rest_client.py +++ b/tabpy/tabpy_tools/rest_client.py @@ -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 @@ -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.