Skip to content

Commit

Permalink
fix: update ga4gh.vrs version + add back VRS type anno in models (#95)
Browse files Browse the repository at this point in the history
close #91
---------

Co-authored-by: Eugene Clark <[email protected]>
  • Loading branch information
korikuzma and ehclark authored Aug 26, 2024
1 parent 4cb87ae commit e4c112f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install_requires =
fastapi>=0.95.0
python-multipart
uvicorn
ga4gh.vrs[extras]~=2.0.0a5
ga4gh.vrs[extras]~=2.0.0a10
psycopg[binary]
snowflake-sqlalchemy~=1.5.1

Expand Down
10 changes: 5 additions & 5 deletions src/anyvar/restapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_location_by_id(
)

if location:
return {"location": location.model_dump(exclude_none=True)}
return {"location": location}
else:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail=f"Location {location_id} not found"
Expand Down Expand Up @@ -147,7 +147,7 @@ def register_variation(
else:
if translated_variation:
v_id = av.put_object(translated_variation)
result["object"] = translated_variation.model_dump(exclude_none=True)
result["object"] = translated_variation
result["object_id"] = v_id
else:
result["messages"].append(f"Translation of {definition} failed.")
Expand Down Expand Up @@ -200,7 +200,7 @@ def register_vrs_object(

variation_object = variation_class_map[variation_type](**variation.dict())
v_id = av.put_object(variation_object)
result["object"] = variation_object.model_dump(exclude_none=True)
result["object"] = variation_object
result["object_id"] = v_id
return result

Expand Down Expand Up @@ -286,7 +286,7 @@ def get_variation_by_id(
)

if variation:
return {"messages": [], "data": variation.model_dump(exclude_none=True)}
return {"messages": [], "data": variation}
else:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail=f"Variation {variation_id} not found"
Expand Down Expand Up @@ -341,7 +341,7 @@ def search_variations(
var_object = av.get_object(allele["id"], deref=True)
if not var_object:
continue
inline_alleles.append(var_object.model_dump(exclude_none=True))
inline_alleles.append(var_object)

return {"variations": inline_alleles}

Expand Down
10 changes: 5 additions & 5 deletions src/anyvar/restapi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def schema_extra(schema: Dict[str, Any], model: Type["InfoResponse"]) -> None:
class GetSequenceLocationResponse(BaseModel):
"""Describe response for the /locations/ endpoint"""

location: Optional[Dict]
location: Optional[models.SequenceLocation]


class RegisterVariationRequest(BaseModel):
Expand Down Expand Up @@ -78,7 +78,7 @@ class RegisterVariationResponse(BaseModel):
"""Describe response for the variation registry endpoint"""

messages: List[str]
object: Optional[Dict]
object: Optional[models.Variation]
object_id: Optional[str]

class Config:
Expand Down Expand Up @@ -116,15 +116,15 @@ class RegisterVrsVariationResponse(BaseModel):
"""Describe response for VRS object registration endpoint"""

messages: List[str]
object: Optional[Dict]
object: Optional[models.Variation]
object_id: Optional[str]


class GetVariationResponse(BaseModel):
"""Describe response for the /variation get endpoint"""

messages: List[StrictStr]
data: Dict
data: models.Variation

class Config:
"""Configure GetVariationResponse class"""
Expand Down Expand Up @@ -161,7 +161,7 @@ def schema_extra(schema: Dict[str, Any], model: Type["GetVariationResponse"]) ->
class SearchResponse(BaseModel):
"""Describe response for the /search endpoint"""

variations: List[Dict]
variations: List[models.Variation]


class VariationStatisticType(str, Enum):
Expand Down

0 comments on commit e4c112f

Please sign in to comment.