Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit 2026232

Browse files
authored
Merge pull request #129 from CSCfi/feature/ga4gh
Update for GA4GH Service-info
2 parents c5f0727 + c32f766 commit 2026232

10 files changed

Lines changed: 54 additions & 15 deletions

File tree

beacon_api/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
__createtime__ = CONFIG_INFO.createtime
2727
__updatetime__ = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ') # Every restart of the application means an update to it
2828

29-
3029
__org_id__ = CONFIG_INFO.org_id
3130
__org_name__ = CONFIG_INFO.org_name
3231
__org_description__ = CONFIG_INFO.org_description
@@ -37,3 +36,7 @@
3736
__org_info__ = {'orgInfo': CONFIG_INFO.org_info}
3837

3938
__sample_queries__ = SAMPLE_QUERIES
39+
40+
# GA4GH Discovery
41+
__service_type__ = f'{CONFIG_INFO.service_type}:{__apiVersion__}'
42+
__service_env__ = CONFIG_INFO.environment

beacon_api/api/info.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .. import __apiVersion__, __title__, __version__, __description__, __url__, __alturl__, __handover_beacon__
1010
from .. import __createtime__, __updatetime__, __org_id__, __org_name__, __org_description__
1111
from .. import __org_address__, __org_logoUrl__, __org_welcomeUrl__, __org_info__, __org_contactUrl__
12-
from .. import __sample_queries__, __handover_drs__, __docs_url__
12+
from .. import __sample_queries__, __handover_drs__, __docs_url__, __service_type__, __service_env__
1313
from ..utils.data_query import fetch_dataset_metadata
1414
from ..extensions.handover import make_handover
1515
from aiocache import cached
@@ -26,13 +26,18 @@ async def ga4gh_info(host):
2626
# TO DO implement some fallback mechanism for ID
2727
'id': '.'.join(reversed(host.split('.'))),
2828
'name': __title__,
29-
"type": "urn:ga4gh:beacon",
29+
"type": __service_type__,
3030
'description': __description__,
31-
'documentationUrl': __docs_url__,
32-
"organization": __org_id__,
31+
"organization": {
32+
"name": __org_name__,
33+
"url": __org_welcomeUrl__,
34+
},
3335
'contactUrl': __org_contactUrl__,
34-
'version': __version__,
35-
"extension": {}
36+
'documentationUrl': __docs_url__,
37+
'createdAt': __createtime__,
38+
'updatedAt': __updatetime__,
39+
'environment': __service_env__,
40+
'version': __version__
3641
}
3742
return beacon_info
3843

beacon_api/conf/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def parse_config_file(path):
3333
'url': config.get('beacon_api_info', 'url'),
3434
'alturl': config.get('beacon_api_info', 'alturl'),
3535
'createtime': config.get('beacon_api_info', 'createtime'),
36+
'service_type': config.get('beacon_api_info', 'service_type'),
37+
'environment': config.get('beacon_api_info', 'environment'),
3638
'org_id': config.get('organisation_info', 'org_id'),
3739
'org_name': config.get('organisation_info', 'org_name'),
3840
'org_description': config.get('organisation_info', 'org_description'),

beacon_api/conf/config.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
title=GA4GHBeacon at CSC
88

99
# Version of the Beacon implementation
10-
version=1.4.0
10+
version=1.4.1
1111

1212
# Author of this software
1313
author=CSC developers
@@ -41,6 +41,13 @@ alturl=
4141
# Datetime when this Beacon was created
4242
createtime=2018-07-25T00:00:00Z
4343

44+
# GA4GH Discovery type `groupId` and `artifactId`, joined in /service-info with apiVersion
45+
# See https://github.com/ga4gh-discovery/ga4gh-service-registry for more information and possible values
46+
service_type=org.ga4gh:beacon
47+
48+
# GA4GH Discovery server environment, possible values: prod, dev, test
49+
environment=prod
50+
4451

4552
[organisation_info]
4653
# Globally unique identifier for organisation that hosts this Beacon service

deploy/test/auth_test.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ alturl=https://ega-archive.org/
4040
# Datetime when this Beacon was created
4141
createtime=2018-07-25T00:00:00Z
4242

43+
# GA4GH Discovery type `groupId` and `artifactId`, joined in /service-info with apiVersion
44+
# See https://github.com/ga4gh-discovery/ga4gh-service-registry for more information and possible values
45+
service_type=org.ga4gh:beacon
46+
47+
# GA4GH Discovery server environment, possible values: prod, dev, test
48+
environment=prod
49+
4350

4451
[handover_info]
4552
# The base url for all handovers

deploy/test/integ_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,6 @@ async def test_32():
703703
data = await resp.json()
704704
# GA4GH Discovery Service-Info is small and its length should be between 3 and 6, when the Beacon info is very long
705705
# https://github.com/ga4gh-discovery/service-info/blob/develop/service-info.yaml
706-
assert 5 <= len(data) <= 9, 'Service info size error' # ga4gh service-info has 5 required keys and at most 9 with optionals
707-
assert data['type'] == 'urn:ga4gh:beacon', 'Service type error' # a new key used in beacon network
706+
assert len(data) >= 5, 'Service info size error' # ga4gh service-info has 5 required keys, and option to add custom keys
707+
assert data['type'].startswith('org.ga4gh:beacon'), 'Service type error' # a new key used in beacon network
708708
assert resp.status == 200, 'HTTP Status code error'

docs/example.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,18 @@ Example Response:
115115
{
116116
"id": "localhost:5050",
117117
"name": "GA4GHBeacon at CSC",
118+
"type": "org.ga4gh:beacon:1.1.0",
118119
"description": "Beacon API Web Server based on the GA4GH Beacon API",
119-
"documentationUrl": "https://beacon-python.readthedocs.io/en/latest/",
120+
"organization": {
121+
"name": "CSC - IT Center for Science",
122+
"url": "https://www.csc.fi/"
123+
},
120124
"contactUrl": "https://www.csc.fi/contact-info",
121-
"version": "1.4.0"
125+
"documentationUrl": "https://beacon-network.readthedocs.io/en/latest/",
126+
"createdAt": "2019-09-04T12:00:00Z",
127+
"updatedAt": "2019-09-05T05:55:18Z",
128+
"environment": "prod",
129+
"version": "1.4.1"
122130
}
123131
124132
Query Endpoint

docs/instructions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pointing to the location of the file using `CONFIG_FILE` environment variable.
6969

7070
.. literalinclude:: /../beacon_api/conf/config.ini
7171
:language: python
72-
:lines: 1-68
72+
:lines: 1-75
7373

7474
.. _oauth2:
7575

@@ -81,7 +81,7 @@ The configuration variables reside in the same `CONFIG_FILE` as described above
8181

8282
.. literalinclude:: /../beacon_api/conf/config.ini
8383
:language: python
84-
:lines: 90-116
84+
:lines: 97-123
8585

8686
* ``server`` should point to an API that returns a public key, which can be used to validate the received JWTBearer token.
8787
* ``issuers`` is a string of comma separated values, e.g. `one,two,three` without spaces. The issuers string should contain

docs/optionals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The handover protocol can be configured in ``config.ini`` as follows:
1717

1818
.. literalinclude:: /../beacon_api/conf/config.ini
1919
:language: python
20-
:lines: 71-87
20+
:lines: 78-94
2121

2222
.. note:: Handover protocol is disabled by default, as shown by the commented out ``drs`` variable. This variable should point
2323
to the server, which serves the additional data. To enable the handover protocol, uncomment the ``drs`` variable.

tests/test.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ alturl=https://ega-archive.org/
4040
# Datetime when this Beacon was created
4141
createtime=2018-07-25T00:00:00Z
4242

43+
# GA4GH Discovery type `groupId` and `artifactId`, joined in /service-info with apiVersion
44+
# See https://github.com/ga4gh-discovery/ga4gh-service-registry for more information and possible values
45+
service_type=org.ga4gh:beacon
46+
47+
# GA4GH Discovery server environment, possible values: prod, dev, test
48+
environment=test
49+
4350

4451
[handover_info]
4552
# The base url for all handovers

0 commit comments

Comments
 (0)