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

Misc updates #62

Merged
merged 4 commits into from
Sep 29, 2023
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
9 changes: 5 additions & 4 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

openapi_args = dict(
title="Workflow runner",
version="1.6.4",
version="1.6.5",
terms_of_service="",
translator_component="ARA",
translator_teams=["Standards Reference Implementation Team"],
Expand Down Expand Up @@ -92,11 +92,12 @@ async def run_workflow(
)

message = request_dict["message"]
qgraph = message["query_graph"]
message["auxiliary_graphs"] = message.get("auxiliary_graphs") or {}
workflow = request_dict["workflow"]
logger = gen_logger()
log_level = request_dict.get("log_level", "ERROR")
logger.setLevel(logging._nameToLevel[log_level])
qgraph = message["query_graph"]
completed_workflow = []

for operation in workflow:
Expand Down Expand Up @@ -151,7 +152,7 @@ async def run_workflow(

try:
response = await post_safely(
NORMALIZER_URL + "/response",
NORMALIZER_URL + "/query",
{
"message": response["message"],
"submitter": "Workflow Runner"
Expand Down Expand Up @@ -218,7 +219,7 @@ async def refresh_services_and_operations():
global SERVICES
# Start with empty SERVICES dict.
SERVICES = defaultdict(list)
endpoints = SmartAPI(OPENAPI_SERVER_MATURITY, TRAPI_VERSION).get_operations_endpoints()
endpoints = SmartAPI(OPENAPI_SERVER_MATURITY, TRAPI_VERSION, LOGGER).get_operations_endpoints()
for endpoint in endpoints:
try:
base_url = parse_obj_as(HttpUrl, endpoint["url"])
Expand Down
16 changes: 11 additions & 5 deletions app/smartapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
class SmartAPI:
"""SmartAPI."""

def __init__(self, maturity, trapi):
def __init__(self, maturity, trapi, logger):
"""Initialize."""
self.base_url = "http://smart-api.info/api"
# get workflow-runner maturity level
self.maturity = maturity
self.trapi = trapi
self.logger = logger

@cache
def get_operations_endpoints(self):
Expand All @@ -41,10 +42,15 @@ def get_trapi_endpoints(self):

endpoints = []
for hit in response_dict["hits"]:
try:
title = hit["info"]["title"]
except KeyError:
title = None
try:
if "/query" not in hit["paths"].keys():
continue
except KeyError:
self.logger.warning(f"{title} doesn't have paths")
continue
try:
url = None
Expand All @@ -56,8 +62,10 @@ def get_trapi_endpoints(self):
url = server.get("url", None)
break
if x_maturity is None:
self.logger.warning(f"{title} doesn't have a matching maturity")
continue
except KeyError:
self.logger.warning(f"{title} failed to get maturity")
continue
try:
source_url = hit["_meta"]["url"]
Expand All @@ -71,17 +79,15 @@ def get_trapi_endpoints(self):
if hit["info"]["x-trapi"]["version"].startswith(trapi_minor):
version = hit["info"]["x-trapi"]["version"]
else:
self.logger.warning(f"{title} doesn't have the correct TRAPI version")
continue
except KeyError:
self.logger.warning(f"{title} failed to get TRAPI version")
continue
try:
operations = hit["info"]["x-trapi"]["operations"]
except KeyError:
operations = None
try:
title = hit["info"]["title"]
except KeyError:
title = None
try:
infores = hit["info"]["x-translator"]["infores"]
if infores == "infores:workflow-runner":
Expand Down
Loading