Skip to content

Commit 89563a3

Browse files
author
Pedro Crespo
committed
Fixes retrieving openapi to webserver.
1 parent c166bc0 commit 89563a3

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

packages/service-library/src/servicelib/openapi.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ def load_from_path(filepath: Path) -> Tuple[Dict, str]:
3232

3333

3434
async def load_from_url(url: URL) -> Tuple[Dict, str]:
35-
TIMEOUT_SECS = 5*60
36-
async with ClientSession(timeout=TIMEOUT_SECS) as session:
35+
#TIMEOUT_SECS = 5*60
36+
#async with ClientSession(timeout=TIMEOUT_SECS) as session:
37+
async with ClientSession() as session:
3738
async with session.get(url) as resp:
38-
spec_dict = yaml.safe_load(resp.content)
39+
text = await resp.text()
40+
spec_dict = yaml.safe_load(text)
3941
return spec_dict, str(url)
4042

4143

packages/simcore-sdk/src/simcore_sdk/config/rabbit.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# TODO: adapt all data below!
1313
# TODO: can use venv as defaults? e.g. $RABBITMQ_LOG_CHANNEL
1414
CONFIG_SCHEMA = T.Dict({
15+
T.Key("enabled", default=True, optional=True): T.Bool(),
1516
T.Key("host", default='rabbit', optional=True): T.String(),
1617
T.Key("port", default=5672, optional=True): T.Int(),
1718
"user": T.String(),

services/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ services:
7878
- SMTP_PORT=${SMTP_PORT}
7979
depends_on:
8080
- webclient
81+
- apihub
8182
#--------------------------------------------------------------------
8283
rabbit:
8384
image: rabbitmq:3-management

services/sidecar/requirements/base.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Common third party packages
2-
# Please keep alphabetical order
32
celery==4.1.0
43
docker==3.5.0
54
kombu==4.1.0

services/web/server/src/simcore_service_webserver/computation_config.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
"""
66
from simcore_sdk.config.rabbit import CONFIG_SCHEMA as _RABBIT_SCHEMA
77

8-
import trafaret as T
8+
# import trafaret as T
99

1010
SERVICE_NAME = 'rabbit'
1111
CONFIG_SECTION_NAME = SERVICE_NAME
1212

1313

14-
schema = _RABBIT_SCHEMA.merge(T.Dict({
15-
T.Key("enabled", default=True, optional=True): T.Bool()
16-
}))
14+
schema = _RABBIT_SCHEMA

services/web/server/src/simcore_service_webserver/rest.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from copy import deepcopy
1111

1212
from aiohttp import web
13+
from tenacity import before_sleep_log, retry, stop_after_attempt, wait_fixed
1314

1415
from servicelib import openapi
1516
from servicelib.application_keys import APP_CONFIG_KEY
@@ -22,6 +23,10 @@
2223
log = logging.getLogger(__name__)
2324

2425

26+
RETRY_WAIT_SECS = 2
27+
RETRY_COUNT = 20
28+
CONNECT_TIMEOUT_SECS = 30
29+
2530

2631
def get_server(servers, url):
2732
# Development server: http://{host}:{port}/{basePath}
@@ -30,7 +35,13 @@ def get_server(servers, url):
3035
return server
3136
raise ValueError("Cannot find server %s in openapi specs" % url)
3237

33-
#-----------------------
38+
39+
@retry( wait=wait_fixed(RETRY_WAIT_SECS),
40+
stop=stop_after_attempt(RETRY_COUNT),
41+
before_sleep=before_sleep_log(log, logging.INFO) )
42+
async def get_specs(location):
43+
specs = await create_openapi_specs(location)
44+
return specs
3445

3546

3647
def setup(app: web.Application, *, debug=False):
@@ -43,7 +54,7 @@ def setup(app: web.Application, *, debug=False):
4354
#specs = await create_openapi_specs(location=cfg["location"])
4455
loop = asyncio.get_event_loop()
4556
location = cfg["location"]
46-
specs = loop.run_until_complete( create_openapi_specs(location) )
57+
specs = loop.run_until_complete( get_specs(location) )
4758

4859
# sets servers variables to current server's config
4960
extra_api_urls = cfg.get("extra_urls", list())

0 commit comments

Comments
 (0)