-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from EGA-archive/develop
Handling errors
- Loading branch information
Showing
10 changed files
with
398 additions
and
283 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import subprocess | ||
import logging | ||
import json | ||
from aiohttp.web_request import Request | ||
from beacon.db.datasets import get_datasets | ||
from beacon.request import RequestParams | ||
from beacon.response.build_response import build_beacon_error_response | ||
from beacon.utils.auth import resolve_token | ||
from beacon.utils.stream import json_stream | ||
from bson import json_util | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
async def handler(request: Request): | ||
LOG.error('Running an error request') | ||
|
||
# Fetch datasets info | ||
qparams = '' | ||
|
||
response_converted= build_beacon_error_response(404, qparams, 'Not Found') | ||
return await json_stream(request, response_converted) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import logging | ||
from aiohttp.web_request import Request | ||
from beacon.response.build_response import build_beacon_service_info_response | ||
from beacon.response.build_response import build_beacon_service_info_response, build_beacon_error_response | ||
from beacon.utils.stream import json_stream | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
async def handler(request: Request): | ||
LOG.info('Running a GET service info request') | ||
response_converted = build_beacon_service_info_response() | ||
try: | ||
LOG.info('Running a GET service info request') | ||
response_converted = build_beacon_service_info_response() | ||
except Exception as err: | ||
qparams = '' | ||
if str(err) == 'Not Found': | ||
response_converted = build_beacon_error_response(404, qparams, str(err)) | ||
elif str(err) == 'Bad Request': | ||
response_converted = build_beacon_error_response(400, qparams, str(err)) | ||
else: | ||
response_converted = build_beacon_error_response(500, qparams, str(err)) | ||
return await json_stream(request, response_converted) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,6 @@ build: | |
docker exec rimongo /bin/bash -c 'mongo beacon -u root -p example --authenticationDatabase admin --eval "db.genomicVariations.deleteMany({})"' | ||
docker exec rimongo /bin/bash -c 'mongo beacon -u root -p example --authenticationDatabase admin --eval "db.individuals.deleteMany({})"' | ||
docker exec rimongo /bin/bash -c 'mongo beacon -u root -p example --authenticationDatabase admin --eval "db.runs.deleteMany({})"' | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/analyses.json rimongo:tmp/analyses.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/biosamples.json rimongo:tmp/biosamples.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/cohorts.json rimongo:tmp/cohorts.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/datasets.json rimongo:tmp/datasets.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/genomicVariations.json rimongo:tmp/genomicVariations.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/individuals.json rimongo:tmp/individuals.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/runs.json rimongo:tmp/runs.json | ||
docker cp /data/vault/bio-scratch/arnau/beacon/beacon2-ri-tools-v2_test_anot/filtering_terms.json rimongo:tmp/filtering_terms.json | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/datasets.json --collection datasets | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/individuals.json --collection individuals | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/cohorts.json --collection cohorts | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/analyses.json --collection analyses | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/biosamples.json --collection biosamples | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/runs.json --collection runs | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/genomicVariations.json --collection genomicVariations | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/filtering_terms.json --collection filtering_terms | ||
docker cp data/analyses.json rimongo:tmp/analyses.json | ||
docker cp data/biosamples.json rimongo:tmp/biosamples.json | ||
docker cp data/cohorts.json rimongo:tmp/cohorts.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,23 +40,23 @@ With `mongo-express` we can see the contents of the database at [http://localhos | |
To load the database we execute the following commands: | ||
|
||
```bash | ||
docker cp /path/to/analyses.json deploy_db_1:tmp/analyses.json | ||
docker cp /path/to/biosamples.json deploy_db_1:tmp/biosamples.json | ||
docker cp /path/to/cohorts.json deploy_db_1:tmp/cohorts.json | ||
docker cp /path/to/datasets.json deploy_db_1:tmp/datasets.json | ||
docker cp /path/to/genomicVariations.json deploy_db_1:tmp/genomicVariations.json | ||
docker cp /path/to/individuals.json deploy_db_1:tmp/individuals.json | ||
docker cp /path/to/runs.json deploy_db_1:tmp/runs.json | ||
docker cp /path/to/analyses.json rimongo:tmp/analyses.json | ||
docker cp /path/to/biosamples.json rimongo:tmp/biosamples.json | ||
docker cp /path/to/cohorts.json rimongo:tmp/cohorts.json | ||
docker cp /path/to/datasets.json rimongo:tmp/datasets.json | ||
docker cp /path/to/genomicVariations.json rimongo:tmp/genomicVariations.json | ||
docker cp /path/to/individuals.json rimongo:tmp/individuals.json | ||
docker cp /path/to/runs.json rimongo:tmp/runs.json | ||
``` | ||
|
||
```bash | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/datasets.json --collection datasets | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/analyses.json --collection analyses | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/biosamples.json --collection biosamples | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/cohorts.json --collection cohorts | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/genomicVariations.json --collection genomicVariations | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/individuals.json --collection individuals | ||
docker exec deploy_db_1 mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/runs.json --collection runs | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/datasets.json --collection datasets | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/analyses.json --collection analyses | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/biosamples.json --collection biosamples | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/cohorts.json --collection cohorts | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/genomicVariations.json --collection genomicVariations | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/individuals.json --collection individuals | ||
docker exec rimongo mongoimport --jsonArray --uri "mongodb://root:[email protected]:27017/beacon?authSource=admin" --file /tmp/runs.json --collection runs | ||
``` | ||
|
||
This loads the JSON files inside of the `data` folder into the MongoDB database container. Each time you import data you will have to create indexes for the queries to run smoothly. Please, check the next point about how to Create the indexes. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters