Skip to content

Commit

Permalink
Merge pull request #47 from bento-platform/features/service-info-addi…
Browse files Browse the repository at this point in the history
…tions

Features/service info additions
  • Loading branch information
gsfk authored Jul 31, 2023
2 parents dc29f11 + e51dc4d commit 758febd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 6 additions & 2 deletions bento_beacon/config_files/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ class Config:
"info": "record"
}

BENTO_DOMAIN = os.environ.get("BENTOV2_DOMAIN")
BEACON_BASE_URL = os.environ.get("BEACON_BASE_URL")
BENTO_PUBLIC_URL = os.environ.get("BENTOV2_PUBLIC_URL")

# reverse domain id
BEACON_ID = ".".join(reversed(os.environ.get("BENTOV2_DOMAIN").split("."))) + ".beacon"
BEACON_ID = ".".join(reversed(BENTO_DOMAIN.split("."))) + ".beacon"

BEACON_NAME = os.environ.get("BENTO_PUBLIC_CLIENT_NAME", "BENTO") + " Beacon"
BEACON_NAME = os.environ.get("BENTO_PUBLIC_CLIENT_NAME", "Bento") + " Beacon"
BEACON_UI_ENABLED = os.environ.get("BENTO_BEACON_UI_ENABLED").strip().lower() in ('true', '1', 't')
BEACON_UI_URL = BENTO_PUBLIC_URL + "/#/en/beacon"

ENTRY_TYPES_DETAILS = {
"biosamples": {
Expand Down
24 changes: 22 additions & 2 deletions bento_beacon/endpoints/info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from copy import deepcopy
from flask import Blueprint, current_app
from ..utils.beacon_response import beacon_info_response
from ..utils.katsu_utils import get_filtering_terms, get_filtering_term_resources, katsu_total_individuals_count, katsu_get
from ..utils.katsu_utils import (
get_filtering_terms,
get_filtering_term_resources,
katsu_total_individuals_count,
katsu_get,
katsu_datasets
)
from ..utils.gohan_utils import gohan_counts_for_overview


Expand Down Expand Up @@ -89,10 +96,23 @@ def get_experiment_schema():
# these return the appropriate response but also save as a side effect

def build_service_info():
service_info = current_app.config["BEACON_CONFIG"].get("serviceInfo")
service_info = deepcopy(current_app.config["BEACON_CONFIG"].get("serviceInfo"))
service_info["environment"] = "dev" if current_app.config["DEBUG"] else "prod"
service_info["id"] = current_app.config["BEACON_ID"]
service_info["name"] = current_app.config["BEACON_NAME"]

# retrieve dataset description from DATS
# may be multiple datasets, so collect all descriptions into one string
# for custom description, add a "description" field to service info in beacon_config.json
k_datasets = katsu_datasets()
description = " ".join([d.get("description") for d in k_datasets if "description" in d])
if description and service_info.get("description") is None:
service_info["description"] = description

# url for beacon ui
if current_app.config["BEACON_UI_ENABLED"]:
service_info["welcomeUrl"] = current_app.config["BEACON_UI_URL"]

current_app.config["SERVICE_INFO"] = service_info
return service_info

Expand Down

0 comments on commit 758febd

Please sign in to comment.