Skip to content

Commit adb31a4

Browse files
committed
REST API endpoint for manifest submission
1 parent fab8300 commit adb31a4

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

api/openapi/api.yaml

Lines changed: 49 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,50 @@ 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+
tags:
169+
- 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

0 commit comments

Comments
 (0)