Skip to content

Commit a815a3e

Browse files
author
Pedro Crespo
committed
Renamed comp_backend as computation
Minor
1 parent 0ff6c01 commit a815a3e

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from aiohttp import web
1212

1313
from .application_keys import APP_CONFIG_KEY
14-
from .comp_backend_subscribe import subscribe
14+
from .computation_subscribe import subscribe
1515
from .computation_config import CONFIG_SECTION_NAME, SERVICE_NAME
1616

1717
log = logging.getLogger(__file__)

services/web/server/src/simcore_service_webserver/comp_backend_api.py renamed to services/web/server/src/simcore_service_webserver/computation_api.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from . import director_sdk
2222
from .application_keys import APP_CONFIG_KEY
23-
from .comp_backend_worker import celery
23+
from .computation_worker import celery
2424

2525
# TODO: this should be coordinated with postgres options from config/server.yaml
2626
#from simcore_sdk.config.db import Config as DbConfig
@@ -34,7 +34,7 @@
3434

3535

3636
db_session = None
37-
comp_backend_routes = web.RouteTableDef()
37+
computation_routes = web.RouteTableDef()
3838

3939
async def init_database(_app):
4040
#pylint: disable=W0603
@@ -88,7 +88,7 @@ async def _get_node_details(node_key:str, node_version:str)->dict:
8888
try:
8989
services_enveloped = await director_sdk.get_director().services_by_key_version_get(node_key, node_version)
9090
node_details = services_enveloped.data[0].to_dict()
91-
return node_details
91+
return node_details
9292
except ApiException as err:
9393
log.exception("Error could not find service %s:%s", node_key, node_version)
9494
raise web_exceptions.HTTPNotFound(reason=str(err))
@@ -120,7 +120,7 @@ async def _build_adjacency_list(node_uuid:str, node_schema:dict, node_inputs:dic
120120
if node_uuid not in dag_adjacency_list[input_node_uuid] and is_node_computational:
121121
dag_adjacency_list[input_node_uuid].append(node_uuid)
122122
return dag_adjacency_list
123-
123+
124124
async def _parse_pipeline(pipeline_data:dict): # pylint: disable=R0912
125125
dag_adjacency_list = dict()
126126
tasks = dict()
@@ -133,7 +133,7 @@ async def _parse_pipeline(pipeline_data:dict): # pylint: disable=R0912
133133
node_key = value["key"]
134134
node_version = value["version"]
135135

136-
# get the task data
136+
# get the task data
137137
node_inputs = None
138138
if "inputs" in value:
139139
node_inputs = value["inputs"]
@@ -167,20 +167,20 @@ async def _parse_pipeline(pipeline_data:dict): # pylint: disable=R0912
167167

168168
async def _set_adjacency_in_pipeline_db(project_id, dag_adjacency_list):
169169
try:
170-
pipeline = db_session.query(ComputationalPipeline).filter(ComputationalPipeline.project_id==project_id).one()
170+
pipeline = db_session.query(ComputationalPipeline).filter(ComputationalPipeline.project_id==project_id).one()
171171
log.debug("Pipeline object found")
172172
pipeline.state = 0
173173
pipeline.dag_adjacency_list = dag_adjacency_list
174174
except sqlalchemy.orm.exc.NoResultFound:
175175
# let's create one then
176-
pipeline = ComputationalPipeline(project_id=project_id, dag_adjacency_list=dag_adjacency_list, state=0)
176+
pipeline = ComputationalPipeline(project_id=project_id, dag_adjacency_list=dag_adjacency_list, state=0)
177177
log.debug("Pipeline object created")
178178
db_session.add(pipeline)
179179
except sqlalchemy.orm.exc.MultipleResultsFound:
180180
log.exception("the computation pipeline %s is not unique", project_id)
181181
raise
182182

183-
async def _set_tasks_in_tasks_db(project_id, tasks):
183+
async def _set_tasks_in_tasks_db(project_id, tasks):
184184
tasks_db = db_session.query(ComputationalTask).filter(ComputationalTask.project_id==project_id).all()
185185
# delete tasks that were deleted from the db
186186
for task_db in tasks_db:
@@ -213,7 +213,7 @@ async def _set_tasks_in_tasks_db(project_id, tasks):
213213
db_session.add(comp_task)
214214

215215
# pylint:disable=too-many-branches, too-many-statements
216-
@comp_backend_routes.post("/start_pipeline")
216+
@computation_routes.post("/start_pipeline")
217217
async def start_pipeline(request):
218218
#pylint:disable=broad-except
219219
# FIXME: this should be implemented generaly using async lazy initialization of db_session??
@@ -230,7 +230,7 @@ async def start_pipeline(request):
230230

231231
log.debug("Client calls start_pipeline with project id: %s, pipeline data %s", project_id, pipeline_data)
232232
dag_adjacency_list, tasks = await _parse_pipeline(pipeline_data)
233-
log.debug("Pipeline parsed:\nlist: %s\ntasks: %s", str(dag_adjacency_list), str(tasks))
233+
log.debug("Pipeline parsed:\nlist: %s\ntasks: %s", str(dag_adjacency_list), str(tasks))
234234
try:
235235
await _set_adjacency_in_pipeline_db(project_id, dag_adjacency_list)
236236
await _set_tasks_in_tasks_db(project_id, tasks)

services/web/server/src/simcore_service_webserver/comp_backend_subscribe.py renamed to services/web/server/src/simcore_service_webserver/computation_subscribe.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import logging
44

55
import aio_pika
6+
from aiohttp import web
67

78
from simcore_sdk.config.rabbit import eval_broker
89

910
from .application_keys import APP_CONFIG_KEY
1011
from .computation_config import CONFIG_SECTION_NAME
11-
from .sockets import SIO
12+
from .sockets import sio
1213

1314
log = logging.getLogger(__file__)
1415

@@ -18,16 +19,16 @@ async def on_message(message: aio_pika.IncomingMessage):
1819
data = json.loads(message.body)
1920
log.debug(data)
2021
if data["Channel"] == "Log":
21-
await SIO.emit("logger", data = json.dumps(data))
22+
await sio.emit("logger", data = json.dumps(data))
2223
elif data["Channel"] == "Progress":
23-
await SIO.emit("progress", data = json.dumps(data))
24+
await sio.emit("progress", data = json.dumps(data))
2425

25-
async def subscribe(_app=None):
26+
async def subscribe(app: web.Application):
2627
# TODO: catch and deal with missing connections:
2728
# e.g. CRITICAL:pika.adapters.base_connection:Could not get addresses to use: [Errno -2] Name or service not known (rabbit)
2829
# This exception is catch and pika persists ... WARNING:pika.connection:Could not connect, 5 attempts l
2930

30-
rb_config = _app[APP_CONFIG_KEY][CONFIG_SECTION_NAME]
31+
rb_config = app[APP_CONFIG_KEY][CONFIG_SECTION_NAME]
3132
rabbit_broker = eval_broker(rb_config)
3233

3334
# FIXME: This tmp resolves ``aio pika 169: IncompatibleProtocolError`` upon apio_pika.connect

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from .application_keys import (APP_CONFIG_KEY, APP_DB_ENGINE_KEY,
1717
APP_DB_SESSION_KEY)
18-
from .comp_backend_api import init_database as _init_db
18+
from .computation_api import init_database as _init_db
1919
from .db_models import metadata
2020
from .db_config import CONFIG_SECTION_NAME
2121

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
logger = logging.getLogger(__name__)
88

99
def setup(app: web.Application):
10-
log.debug("Setting up %s ...", __name__)
10+
logger.debug("Setting up %s ...", __name__)
1111

1212
assert CONFIG_SECTION_NAME in app[APP_CONFIG_KEY]
1313

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from servicelib import openapi
1212

13-
from . import comp_backend_api, registry_api, rest_handlers
13+
from . import computation_api, registry_api, rest_handlers
1414
from .application_keys import APP_OPENAPI_SPECS_KEY
1515
from .login import routes as auth_routes
1616
from .rest_settings import get_base_path
@@ -45,7 +45,7 @@ def create(specs: openapi.Spec) -> List[web.RouteDef]:
4545
# FIXME: temp fix for running pipelines
4646
path, handle = '/services', registry_api.get_services
4747
routes.append(web.get(BASEPATH+path, handle))
48-
path, handle = '/start_pipeline', comp_backend_api.start_pipeline
48+
path, handle = '/start_pipeline', computation_api.start_pipeline
4949
routes.append(web.post(BASEPATH+path, handle))
5050

5151
return routes

0 commit comments

Comments
 (0)