Skip to content

Commit fc8514a

Browse files
committed
docs: enhance score set create/patch endpoints with detailed OpenAPI schema for file uploads
1 parent e75c25f commit fc8514a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

src/mavedb/routers/score_sets.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,40 @@ async def create_score_set(
16911691
response_model_exclude_none=True,
16921692
responses={**BASE_400_RESPONSE, **ACCESS_CONTROL_ERROR_RESPONSES},
16931693
summary="Upload score and variant count files for a score set",
1694+
openapi_extra={
1695+
"requestBody": {
1696+
"content": {
1697+
"multipart/form-data": {
1698+
"schema": {
1699+
"type": "object",
1700+
"properties": {
1701+
"scores_file": {
1702+
"type": "string",
1703+
"format": "binary",
1704+
"description": "CSV file containing variant scores. This file is required, and should have at least one score column.",
1705+
},
1706+
"counts_file": {
1707+
"type": "string | null",
1708+
"format": "binary",
1709+
"description": "CSV file containing variant counts. If provided, this file should have the same index and variant columns as the scores file.",
1710+
},
1711+
"score_columns_metadata": {
1712+
"type": "string | null",
1713+
"format": "binary",
1714+
"description": "JSON file containing metadata for score columns. If provided, this file should have metadata for one or more score columns in the scores file. This JSON file should provide a dictionary mapping column names to metadata objects. Metadata objects should follow the DatasetColumnMetadata schema: `{'description': string, 'details': string}`.",
1715+
},
1716+
"count_columns_metadata": {
1717+
"type": "string | null",
1718+
"format": "binary",
1719+
"description": "JSON file containing metadata for count columns. If provided, this file should have metadata for one or more count columns in the counts file. This JSON file should provide a dictionary mapping column names to metadata objects. Metadata objects should follow the DatasetColumnMetadata schema: `{'description': string, 'details': string}`.",
1720+
},
1721+
},
1722+
}
1723+
},
1724+
},
1725+
"description": "Score files, to be uploaded as multipart form data. The `scores_file` is required, while the `counts_file`, `score_columns_metadata`, and `count_columns_metadata` are optional.",
1726+
}
1727+
},
16941728
)
16951729
async def upload_score_set_variant_data(
16961730
*,
@@ -1763,6 +1797,41 @@ async def upload_score_set_variant_data(
17631797
response_model_exclude_none=True,
17641798
responses={**BASE_400_RESPONSE, **ACCESS_CONTROL_ERROR_RESPONSES},
17651799
summary="Update score ranges / calibrations for a score set",
1800+
openapi_extra={
1801+
"requestBody": {
1802+
"content": {
1803+
"multipart/form-data": {
1804+
"schema": {
1805+
"type": "object",
1806+
"properties": {
1807+
**score_set.ScoreSetUpdateAllOptional.model_json_schema(by_alias=False)["properties"],
1808+
"scores_file": {
1809+
"type": "string | null",
1810+
"format": "binary",
1811+
"description": "CSV file containing variant scores. If provided, this file should have at least one score column.",
1812+
},
1813+
"counts_file": {
1814+
"type": "string | null",
1815+
"format": "binary",
1816+
"description": "CSV file containing variant counts. If provided, this file should have the same index and variant columns as the scores file.",
1817+
},
1818+
"score_columns_metadata": {
1819+
"type": "string | null",
1820+
"format": "binary",
1821+
"description": "JSON file containing metadata for score columns. If provided, this file should have metadata for one or more score columns in the scores file. This JSON file should provide a dictionary mapping column names to metadata objects. Metadata objects should follow the DatasetColumnMetadata schema: `{'description': string, 'details': string}`.",
1822+
},
1823+
"count_columns_metadata": {
1824+
"type": "string | null",
1825+
"format": "binary",
1826+
"description": "JSON file containing metadata for count columns. If provided, this file should have metadata for one or more count columns in the counts file. This JSON file should provide a dictionary mapping column names to metadata objects. Metadata objects should follow the DatasetColumnMetadata schema: `{'description': string, 'details': string}`.",
1827+
},
1828+
},
1829+
}
1830+
},
1831+
},
1832+
"description": "Score set properties and score files, to be uploaded as multipart form data. All fields here are optional, and only those provided will be updated.",
1833+
}
1834+
},
17661835
)
17671836
async def update_score_set_with_variants(
17681837
*,
@@ -1780,6 +1849,13 @@ async def update_score_set_with_variants(
17801849
"""
17811850
logger.info(msg="Began score set with variants update.", extra=logging_context())
17821851

1852+
# TODO#629: Use `flexible_model_loader` utility here to support both form data and JSON body.
1853+
# See: https://github.com/VariantEffect/mavedb-api/pull/589/changes/d1641de7e4bee43e8a0c9f9283e022c5b56830ff
1854+
# Currently, only form data is supported but this would allow us to also support JSON bodies
1855+
# in cases where no files are being uploaded. My view is accepting score set calibration
1856+
# information via a single form field is also more straightforward than handling all the score
1857+
# set update fields as separate form fields and parsing them into an object. Doing so will also
1858+
# simplify the OpenAPI schema for this endpoint.
17831859
try:
17841860
# Get all form data from the request
17851861
form_data = await request.form()

0 commit comments

Comments
 (0)