Skip to content

Commit

Permalink
Hotfix: model redeployment (#462)
Browse files Browse the repository at this point in the history
* Fix model redeployment

* Fix style and update version

Co-authored-by: Olek Golovatyi <[email protected]>
  • Loading branch information
0golovatyi and Olek Golovatyi authored Nov 10, 2020
1 parent f891366 commit 5df0e00
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.3.1

### Bug fixes

- Overriding deployed models.

## v2.3.0

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion tabpy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.3.1
1 change: 0 additions & 1 deletion tabpy/tabpy_server/handlers/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def error_out(self, code, log_message, info=None):
code, log_message, info
),
)
self.finish()

def options(self):
# add CORS headers if TabPy has a cors_origin specified
Expand Down
10 changes: 5 additions & 5 deletions tabpy/tabpy_server/management/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def _check_and_set_endpoint_type(self, endpoint_type, defaultValue):
return self._check_and_set_endpoint_str_value(
endpoint_type, "endpoint type", defaultValue)

def _check_and_set_target(self, target, defaultValue):
return self._check_and_set_endpoint_str_value(
target, "target", defaultValue)
def _check_target(self, target):
if target and not isinstance(target, str):
raise ValueError("target must be a string.")

def _check_and_set_dependencies(self, dependencies, defaultValue):
if not dependencies:
Expand Down Expand Up @@ -232,7 +232,7 @@ def add_endpoint(
endpoint_type = self._check_and_set_endpoint_type(endpoint_type, None)
dependencies = self._check_and_set_dependencies(dependencies, [])

target = self._check_and_set_target(target, "")
self._check_target(target)
if target and target not in endpoints:
raise ValueError("target endpoint is not valid.")

Expand Down Expand Up @@ -331,7 +331,7 @@ def update_endpoint(
dependencies = self._check_and_set_dependencies(
dependencies, endpoint_info.get("dependencies", []))

target = self._check_and_set_target(target, None)
self._check_target(target)
if target and target not in endpoints:
raise ValueError("target endpoint is not valid.")
elif not target:
Expand Down
33 changes: 33 additions & 0 deletions tests/integration/test_deploy_model_ssl_on_auth_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,36 @@ def test_deploy_ssl_on_auth_on(self):
headers=headers,
)
self.assertEqual(200, m_response.status_code)

def test_override_model_ssl_on_auth_on(self):
# Uncomment the following line to preserve
# test case output and other files (config, state, ect.)
# in system temp folder.
# self.set_delete_temp_folder(False)

self.deploy_models(self._get_username(), self._get_password())

# Override models
self.deploy_models(self._get_username(), self._get_password())

headers = {
"Content-Type": "application/json",
"TabPy-Client": "Integration test for deploying models with auth",
"Authorization": "Basic "
+ base64.b64encode("user1:P@ssw0rd".encode("utf-8")).decode("utf-8"),
}

session = requests.Session()
# Do not verify servers' cert to be signed by trusted CA
session.verify = False
# Do not warn about insecure request
requests.packages.urllib3.disable_warnings()

models = ["PCA", "Sentiment%20Analysis", "ttest", "anova"]
for m in models:
m_response = session.get(
url=f"{self._get_transfer_protocol()}://"
f"localhost:9004/endpoints/{m}",
headers=headers,
)
self.assertEqual(200, m_response.status_code)

0 comments on commit 5df0e00

Please sign in to comment.