Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename omics_processing endpoints to data_generation #1404

Open
wants to merge 2 commits into
base: berkeley-schema-migration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions nmdc_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,18 @@ async def get_study_image(study_id: str, db: Session = Depends(get_db)):
return StreamingResponse(BytesIO(image), media_type="image/jpeg")


# omics_processing
# data_generation
# Note the intermingling of the terms "data generation" and "omics processing."
# The Berkeley schema (NMDC schema v11) did away with the phrase "omics processing."
# As a result, public-facing uses of "omics processing" should be replaced with
# "data generation."
# Future work should go in to a more thorough conversion of omics process to data generation.
@router.post(
"/omics_processing/search",
"/data_generation/search",
response_model=query.OmicsProcessingSearchResponse,
tags=["omics_processing"],
name="Search for omics processings",
description="Faceted search of omics_processing data.",
tags=["data_generation"],
name="Search for data generations",
description="Faceted search of data_generation data.",
)
async def search_omics_processing(
query: query.SearchQuery = query.SearchQuery(),
Expand All @@ -428,19 +433,19 @@ async def search_omics_processing(


@router.post(
"/omics_processing/facet",
"/data_generation/facet",
response_model=query.FacetResponse,
tags=["omics_processing"],
tags=["data_generation"],
name="Get all values of an attribute",
)
async def facet_omics_processing(query: query.FacetQuery, db: Session = Depends(get_db)):
return crud.facet_omics_processing(db, query.attribute, query.conditions)


@router.post(
"/omics_processing/binned_facet",
"/data_generation/binned_facet",
response_model=query.BinnedFacetResponse,
tags=["omics_processing"],
tags=["data_generation"],
name="Get all values of a non-string attribute with binning",
)
async def binned_facet_omics_processing(
Expand All @@ -450,26 +455,26 @@ async def binned_facet_omics_processing(


@router.get(
"/omics_processing/{omics_processing_id}",
"/data_generation/{data_generation_id}",
response_model=schemas.OmicsProcessing,
tags=["omics_processing"],
tags=["data_generation"],
)
async def get_omics_processing(omics_processing_id: str, db: Session = Depends(get_db)):
db_omics_processing = crud.get_omics_processing(db, omics_processing_id)
async def get_omics_processing(data_generation_id: str, db: Session = Depends(get_db)):
db_omics_processing = crud.get_omics_processing(db, data_generation_id)
if db_omics_processing is None:
raise HTTPException(status_code=404, detail="OmicsProcessing not found")
return db_omics_processing


@router.get(
"/omics_processing/{omics_processing_id}/outputs",
"/data_generation/{data_generation_id}/outputs",
response_model=List[schemas.DataObject],
tags=["omics_processing"],
tags=["data_generation"],
)
async def list_omics_processing_data_objects(
omics_processing_id: str, db: Session = Depends(get_db)
data_generation_id: str, db: Session = Depends(get_db)
):
return crud.list_omics_processing_data_objects(db, omics_processing_id).all()
return crud.list_omics_processing_data_objects(db, data_generation_id).all()


# data object
Expand Down
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_get_environmental_aggregation(db: Session, client: TestClient):
@pytest.mark.parametrize(
"endpoint",
[
"omics_processing",
"data_generation",
],
)
def test_list_data_objects(db: Session, client: TestClient, endpoint: str):
Expand Down
10 changes: 6 additions & 4 deletions web/src/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ async function searchStudy(params: SearchParams) {
}

async function searchOmicsProcessing(params: SearchParams) {
return _search<OmicsProcessingResult>('omics_processing', params);
return _search<OmicsProcessingResult>('data_generation', params);
}

async function searchReadsQC(params: SearchParams) {
Expand Down Expand Up @@ -483,7 +483,7 @@ async function getFacetSummary(
field: string,
conditions: Condition[],
): Promise<FacetSummaryResponse[]> {
const path = type;
const path = type === 'omics_processing' ? 'data_generation' : type;
const { data } = await client.post<{ facets: Record<string, number> }>(`${path}/facet`, {
conditions, attribute: field,
});
Expand All @@ -504,7 +504,8 @@ async function getBinnedFacet<T = string | number>(
numBins: number,
resolution: 'day' | 'week' | 'month' | 'year' = 'month',
) {
const { data } = await client.post<BinResponse<T>>(`${table}/binned_facet`, {
const path = table === 'omics_processing' ? 'data_generation' : table;
const { data } = await client.post<BinResponse<T>>(`${path}/binned_facet`, {
attribute,
conditions,
resolution,
Expand Down Expand Up @@ -588,7 +589,8 @@ async function getDataObjectList(
'metaproteomic_analysis',
];
if (supportedTypes.indexOf(type) >= 0) {
const { data } = await client.get<DataObjectSearchResult[]>(`${type}/${parentId}/outputs`);
const path = type === 'omics_processing' ? 'data_generation' : type;
const { data } = await client.get<DataObjectSearchResult[]>(`${path}/${parentId}/outputs`);
return data;
}
return [];
Expand Down