Skip to content

Commit

Permalink
build: update ga4gh.vrsatile.pydantic version (#281)
Browse files Browse the repository at this point in the history
- Upgrades to pydantic v2
  • Loading branch information
korikuzma authored Oct 5, 2023
1 parent 6e7ae63 commit dca45f5
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 183 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fastapi = "*"
uvicorn = "*"
click = "*"
boto3 = "*"
"ga4gh.vrsatile.pydantic" = "~=0.0.12"
"ga4gh.vrsatile.pydantic" = "~=0.2.0"
"ga4gh.vrs" = "~=0.8.1"

[dev-packages]
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/generate_normalize_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_gjgf(result: UnmergedNormalizationService) -> Dict:
"metadata": {
"color": COLORS[i],
"hover": f"{match.concept_id}\n{match.symbol}\n<i>{match.label}</i>", # noqa: E501
"click": f"<p color='black'>{json.dumps(match.dict(), indent=2)}</p>", # noqa: E501
"click": f"<p color='black'>{json.dumps(match.model_dump(), indent=2)}</p>", # noqa: E501
}
}
for xref in match.xrefs:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"uvicorn",
"click",
"boto3",
"ga4gh.vrsatile.pydantic~=0.0.12",
"ga4gh.vrsatile.pydantic~=0.2.0",
"ga4gh.vrs~=0.8.1"
]
dynamic = ["version"]
Expand Down
2 changes: 1 addition & 1 deletion src/gene/database/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def add_source_metadata(self, src_name: SourceName, metadata: SourceMeta) -> Non
:raise DatabaseWriteException: if write fails
"""
src_name_value = src_name.value
metadata_item = metadata.dict()
metadata_item = metadata.model_dump()
metadata_item["src_name"] = src_name_value
metadata_item["label_and_type"] = f"{str(src_name_value).lower()}##source"
metadata_item["concept_id"] = f"source:{str(src_name_value).lower()}"
Expand Down
2 changes: 1 addition & 1 deletion src/gene/etl/vrs_locations/chromosome_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_location(self, location: Dict, gene: Dict) -> Optional[Dict]:
try:
chr_location = GeneChromosomeLocation(
chr=location["chr"], start=location["start"], end=location["end"]
).dict()
).model_dump()
except ValidationError as e:
logger.info(f"{e} for {gene['symbol']}")
else:
Expand Down
2 changes: 1 addition & 1 deletion src/gene/etl/vrs_locations/sequence_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def add_location(
start=gene.start - 1, # type: ignore
end=gene.end, # type: ignore
sequence_id=sequence_id,
).dict() # type: ignore
).model_dump() # type: ignore
else:
logger.info(
f"{params['concept_id']} has invalid interval:"
Expand Down
3 changes: 3 additions & 0 deletions src/gene/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
summary=read_query_summary,
response_description=response_description,
response_model=SearchService,
response_model_exclude_none=True,
description=search_description,
tags=["Query"],
)
Expand Down Expand Up @@ -99,6 +100,7 @@ def search(
summary=normalize_summary,
response_description=normalize_response_descr,
response_model=NormalizeService,
response_model_exclude_none=True,
description=normalize_descr,
tags=["Query"],
)
Expand Down Expand Up @@ -134,6 +136,7 @@ def normalize(q: str = Query(..., description=normalize_q_descr)) -> NormalizeSe
operation_id="getUnmergedRecords",
response_description=unmerged_response_descr,
response_model=UnmergedNormalizationService,
response_model_exclude_none=True,
description=unmerged_normalize_description,
tags=["Query"],
)
Expand Down
4 changes: 3 additions & 1 deletion src/gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
RefType,
SearchService,
ServiceMeta,
SourceMeta,
SourceName,
SourcePriority,
UnmergedNormalizationService,
Expand Down Expand Up @@ -370,7 +371,8 @@ def _add_merged_meta(self, response: NormalizeService) -> NormalizeService:
prefix = concept_id.split(":")[0]
src_name = PREFIX_LOOKUP[prefix.lower()]
if src_name not in sources_meta:
sources_meta[src_name] = self.db.get_source_metadata(src_name)
_sources_meta = self.db.get_source_metadata(src_name)
sources_meta[SourceName(src_name)] = SourceMeta(**_sources_meta)
response.source_meta_ = sources_meta
return response

Expand Down
Loading

0 comments on commit dca45f5

Please sign in to comment.