Skip to content

Commit

Permalink
Merge pull request #84 from bento-platform/chore/update-deps
Browse files Browse the repository at this point in the history
chore: update bento_lib and lockfile dependencies
  • Loading branch information
davidlougheed authored Dec 8, 2023
2 parents 30642d1 + 8f69af4 commit 4fd3da3
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 215 deletions.
1 change: 1 addition & 0 deletions chord_drs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Config:
MINIO_PASSWORD: str | None = MINIO_PASSWORD
MINIO_BUCKET: str | None = os.environ.get("MINIO_BUCKET") if MINIO_URL else None
BENTO_DEBUG = os.environ.get("BENTO_DEBUG", os.environ.get("FLASK_DEBUG", "false")).strip().lower() in TRUTH_VALUES
BENTO_CONTAINER_LOCAL = os.environ.get("BENTO_CONTAINER_LOCAL", "false").strip().lower() in TRUTH_VALUES

# CORS
CORS_ORIGINS: list[str] | str = [x for x in os.environ.get("CORS_ORIGINS", "").split(";") if x] or "*"
Expand Down
59 changes: 21 additions & 38 deletions chord_drs/routes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import re
import urllib.parse
import os
import subprocess
import re
import tempfile
import urllib.parse

from asgiref.sync import async_to_sync
from bento_lib.auth.permissions import Permission, P_INGEST_DATA, P_QUERY_DATA, P_DOWNLOAD_DATA
from bento_lib.auth.resources import RESOURCE_EVERYTHING, build_resource
from bento_lib.service_info.constants import SERVICE_ORGANIZATION_C3G
from bento_lib.service_info.helpers import build_service_info
from flask import (
Blueprint,
Request,
Expand Down Expand Up @@ -216,42 +218,23 @@ def build_blob_json(drs_blob: DrsBlob, inside_container: bool = False) -> DRSObj
@authz_middleware.deco_public_endpoint
def service_info():
# Spec: https://github.com/ga4gh-discovery/ga4gh-service-info
info = {
"id": current_app.config["SERVICE_ID"],
"name": SERVICE_NAME,
"type": SERVICE_TYPE,
"description": "Data repository service (based on GA4GH's specs) for a Bento platform node.",
"organization": {
"name": "C3G",
"url": "https://www.computationalgenomics.ca"
},
"contactUrl": "mailto:[email protected]",
"version": __version__,
"environment": "prod",
"bento": {
"serviceKind": BENTO_SERVICE_KIND,
return jsonify(async_to_sync(build_service_info)(
{
"id": current_app.config["SERVICE_ID"],
"name": SERVICE_NAME,
"type": SERVICE_TYPE,
"description": "Data repository service (based on GA4GH's specs) for a Bento platform node.",
"organization": SERVICE_ORGANIZATION_C3G,
"contactUrl": "mailto:[email protected]",
"version": __version__,
"bento": {
"serviceKind": BENTO_SERVICE_KIND,
},
},
}

if not current_app.config["BENTO_DEBUG"]:
return jsonify(info)

info["environment"] = "dev"
try:
if res_tag := subprocess.check_output(["git", "describe", "--tags", "--abbrev=0"]):
res_tag_str = res_tag.decode().rstrip()
info["bento"]["gitTag"] = res_tag_str
if res_branch := subprocess.check_output(["git", "branch", "--show-current"]):
res_branch_str = res_branch.decode().strip()
info["bento"]["gitBranch"] = res_branch_str
if res_commit := subprocess.check_output(["git", "rev-parse", "HEAD"]):
info["bento"]["gitCommit"] = res_commit.decode().strip()

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

return jsonify(info)
debug=current_app.config["BENTO_DEBUG"],
local=current_app.config["BENTO_CONTAINER_LOCAL"],
logger=current_app.logger,
))


def get_drs_object(object_id: str) -> tuple[DrsBlob | DrsBundle | None, bool]:
Expand Down
3 changes: 3 additions & 0 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ RUN poetry config virtualenvs.create false && \
COPY entrypoint.bash .
COPY run.dev.bash .

# Tell the service that we're running a local development container
ENV BENTO_CONTAINER_LOCAL=true

# Don't copy any code in - the dev compose file will mount the repo

ENTRYPOINT ["/bin/bash", "/drs/entrypoint.bash"]
Expand Down
Loading

0 comments on commit 4fd3da3

Please sign in to comment.