Skip to content

Commit 89047f4

Browse files
committed
Implemented concept listing and lookup in concept controller
1 parent a90a814 commit 89047f4

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

REST-Server/openapi_server/controllers/concepts_controller.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
from openapi_server.models.concept import Concept # noqa: E501
55
from openapi_server import util
66

7+
import configparser
8+
import redis
79

8-
def concept_mapping_concept_get(concept): # noqa: E501
10+
config = configparser.ConfigParser()
11+
config.read('config.ini')
12+
13+
r = redis.Redis(host=config['REDIS']['HOST'],
14+
port=config['REDIS']['PORT'],
15+
db=config['REDIS']['DB'])
16+
17+
def concept_mapping_concept_get(Concept): # noqa: E501
918
"""Get an array of models related to a concept.
1019
1120
Submit a concept name and receive an array of model related to that concept. # noqa: E501
@@ -15,7 +24,8 @@ def concept_mapping_concept_get(concept): # noqa: E501
1524
1625
:rtype: Concept
1726
"""
18-
return 'do some magic!'
27+
models = [m.decode('utf-8') for m in list(r.smembers(Concept))]
28+
return models
1929

2030

2131
def list_concepts_get(): # noqa: E501
@@ -26,4 +36,5 @@ def list_concepts_get(): # noqa: E501
2636
2737
:rtype: List[str]
2838
"""
29-
return 'do some magic!'
39+
concepts = [c.decode('utf-8') for c in list(r.smembers('concepts'))]
40+
return concepts

REST-Server/openapi_server/openapi/openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ paths:
189189
content:
190190
application/json:
191191
schema:
192-
$ref: '#/components/schemas/Concept'
192+
$ref: '#/components/schemas/ConceptMapping'
193193
description: SUCCESS
194194
summary: Get an array of models related to a concept.
195195
tags:

model_service_api.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ paths:
173173
content:
174174
application/json:
175175
schema:
176-
$ref: '#/components/schemas/Concept'
176+
$ref: '#/components/schemas/ConceptMapping'
177177
/run_model:
178178
post:
179179
tags:

0 commit comments

Comments
 (0)