Skip to content

Commit 76efd13

Browse files
authored
Endpoint specification for model/submit
2 parents fab8300 + aa48453 commit 76efd13

File tree

4 files changed

+145
-44
lines changed

4 files changed

+145
-44
lines changed

api/openapi/api.yaml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ paths:
6161
required: true
6262
operationId: api.routes.get_manifest_route
6363
responses:
64-
'201':
64+
"201":
6565
description: Googlesheet link created
6666
content:
6767
application/json:
@@ -103,7 +103,7 @@ paths:
103103
required: true
104104
operationId: api.routes.validate_manifest_route
105105
responses:
106-
'200':
106+
"200":
107107
description: Manifest Validated
108108
content:
109109
application/json:
@@ -120,4 +120,52 @@ paths:
120120
type: string
121121
tags:
122122
- Model Operations
123-
123+
/model/submit:
124+
post:
125+
summary: Endpoint to facilitate manifest submission
126+
description: Endpoint to submit annotated manifest files
127+
requestBody:
128+
content:
129+
multipart/form-data:
130+
schema:
131+
type: object
132+
properties:
133+
csv_file:
134+
type: string
135+
format: binary
136+
parameters:
137+
- in: query
138+
name: schema_url
139+
schema:
140+
type: string
141+
description: Data Model URL
142+
example: >-
143+
https://raw.githubusercontent.com/Sage-Bionetworks/schematic/develop/tests/data/example.model.jsonld
144+
required: true
145+
- in: query
146+
name: data_type
147+
schema:
148+
type: string
149+
nullable: true
150+
description: Data Model Component
151+
example: Patient
152+
required: true
153+
- in: query
154+
name: dataset_id
155+
schema:
156+
type: string
157+
nullable: true
158+
description: Dataset SynID
159+
required: true
160+
operationId: api.routes.submit_manifest_route
161+
responses:
162+
"200":
163+
description: Manifest submitted
164+
content:
165+
application/json:
166+
schema:
167+
type: boolean
168+
"500":
169+
description: Check schematic log
170+
tags:
171+
- Model Operations

api/routes.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,36 @@ def validate_manifest_route(schema_url, data_type):
9696
)
9797

9898
return errors
99+
100+
101+
def submit_manifest_route(schema_url):
102+
# call config_handler()
103+
config_handler()
104+
105+
manifest_file = connexion.request.files["csv_file"]
106+
107+
# save contents of incoming manifest CSV file to temp file
108+
temp_dir = tempfile.gettempdir()
109+
# path to temp file where manifest file contents will be saved
110+
temp_path = os.path.join(temp_dir, manifest_file.filename)
111+
# save content
112+
manifest_file.save(temp_path)
113+
114+
# get path to temporary JSON-LD file
115+
jsonld = get_temp_jsonld(schema_url)
116+
117+
dataset_id = connexion.request.args["dataset_id"]
118+
119+
data_type = connexion.request.args["data_type"]
120+
121+
metadata_model = MetadataModel(
122+
inputMModelLocation=jsonld, inputMModelLocationType="local"
123+
)
124+
125+
success = metadata_model.submit_metadata_manifest(
126+
manifest_path=temp_path,
127+
dataset_id=dataset_id,
128+
validate_component=data_type,
129+
)
130+
131+
return success

poetry.lock

Lines changed: 59 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ rdflib = "^5.0.0"
5555
setuptools = "^52.0.0"
5656
synapseclient = "~2.3" # ~ (not ^) until Data Curator App supports OAuth tokens
5757
toml = "^0.10.2"
58-
Flask = "^2.0.1"
59-
connexion = "^2.7.0"
58+
Flask = "^1.1.4"
59+
connexion = {extras = ["swagger-ui"], version = "^2.8.0"}
6060

6161

6262
[tool.poetry.dev-dependencies]

0 commit comments

Comments
 (0)