Skip to content

Commit

Permalink
1.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaudis committed Mar 8, 2024
1 parent d15d810 commit 8095c4b
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 483 deletions.
3 changes: 2 additions & 1 deletion bycon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
}

read_service_definition_files(byc)
# updates `beacon_defaults`, `dataset_definitions` and `local_paths`
# 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)

Expand Down
40 changes: 12 additions & 28 deletions bycon/beaconServer/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,12 @@ def main():
################################################################################

def beacon():
# updates `beacon_defaults`, `dataset_definitions` and `local_paths`
# update_rootpars_from_local(LOC_PATH, byc)
# set_beacon_defaults(byc)

defs = BYC["beacon_defaults"]
s_a_s = defs.get("service_path_aliases", {})
r_w = defs.get("rewrites", {})
d_p_s = defs.get("data_pipeline_path_ids", [])

"""
The type of execution depends on the requested entity defined in `beacon_defaults`
which can either be one of the Beacon entities (also recognizing aliases)
in `beacon_defaults.service_path_aliases` or targets of a rewrite from
`beacon_defaults.rewrites`.
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 entity is determined from different potential inputs and overwritten
by the next one in the oreder, if existing:
by the next one in the order, if existing:
1. from the path (element after "beacon", e.g. `biosamples` from
`/beacon/biosamples/...`)
Expand All @@ -48,31 +38,25 @@ 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)
# args_update_form(byc)
prdbug(f'beacon.py - request_entity_path_id: {byc.get("request_entity_path_id")}')

e_p_id = BYC_PARS.get("request_entity_path_id", "___none___")
prdbug(f'beacon.py - form e_p_id: {e_p_id}')
if e_p_id in s_a_s or e_p_id in r_w:
if e_p_id in p_e_m:
byc.update({"request_entity_path_id": e_p_id})
r_p_id = byc.get("request_entity_path_id", "info")

prdbug(f'beacon.py - request_entity_path_id: {r_p_id}')

# check for rewrites
if r_p_id in r_w:
uri = environ.get('REQUEST_URI')
pat = re.compile( rf"^.+\/{r_p_id}\/?(.*?)$" )
if pat.match(uri):
stuff = pat.match(uri).group(1)
print_uri_rewrite_response(r_w[r_p_id], stuff)
e = p_e_m.get(r_p_id)
f = e_p_m.get(e)

f = s_a_s.get(r_p_id)
if not f:
pass
elif f in d_p_s:
elif e in d_p_e:
initialize_bycon_service(byc, f)
r = BeaconDataResponse(byc).resultsetResponse()
print_json_response(r)
Expand Down
7 changes: 4 additions & 3 deletions bycon/beaconServer/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def info():
initialize_bycon_service(byc, "info")
r = BeaconInfoResponse(byc)

defs = BYC["beacon_defaults"]
b_e_d = defs.get("entity_defaults", {})
b_e_d = BYC.get("entity_defaults", {})
info = b_e_d.get("info", {})
pgx_info = info.get("content", {})
beacon_info = object_instance_from_schema_name("beaconInfoResults", "")
Expand All @@ -38,9 +37,11 @@ def info():

# TODO: All the schemas really only here?
beacon_schemas = []
entry_type_responses = ["beaconCollectionsResponse", "beaconResultsetsResponse"]
for e_t, e_d in b_e_d.items():
b_s = e_d.get("beacon_schema", {})
if e_d.get("is_entry_type", True) is True:
r_s = e_d.get("response_schema", "___none___")
if r_s in entry_type_responses:
beacon_schemas.append(b_s)

response.update( { "returned_schemas": beacon_schemas } )
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 @@ -22,7 +22,7 @@ def main():

def service_info():
initialize_bycon_service(byc, "service_info")
b_e_d = BYC["beacon_defaults"].get("entity_defaults", {})
b_e_d = BYC.get("entity_defaults", {})
pgx_info = b_e_d.get("info", {})
c = pgx_info.get("content", {})
info = object_instance_from_schema_name("ga4gh-service-info-1-0-0-schema", "")
Expand Down
11 changes: 10 additions & 1 deletion bycon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
"ERRORS": [],
"WARNINGS": [],
"USER": "anonymous",
"beacon_defaults": {},
"beacon_defaults": {
"defaults": {
"default_dataset_id": "examplez",
"test_domains": ["localhost"]
},
},
"entity_defaults": {"info":{}},
"path_entry_type_mappings": {},
"entry_type_path_mappings": {},
"data_pipeline_entities": [],
"datatable_mappings": {}
}

Expand Down
15 changes: 8 additions & 7 deletions bycon/definitions/argument_definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ request_entity_path_id:
type: string
cmdFlags:
- --requestEntityPathId
description: required data entry point, equal to the first REST path element in Beacon
description: >-
data entry point, equal to the first REST path element in Beacon
requested_schema:
type: string
Expand Down Expand Up @@ -455,12 +456,12 @@ source:
- --source
description: some source label, e.g. `analyses`

query:
type: string
cmdFlags:
- -q
- --query
description: complete query string, e.g. `{"biosamples":{"external_references.id":"geo:GSE7428"}}`
# query:
# type: string
# cmdFlags:
# - -q
# - --query
# description: complete query string, e.g. `{"biosamples":{"external_references.id":"geo:GSE7428"}}`

delivery_keys:
type: array
Expand Down
219 changes: 0 additions & 219 deletions bycon/definitions/beacon_defaults.yaml

This file was deleted.

Loading

0 comments on commit 8095c4b

Please sign in to comment.