Skip to content

Commit

Permalink
force update after a loooong time
Browse files Browse the repository at this point in the history
... to 1.8.4
  • Loading branch information
mbaudis committed Jun 19, 2024
1 parent 82326e8 commit c7065aa
Show file tree
Hide file tree
Showing 63 changed files with 1,178 additions and 742 deletions.
17 changes: 7 additions & 10 deletions bycon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@
from service_utils import *
from variant_mapping import *

byc: object = {
"parsed_config_paths": []
}

read_service_definition_files(byc)
# updates `entity_defaults`, `dataset_definitions` and `local_paths`
update_rootpars_from_local(LOC_PATH, byc)
set_entity_mappings()
set_beacon_defaults(byc)
parse_arguments(byc)
read_service_definition_files()
update_rootpars_from_local()
rest_path_elements()
set_beacon_defaults()
parse_arguments()
set_entities()
initialize_bycon_service()

except Exception:
if not "local" in ENV:
Expand Down
44 changes: 14 additions & 30 deletions bycon/beaconServer/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def main():

def beacon():
"""
The type of execution depends on the requested entity defined in the
`path_entry_type_mappings` generated from `request_entity_path_id` (or aliases)
in `entity_defaults`.
The type of execution depends on the requested entity defined in the
`request_entity_path_id` (or aliases) in `entity_defaults`.
The entity is determined from different potential inputs and overwritten
by the next one in the order, if existing:
Expand All @@ -39,49 +38,34 @@ def beacon():
Fallback is `/info`.
"""

p_e_m = BYC.get("path_entry_type_mappings", {})
e_p_m = BYC.get("entry_type_path_mappings", {})
d_p_e = BYC.get("data_pipeline_entities", [])
byc.update({"request_path_root": "beacon"})
rest_path_elements(byc)

e_p_id = BYC_PARS.get("request_entity_path_id", "___none___")
if e_p_id in p_e_m:
byc.update({"request_entity_path_id": e_p_id})
rq_p_id = byc.get("request_entity_path_id", "info")
update_entity_ids_from_path(byc)
rp_p_id = byc.get("response_entity_path_id", rq_p_id)
prdbug(f'beacon.py - request_entity_path_id: {rq_p_id}')
prdbug(f'beacon.py - response_entity_path_id: {rp_p_id}')

# e = p_e_m.get(rq_p_id)
e = p_e_m.get(rp_p_id)
f = e_p_m.get(e)

if not f:
rq_id = BYC.get("request_entity_id", "info")
rq_p_id = BYC.get("request_entity_path_id", "info")
rp_id = BYC.get("response_entity_id")

if not rp_id:
pass
elif e in d_p_e:
initialize_bycon_service(byc, f)
r = BeaconDataResponse(byc).resultsetResponse()
elif rq_id in d_p_e:
r = BeaconDataResponse().resultsetResponse()
print_json_response(r)
elif f:
elif rq_p_id:
# dynamic package/function loading; e.g. `filtering_terms` loads
# `filtering_terms` from `filtering_terms.py`...
try:
mod = import_module(f)
serv = getattr(mod, f)
mod = import_module(rq_p_id)
serv = getattr(mod, rq_p_id)
serv()
exit()
except Exception as e:
print('Content-Type: text')
print('status:422')
print()
print('Service {} WTF error: {}'.format(f, e))
print(f'Service {rq_id} WTF error: {e}')

exit()

BYC["ERRORS"].append("No correct service path provided. Please refer to the documentation at http://docs.progenetix.org")
BeaconErrorResponse(byc).response(422)
BeaconErrorResponse().response(422)


################################################################################
Expand Down
6 changes: 3 additions & 3 deletions bycon/beaconServer/cohorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def main():
################################################################################

def cohorts():
initialize_bycon_service(byc, "cohorts")
r = BeaconDataResponse(byc).collectionsResponse()
print_json_response(r)
# initialize_bycon_service()
r = BeaconDataResponse()
print_json_response(r.collectionsResponse())


################################################################################
Expand Down
4 changes: 2 additions & 2 deletions bycon/beaconServer/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def main():
################################################################################

def configuration():
initialize_bycon_service(byc, "configuration")
r = BeaconInfoResponse(byc)
# initialize_bycon_service()
r = BeaconInfoResponse()
c_f = get_schema_file_path("beaconConfiguration")
c = load_yaml_empty_fallback(c_f)
print_json_response(r.populatedInfoResponse(c))
Expand Down
5 changes: 2 additions & 3 deletions bycon/beaconServer/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ def main():
except Exception:
print_text_response(traceback.format_exc(), 302)


################################################################################

def datasets():
initialize_bycon_service(byc, "datasets")
r = BeaconDataResponse(byc)
# initialize_bycon_service()
r = BeaconDataResponse()
print_json_response(r.collectionsResponse())


Expand Down
7 changes: 3 additions & 4 deletions bycon/beaconServer/entry_types.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ def main():
################################################################################

def entry_types():

initialize_bycon_service(byc, "entry_types")
r = BeaconInfoResponse(byc)
# initialize_bycon_service()
r = BeaconInfoResponse()
e_f = get_schema_file_path("beaconConfiguration")
e_t_s = load_yaml_empty_fallback( e_f )
e_t_s = load_yaml_empty_fallback(e_f)
print_json_response(r.populatedInfoResponse({"entry_types": e_t_s["entryTypes"] }))


Expand Down
4 changes: 2 additions & 2 deletions bycon/beaconServer/filtering_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def main():
################################################################################

def filtering_terms():
initialize_bycon_service(byc, "filtering_terms")
r = BeaconDataResponse(byc)
# initialize_bycon_service()
r = BeaconDataResponse()
print_json_response(r.filteringTermsResponse())


Expand Down
4 changes: 2 additions & 2 deletions bycon/beaconServer/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def main():
################################################################################

def info():
initialize_bycon_service(byc, "info")
r = BeaconInfoResponse(byc)
# initialize_bycon_service()
r = BeaconInfoResponse()

b_e_d = BYC.get("entity_defaults", {})
info = b_e_d.get("info", {})
Expand Down
4 changes: 2 additions & 2 deletions bycon/beaconServer/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def main():
################################################################################

def map():
initialize_bycon_service(byc, "map")
r = BeaconInfoResponse(byc)
# initialize_bycon_service()
r = BeaconInfoResponse()
m_f = get_schema_file_path("beaconMap")
beaconMap = load_yaml_empty_fallback( m_f )
print_json_response(r.populatedInfoResponse(beaconMap))
Expand Down
2 changes: 1 addition & 1 deletion bycon/beaconServer/service_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
################################################################################

def service_info():
initialize_bycon_service(byc, "service_info")
# initialize_bycon_service()
b_e_d = BYC.get("entity_defaults", {})
pgx_info = b_e_d.get("info", {})
c = pgx_info.get("content", {})
Expand Down
65 changes: 58 additions & 7 deletions bycon/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import inspect
from os import environ, path, pardir
from pymongo import MongoClient
import sys

pkg_path = path.dirname( path.abspath(__file__) )

Expand All @@ -14,8 +16,14 @@
LIB_PATH = path.join( pkg_path, "lib")

# path of the calling script is used to point to a local config directory
__caller_path = path.dirname(path.abspath((inspect.stack()[1])[1]))
LOC_PATH = path.join(__caller_path, "local")
# __caller_path = path.dirname(path.abspath((inspect.stack()[1])[1]))
__caller_path = path.dirname( path.abspath(sys.argv[0]))
LOC_PATH = path.join(__caller_path, pardir, "local")

REQUEST_PATH_ROOT = "beacon"

if "services" in LOC_PATH or "byconaut" in LOC_PATH:
REQUEST_PATH_ROOT = "services"

#------------------------------------------------------------------------------#
# Database settings
Expand All @@ -38,31 +46,74 @@
# to be modified during execution ##############################################
################################################################################

mongo_client = MongoClient(host=DB_MONGOHOST)
db_names = list(mongo_client.list_database_names())

BYC = {
"DEBUG_MODE": False,
"TEST_MODE": False,
"ERRORS": [],
"WARNINGS": [],
"USER": "anonymous",

"BYC_DATASET_IDS": [],
"DATABASE_NAMES": [x for x in db_names if x not in [HOUSEKEEPING_DB, SERVICES_DB, "admin", "config", "local"]],
"BYC_FILTERS": [],

"beacon_defaults": {
"defaults": {
"default_dataset_id": "examplez",
"test_domains": ["localhost"]
},
},

# ..._mappings / ..._definitions are generated from YAML files & should stay static

"argument_definitions": {},
"data_pipeline_entities": [],
"dataset_definitions": {},
"datatable_mappings": {},
"entity_defaults": {"info":{}},
"entry_type_path_mappings": {},
"filter_definitions": {},
"geoloc_definitions": {},
"handover_definitions": {},
"interval_definitions": {},
"path_entry_type_mappings": {},
"variant_request_definitions": {},
"variant_type_definitions": {},

"loc_mod_pars": [
"authorizations",
"dataset_definitions",
"local_paths",
"datatable_mappings",
"plot_defaults"
],

"authorizations": {},
"local_paths": {},
"plot_defaults": {},
"map_defaults": {},
"query_meta": {},
"service_config": {},

# -------------------------------------------------------------------------- #

"authorized_granularities": {},
"data_pipeline_entities": [],
"parsed_config_paths": [],
"request_entity_path_id": None,
"request_entity_id": None,
"response_entity_path_id": None,
"response_entity_id": None,
"response_entity": {},
"response_schema": "beaconInfoResponse",
"returned_granularity": "boolean",

"cytobands": [],
"cytolimits": {},
"genome_size": 0
"genome_size": 0,
"cytoband_intervals": {},
"genomic_intervals": {},
"genomic_interval_count": 0

}

Expand All @@ -71,7 +122,7 @@
# provifding default values
BYC_PARS = {}

# an object to make global, pre-processed variant parameters accessible
# objects to make global, pre-processed variant parameters accessible
BYC_VARGS = {}

# default authorization levels; a local `authorizations.yaml` file can add to
Expand Down
Loading

0 comments on commit c7065aa

Please sign in to comment.