Skip to content

Commit

Permalink
add aiojobs setup and add pre-query condition
Browse files Browse the repository at this point in the history
  • Loading branch information
csc-jm committed Dec 21, 2020
1 parent 45b47bc commit 228992b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- "OIDC_URL=http://mockauth:8000"
# Enable this we working with front-end on localhost
# or change to http://frontend:3000 if started using docker-compose
# - "REDIRECT_URL=http://localhost:3000"
- "REDIRECT_URL=http://localhost:3000"
- "JWK_URL=http://mockauth:8000/keyset"
- "AUTH_REFERER=http://mockauth:8000/"
- "LOG_LEVEL=DEBUG"
Expand Down Expand Up @@ -52,4 +52,4 @@ services:
- ./tests/integration/mock_auth.py:/mock_auth.py
entrypoint: ["python", "/mock_auth.py", "0.0.0.0", "8000"]
volumes:
data:
data:
4 changes: 4 additions & 0 deletions metadata_backend/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,10 @@ async def data_mirroring(self, dataset_id: str, db_client: AsyncIOMotorClient) -
query = MultiDictProxy(MultiDict([("egaStableId", dataset_id)]))
_, _, _, total_objects = await Operator(db_client).query_metadata_database("dataset", query, 1, 1, [])
if total_objects > 0:
LOG.info(f"Dataset {dataset_id} has already been mirrored into the database.")
# Idea with this is to query for a dataset with the exactly same egaStableId value
# and if none is found, then it is mirrored from EGA. As of now, this query doesn't work properly
else:
ega_data = MetadataMirror().mirror_dataset(dataset_id)
operator = Operator(db_client)
for schema_type in ega_data:
Expand Down
10 changes: 8 additions & 2 deletions metadata_backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import uvloop
from aiohttp import web
from aiojobs.aiohttp import setup
from cryptography.fernet import Fernet
import secrets
import time
Expand Down Expand Up @@ -55,7 +56,6 @@ async def init() -> web.Application:
server.middlewares.append(check_login)
rest_handler = RESTApiHandler()
submission_handler = SubmissionAPIHandler()
mirror_handler = DataMirrorHandler()
api_routes = [
web.get("/schemas", rest_handler.get_schema_types),
web.get("/schemas/{schema}", rest_handler.get_json_schema),
Expand All @@ -79,7 +79,6 @@ async def init() -> web.Application:
web.delete("/users/{userId}", rest_handler.delete_user),
web.post("/submit", submission_handler.submit),
web.post("/validate", submission_handler.validate),
web.get("/mirror/{datasetId}", mirror_handler.mirror_dataset),
]
server.router.add_routes(api_routes)
LOG.info("Server configurations and routes loaded")
Expand All @@ -91,6 +90,13 @@ async def init() -> web.Application:
]
server.router.add_routes(aai_routes)
LOG.info("AAI routes loaded")
mirror_handler = DataMirrorHandler()
mirror_routes = [
web.get("/mirror/{datasetId}", mirror_handler.mirror_dataset),
]
server.router.add_routes(mirror_routes)
setup(server)
LOG.info("Mirroring routes loaded")
if frontend_static_files.exists():
static_handler = StaticHandler(frontend_static_files)
frontend_routes = [
Expand Down

0 comments on commit 228992b

Please sign in to comment.