Skip to content

Commit 757abd1

Browse files
authored
Merge pull request #1277 from Sage-Bionetworks/develop-version-endpoint-FDS-698
Add API endpoint that returns the current version of schematic
2 parents d9121aa + 730078a commit 757abd1

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

.github/workflows/docker_build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Checkout repository
2626
uses: actions/checkout@v2
2727

28+
- name: Set env variable for version tag
29+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
30+
2831
- name: Log in to the Container registry
2932
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
3033
with:
@@ -41,10 +44,14 @@ jobs:
4144
type=ref,event=branch
4245
type=ref,event=pr
4346
type=semver,pattern={{raw}}
47+
4448
- name: Build and push Docker image
4549
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
4650
with:
4751
file: schematic_api/Dockerfile
4852
push: true
4953
tags: ${{ steps.meta.outputs.tags }}
50-
labels: ${{ steps.meta.outputs.labels }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
build-args: |
56+
TAG=${{ env.RELEASE_VERSION }}
57+

schematic_api/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM tiangolo/uwsgi-nginx-flask:python3.10
22

3+
# add version tag as a build argument
4+
ARG TAG
5+
36
# the environment variables defined here are the default
47
# and can be overwritten by docker run -e VARIABLE = XX
58
# or can be overwritten by .env when using docker compose
@@ -15,7 +18,8 @@ ENV PYTHONFAULTHANDLER=1 \
1518
APP_DIR=/app/app \
1619
ROOT=/ \
1720
UWSGI_INI=/app/uwsgi.ini \
18-
NGINX_WORKER_PROCESSES=1
21+
NGINX_WORKER_PROCESSES=1 \
22+
VERSION=$TAG
1923

2024
# Note:
2125
# The starting number of uWSGI processes is controlled by the variable UWSGI_CHEAPER, by default set to 2.

schematic_api/api/openapi/api.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,4 +1262,22 @@ paths:
12621262
Family History,FamilyHistory,TBD,False,True,," If Diagnosis is ""Cancer"" then ""Family History"" is required",Patient
12631263
tags:
12641264
- Visualization Operations
1265+
1266+
/version:
1267+
get:
1268+
summary: Get the version of schematic currently being used
1269+
description: >-
1270+
Get the version of schematic that is currently deployed and being used
1271+
operationId: schematic_api.api.routes.get_schematic_version
1272+
responses:
1273+
"200":
1274+
description: Returns a JSON String containing the version of schematic.
1275+
content:
1276+
text/plain:
1277+
schema:
1278+
type: string
1279+
"500":
1280+
description: Schematic version was not able to be identified.
1281+
tags:
1282+
- Version
12651283

schematic_api/api/routes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,3 +815,14 @@ def get_nodes_display_names(schema_url: str, node_list: list[str]) -> list:
815815
node_display_names = gen.get_nodes_display_names(node_list, mm_graph)
816816
return node_display_names
817817

818+
def get_schematic_version() -> str:
819+
"""
820+
Return the current version of schematic
821+
"""
822+
if "VERSION" in os.environ:
823+
version = os.environ["VERSION"]
824+
else:
825+
raise NotImplementedError(
826+
"Using this endpoint to check the version of schematic is only supported when the API is running in a docker container."
827+
)
828+
return version

0 commit comments

Comments
 (0)