Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATAUP-497: Removing old code relating to the defunct UJS #2713

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kbase-extension/static/kbase/js/util/timeFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ define(['util/util'], (Utils) => {

/**
* @method reformatISOTimeString
* Parses the user_and_job_state timestamp and returns it as a user-
* readable string in the UTC time.
* Parses a timestamp and returns it as a user-readable string
* in the UTC time.
*
* This assumes that the timestamp string is in the following format:
*
Expand Down
21 changes: 11 additions & 10 deletions src/biokbase/narrative/clients.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from biokbase.workspace.client import Workspace
from biokbase.narrative_method_store.client import NarrativeMethodStore
from biokbase.userandjobstate.client import UserAndJobState
from biokbase.catalog.Client import Catalog
from biokbase.service.Client import Client as ServiceClient
from biokbase.execution_engine2.execution_engine2Client import execution_engine2
Expand All @@ -19,21 +18,23 @@ def reset():
def __init_client(client_name, token=None):
if client_name == "workspace":
c = Workspace(URLS.workspace, token=token)
elif (
client_name == "execution_engine2"
or client_name == "execution_engine"
or client_name == "job_service"
):
elif client_name == "execution_engine2":
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all the synonyms as we only ever use execution_engine2 in the codebase

c = execution_engine2(URLS.execution_engine2, token=token)
elif client_name == "narrative_method_store":
c = NarrativeMethodStore(URLS.narrative_method_store, token=token)
elif client_name == "service" or client_name == "service_wizard":
elif client_name == "service":
c = ServiceClient(URLS.service_wizard, use_url_lookup=True, token=token)
elif client_name == "catalog":
c = Catalog(URLS.catalog, token=token)
elif client_name == "user_and_job_state":
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove -- unused

c = UserAndJobState(URLS.user_and_job_state, token=token)
else:
raise ValueError('Unknown client name "%s"' % client_name)
raise ValueError(
'Unknown client name "%s"\n' % client_name
+ "The following client names are recognised:\n"
+ 'Catalog: "catalog"\n'
+ 'Execution Engine 2: "execution_engine2"\n'
+ 'NMS: "narrative_method_store"\n'
+ 'Service Wizard: "service"\n'
+ 'Workspace: "workspace"'
)

return c
3 changes: 0 additions & 3 deletions src/biokbase/narrative/exception_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from requests.exceptions import HTTPError
from biokbase.execution_engine2.baseclient import ServerError as EEServerError
from biokbase.userandjobstate.baseclient import ServerError as UJSServerError


class JobRequestException(ValueError):
Expand Down Expand Up @@ -48,8 +47,6 @@ def transform_job_exception(e, error=None):
"""
if isinstance(e, EEServerError):
return NarrativeException(e.code, e.message, e.name, "ee2", error)
elif isinstance(e, UJSServerError):
return NarrativeException(e.code, e.message, e.name, "ujs", error)
elif isinstance(e, HTTPError):
code = e.response.status_code
if code == 404 or code == 502 or code == 503:
Expand Down
32 changes: 32 additions & 0 deletions src/biokbase/narrative/tests/test_clients.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import unittest
import biokbase.narrative.clients as clients

from biokbase.workspace.client import Workspace as WS_Client
from biokbase.narrative_method_store.client import NarrativeMethodStore as NMS_Client
from biokbase.catalog.Client import Catalog as Catalog_Client
from biokbase.service.Client import Client as Service_Client
from biokbase.execution_engine2.execution_engine2Client import (
execution_engine2 as EE2_Client,
)


class ClientsTestCase(unittest.TestCase):
def test_valid_clients(self):
name_to_type = {
"workspace": WS_Client,
"execution_engine2": EE2_Client,
"narrative_method_store": NMS_Client,
"service": Service_Client,
"catalog": Catalog_Client,
}

for client_name, client_type in name_to_type.items():
client = clients.get(client_name)
self.assertIsInstance(client, client_type)

def test_invalid_clients(self):
invalid_names = ["service_wizard", "ee2", "ws"]

for name in invalid_names:
with self.assertRaisesRegex(ValueError, "Unknown client name"):
clients.get(name)
39 changes: 15 additions & 24 deletions src/biokbase/narrative/tests/test_exception_util.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import unittest
from biokbase.narrative.exception_util import (
NarrativeException,
transform_job_exception,
)
from biokbase.execution_engine2.baseclient import ServerError as EEServerError
from biokbase.userandjobstate.baseclient import ServerError as UJSServerError
from requests.exceptions import HTTPError
import requests

ERROR_MSG = "some error message"

HTTP_ERROR = "HTTPError"
HTTP_ERROR_MSG = "http error message"


class ExceptionUtilTestCase(unittest.TestCase):
def test_transform_ee2_err(self):
code = 1000
message = "some error message"
message = ERROR_MSG
name = "EEError"
ee2_err = EEServerError(name, code, message)
nar_err = transform_job_exception(ee2_err)
Expand All @@ -24,7 +27,7 @@ def test_transform_ee2_err(self):

def test_transform_ee2_err__with_error(self):
code = 1000
message = "some error message"
message = ERROR_MSG
name = "EEError"
error = "Unable to perform some request"
ee2_err = EEServerError(name, code, message)
Expand All @@ -35,26 +38,14 @@ def test_transform_ee2_err__with_error(self):
self.assertEqual(nar_err.source, "ee2")
self.assertEqual(nar_err.error, error)

def test_transform_ujs_err(self):
code = 1000
message = "some error message"
name = "UJSError"
ujs_err = UJSServerError(name, code, message)
nar_err = transform_job_exception(ujs_err)
self.assertEqual(nar_err.code, code)
self.assertEqual(nar_err.message, message)
self.assertEqual(nar_err.name, name)
self.assertEqual(nar_err.source, "ujs")
self.assertIsNone(nar_err.error)

def test_transform_http_err_unavailable(self):
codes = [404, 502, 503]
message = "A KBase service is currently unavailable."
name = "HTTPError"
name = HTTP_ERROR
for c in codes:
res = requests.Response()
res.status_code = c
err = HTTPError("http error", response=res)
err = HTTPError(HTTP_ERROR_MSG, response=res)
nar_err = transform_job_exception(err)
self.assertEqual(nar_err.code, c)
self.assertEqual(nar_err.message, message)
Expand All @@ -65,11 +56,11 @@ def test_transform_http_err_unavailable(self):
def test_transform_http_err_timeout(self):
codes = [504, 598, 599]
message = "There was a temporary network connection error."
name = "HTTPError"
name = HTTP_ERROR
for c in codes:
res = requests.Response()
res.status_code = c
err = HTTPError("http error", response=res)
err = HTTPError(HTTP_ERROR_MSG, response=res)
nar_err = transform_job_exception(err)
self.assertEqual(nar_err.code, c)
self.assertEqual(nar_err.message, message)
Expand All @@ -80,10 +71,10 @@ def test_transform_http_err_timeout(self):
def test_transform_http_err_internal(self):
code = 500
message = "An internal error occurred in the KBase service."
name = "HTTPError"
name = HTTP_ERROR
res = requests.Response()
res.status_code = code
err = HTTPError("http error", response=res)
err = HTTPError(HTTP_ERROR_MSG, response=res)
nar_err = transform_job_exception(err)
self.assertEqual(nar_err.code, code)
self.assertEqual(nar_err.message, message)
Expand All @@ -94,10 +85,10 @@ def test_transform_http_err_internal(self):
def test_transform_http_err_unknown(self):
code = 666
message = "An untracked error occurred."
name = "HTTPError"
name = HTTP_ERROR
res = requests.Response()
res.status_code = code
err = HTTPError("http error", response=res)
err = HTTPError(HTTP_ERROR_MSG, response=res)
nar_err = transform_job_exception(err)
self.assertEqual(nar_err.code, code)
self.assertEqual(nar_err.message, message)
Expand Down
Empty file.
Loading