Skip to content

Commit

Permalink
Merge pull request #9 from bento-platform/update-deps
Browse files Browse the repository at this point in the history
Update dependencies & service-info email
  • Loading branch information
davidlougheed authored Jan 7, 2023
2 parents 0e25caf + e5592d8 commit 5ee2011
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 496 deletions.
3 changes: 2 additions & 1 deletion bento_service_registry/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from bento_lib.types import GA4GHServiceType
from bento_service_registry import __version__

__all__ = [
Expand All @@ -12,7 +13,7 @@

# For exact implementations, this should be org.ga4gh/service-registry/1.0.0.
# In our case, most of our services diverge or will at some point, so use ca.c3g.bento as the group.
SERVICE_TYPE: dict[str, str] = {
SERVICE_TYPE: GA4GHServiceType = {
"group": "ca.c3g.bento",
"artifact": SERVICE_ARTIFACT,
"version": __version__,
Expand Down
19 changes: 9 additions & 10 deletions bento_service_registry/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys

from bento_lib.responses.quart_errors import quart_not_found_error
from bento_lib.types import GA4GHServiceInfo
from bento_service_registry import __version__
from datetime import datetime
from json.decoder import JSONDecodeError
Expand Down Expand Up @@ -130,9 +131,9 @@ async def service_types():
return json.jsonify(list(types_by_key.values()))


async def get_service_info() -> dict:
async def get_service_info() -> GA4GHServiceInfo:
service_id = current_app.config["SERVICE_ID"]
service_info_dict = {
service_info_dict: GA4GHServiceInfo = {
"id": service_id,
"name": SERVICE_NAME, # TODO: Should be globally unique?
"type": SERVICE_TYPE,
Expand All @@ -141,7 +142,7 @@ async def get_service_info() -> dict:
"name": "C3G",
"url": "https://www.computationalgenomics.ca"
},
"contactUrl": "mailto:[email protected].ca",
"contactUrl": "mailto:info@c3g.ca",
"version": __version__,
"url": get_service_url(SERVICE_ARTIFACT),
"environment": "prod"
Expand All @@ -150,10 +151,8 @@ async def get_service_info() -> dict:
if not current_app.config["BENTO_DEBUG"]:
return service_info_dict

info = {
**service_info_dict,
"environment": "dev"
}
service_info_dict["environment"] = "dev"

try:
git_proc = await asyncio.create_subprocess_exec(
"git", "describe", "--tags", "--abbrev=0",
Expand All @@ -162,7 +161,7 @@ async def get_service_info() -> dict:
)
res_tag, _ = await git_proc.communicate()
if res_tag:
info["git_tag"] = res_tag.decode().rstrip()
service_info_dict["git_tag"] = res_tag.decode().rstrip()

git_proc = await asyncio.create_subprocess_exec(
"git", "branch", "--show-current",
Expand All @@ -171,13 +170,13 @@ async def get_service_info() -> dict:
)
res_branch, _ = await git_proc.communicate()
if res_branch:
info["git_branch"] = res_branch.decode().rstrip()
service_info_dict["git_branch"] = res_branch.decode().rstrip()

except Exception as e:
except_name = type(e).__name__
print("Error in dev-mode retrieving git information", except_name)

return info # updated service info with the git info
return service_info_dict # updated service info with the git info


@service_registry.route("/service-info")
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export QUART_APP=bento_service_registry.app:application

if [ -z "${INTERNAL_PORT}" ]; then
# Set default internal port to 5000
INTERNAL_PORT=5000
export INTERNAL_PORT=5000
fi

python -m poetry install
Expand Down
Loading

0 comments on commit 5ee2011

Please sign in to comment.