Skip to content

Commit

Permalink
Merge pull request #26 from EGA-archive/urgent-fix
Browse files Browse the repository at this point in the history
Applying granularity restrictions from source
  • Loading branch information
costero-e authored Jan 7, 2025
2 parents 9f42772 + 01393f5 commit eeabc63
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion beacon/conf/api_version.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
api_version: v2.0-154384d
api_version: v2.0-9f42772
26 changes: 23 additions & 3 deletions beacon/response/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,56 @@ async def builder(self, request: Request, datasets, qparams, entry_type, entry_i
source_entry_type = source_entry_type[1]
if source_entry_type == 'analyses':
source = analyses['database']
source_granularity = analyses['granularity']
elif source_entry_type == 'biosamples':
source = biosamples['database']
source_granularity = biosamples['granularity']
elif source_entry_type == 'individuals':
source = individuals['database']
source_granularity = individuals['granularity']
elif source_entry_type == 'runs':
source = runs['database']
source_granularity = runs['granularity']
elif entry_type == 'g_variants':
source = g_variants['database']
source_granularity = g_variants['granularity']
elif '_' in entry_type:
source = g_variants['database']
source_granularity = g_variants['granularity']
elif entry_type == 'analyses':
source = analyses['database']
source_granularity = analyses['granularity']
elif entry_type == 'biosamples':
source = biosamples['database']
source_granularity = biosamples['granularity']
elif entry_type == 'individuals':
source = individuals['database']
source_granularity = individuals['granularity']
elif entry_type == 'runs':
source = runs['database']
source_granularity = runs['granularity']
if source_granularity['record']==True:
allowed_granularity='record'
elif source_granularity['count']==True:
allowed_granularity='count'
else:
allowed_granularity='boolean'
complete_module='beacon.connections.'+source+'.executor'
import importlib
module = importlib.import_module(complete_module, package=None)
testMode = qparams.query.test_mode
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 max_beacon_granularity == 'record':
if include != 'NONE' and granularity == Granularity.RECORD and max_beacon_granularity == 'record' and allowed_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 max_beacon_granularity == 'record':
elif include == 'NONE' and granularity == Granularity.RECORD and max_beacon_granularity == 'record' and allowed_granularity=='record':
response = build_beacon_none_response(self, datasets_docs["NONE"], count, qparams, entity_schema)
elif granularity == Granularity.COUNT and max_beacon_granularity in ['count', 'record'] or granularity == Granularity.RECORD and max_beacon_granularity in ['count']:
elif granularity == Granularity.COUNT and max_beacon_granularity in ['count', 'record'] and allowed_granularity in ['count', 'record']:
response = build_beacon_count_response(self, count, qparams, entity_schema)
elif granularity == Granularity.RECORD and max_beacon_granularity in ['count'] and allowed_granularity in ['count', 'record']:
response = build_beacon_count_response(self, count, qparams, entity_schema)
elif granularity == Granularity.RECORD and allowed_granularity in ['count'] and max_beacon_granularity in ['count', 'record']:
response = build_beacon_count_response(self, count, qparams, entity_schema)
else:
response = build_beacon_boolean_response(self, count, qparams, entity_schema)
Expand Down
15 changes: 0 additions & 15 deletions beacon/source/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

analyses={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
Expand All @@ -15,7 +14,6 @@
}
biosamples={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
Expand All @@ -29,11 +27,6 @@
'database': 'mongo'
}
cohorts={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
'singleEntryUrl': True,
'endpoints': {
'analysis': True,
Expand All @@ -44,11 +37,6 @@
'database': 'mongo'
}
datasets={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
'singleEntryUrl': True,
'endpoints': {
'analysis': True,
Expand All @@ -62,7 +50,6 @@
}
g_variants={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
Expand All @@ -78,7 +65,6 @@
}
individuals={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
Expand All @@ -94,7 +80,6 @@
}
runs={
'granularity': {
'boolean': True,
'count': True,
'record': True
},
Expand Down

0 comments on commit eeabc63

Please sign in to comment.