diff --git a/beacon/conf/conf.py b/beacon/conf/conf.py index 2dee48b..4b94296 100644 --- a/beacon/conf/conf.py +++ b/beacon/conf/conf.py @@ -23,7 +23,7 @@ alternative_url = 'https://beacon.ega-archive.org/api' create_datetime = '2021-11-29T12:00:00.000000' update_datetime = '' -default_beacon_granularity = "record" # boolean, count or record +max_beacon_granularity = "record" # boolean, count or record security_levels = ['PUBLIC', 'REGISTERED', 'CONTROLLED'] documentation_url = 'https://b2ri-documentation-demo.ega-archive.org/' alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges','phenotypicFeatures.onset.iso8601duration'] diff --git a/beacon/connections/mongo/Makefile b/beacon/connections/mongo/Makefile index 53d796a..107c5b5 100644 --- a/beacon/connections/mongo/Makefile +++ b/beacon/connections/mongo/Makefile @@ -1,19 +1,10 @@ build: - docker cp data/analyses.json mongoprod:tmp/analyses.json - docker cp data/biosamples.json mongoprod:tmp/biosamples.json - docker cp data/cohorts.json mongoprod:tmp/cohorts.json - docker cp data/datasets.json mongoprod:tmp/datasets.json - docker cp data/genomicVariations.json mongoprod:tmp/genomicVariations.json - docker cp data/individuals.json mongoprod:tmp/individuals.json - docker cp data/runs.json mongoprod:tmp/runs.json - docker cp data/targets.json mongoprod:tmp/targets.json - docker cp data/caseLevelData.json mongoprod:tmp/caseLevelData.json - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/datasets.json --collection datasets - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/individuals.json --collection individuals - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/cohorts.json --collection cohorts - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/analyses.json --collection analyses - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/biosamples.json --collection biosamples - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/genomicVariations.json --collection genomicVariations - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/runs.json --collection runs - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/targets.json --collection targets - docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /tmp/caseLevelData.json --collection caseLevelData \ No newline at end of file + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/datasets.json --collection datasets + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/individuals.json --collection individuals + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/cohorts.json --collection cohorts + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/analyses.json --collection analyses + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/biosamples.json --collection biosamples + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/genomicVariations.json --collection genomicVariations + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/runs.json --collection runs + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/targets.json --collection targets + docker exec mongoprod mongoimport --jsonArray --uri "mongodb://root:example@127.0.0.1:27017/beacon?authSource=admin" --file /data/caseLevelData.json --collection caseLevelData \ No newline at end of file diff --git a/beacon/request/parameters.py b/beacon/request/parameters.py index b1f604b..47c8dfb 100644 --- a/beacon/request/parameters.py +++ b/beacon/request/parameters.py @@ -9,7 +9,7 @@ ) from strenum import StrEnum from typing import List, Optional, Union -from beacon.conf.conf import api_version, default_beacon_granularity +from beacon.conf.conf import api_version, max_beacon_granularity from humps.main import camelize from aiohttp.web_request import Request from aiohttp import web @@ -83,7 +83,7 @@ class RequestQuery(CamelModel): pagination: Pagination = Pagination() request_parameters: Union[list,dict] = {} test_mode: bool = False - requested_granularity: Granularity = Granularity(default_beacon_granularity) + requested_granularity: Granularity = Granularity(max_beacon_granularity) scope: str = None class SequenceQuery(BaseModel): diff --git a/beacon/response/builder.py b/beacon/response/builder.py index eb4a33f..bc18b62 100644 --- a/beacon/response/builder.py +++ b/beacon/response/builder.py @@ -1,7 +1,7 @@ from aiohttp.web_request import Request from beacon.response.catalog import build_beacon_record_response_by_dataset, build_beacon_count_response, build_beacon_collection_response, build_beacon_info_response, build_map, build_configuration, build_entry_types, build_beacon_service_info_response, build_filtering_terms_response, build_beacon_boolean_response, build_beacon_none_response from beacon.logs.logs import log_with_args, LOG -from beacon.conf.conf import level, default_beacon_granularity +from beacon.conf.conf import level, max_beacon_granularity from beacon.request.classes import Granularity from beacon.source.manage import analyses, biosamples, cohorts, datasets, g_variants, individuals, runs, filtering_terms @@ -39,11 +39,11 @@ async def builder(self, request: Request, datasets, qparams, entry_type, entry_i if testMode == True: datasets = ['test'] datasets_docs, datasets_count, count, entity_schema, include, datasets = await module.execute_function(self, entry_type, datasets, qparams, entry_id) - if include != 'NONE' and granularity == Granularity.RECORD and default_beacon_granularity == 'record': + if include != 'NONE' and granularity == Granularity.RECORD and max_beacon_granularity == 'record': response = build_beacon_record_response_by_dataset(self, datasets, datasets_docs, datasets_count, count, qparams, entity_schema) - elif include == 'NONE' and granularity == Granularity.RECORD and default_beacon_granularity == 'record': + elif include == 'NONE' and granularity == Granularity.RECORD and max_beacon_granularity == 'record': response = build_beacon_none_response(self, datasets_docs["NONE"], count, qparams, entity_schema) - elif granularity == Granularity.COUNT or granularity == Granularity.RECORD and default_beacon_granularity in ['count', 'record']: + elif granularity == Granularity.COUNT and max_beacon_granularity in ['count', 'record'] or granularity == Granularity.RECORD and max_beacon_granularity in ['count']: response = build_beacon_count_response(self, count, qparams, entity_schema) else: response = build_beacon_boolean_response(self, count, qparams, entity_schema) diff --git a/beacon/response/catalog.py b/beacon/response/catalog.py index 444d185..f4f33e0 100644 --- a/beacon/response/catalog.py +++ b/beacon/response/catalog.py @@ -314,7 +314,7 @@ def build_configuration(self): 'productionStatus': conf.environment.upper() }, 'securityAttributes': { - 'defaultGranularity': conf.default_beacon_granularity, + 'defaultGranularity': conf.max_beacon_granularity, 'securityLevels': conf.security_levels }, 'entryTypes': entry_types['entryTypes'] diff --git a/docker-compose.yml b/docker-compose.yml index cb9270a..e3c18dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -67,11 +67,11 @@ services: db: image: mongo:5 - command: --wiredTigerCacheSizeGB 4 + command: --wiredTigerCacheSizeGB 4 -port 27018 hostname: mongo container_name: mongoprod ports: - - 27017:27017 + - 27018:27017 environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: example