Skip to content

Commit

Permalink
Merge pull request #111 from monarch-initiative/pydantic-v2
Browse files Browse the repository at this point in the history
Update to Pydantic v2
  • Loading branch information
glass-ships authored Nov 10, 2023
2 parents 718d045 + c62f2a4 commit eb4a332
Show file tree
Hide file tree
Showing 18 changed files with 20,317 additions and 647 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
# run pytest
#----------------------------------------------
- name: Run tests
run: poetry run pytest tests
run: poetry run pytest tests
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Default output / Generated / Unpacked data files
output/
tests/resources/source-files/string.tsv*

.ruff_cache

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re
import uuid

from biolink.pydanticmodel import PairwiseGeneToGeneInteraction, Protein
# from biolink.pydanticmodel_v2 import PairwiseGeneToGeneInteraction, Protein
from koza.model.biolink.pydanticmodel_v2 import PairwiseGeneToGeneInteraction, Protein

from koza.cli_runner import get_koza_app

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import uuid

from biolink.pydanticmodel import Gene, PairwiseGeneToGeneInteraction
# from biolink.pydanticmodel_v2 import Gene, PairwiseGeneToGeneInteraction
from koza.model.biolink.pydanticmodel_v2 import Gene, PairwiseGeneToGeneInteraction

from koza.cli_runner import get_koza_app

Expand Down
3 changes: 2 additions & 1 deletion examples/string-w-map/map-protein-links-detailed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import uuid

from biolink.pydanticmodel import Gene, PairwiseGeneToGeneInteraction
# from biolink.pydanticmodel_v2 import Gene, PairwiseGeneToGeneInteraction
from koza.model.biolink.pydanticmodel_v2 import Gene, PairwiseGeneToGeneInteraction

from koza.cli_runner import get_koza_app

Expand Down
3 changes: 2 additions & 1 deletion examples/string/protein-links-detailed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re
import uuid

from biolink.pydanticmodel import PairwiseGeneToGeneInteraction, Protein
# from biolink.pydanticmodel_v2 import PairwiseGeneToGeneInteraction, Protein
from koza.model.biolink.pydanticmodel_v2 import PairwiseGeneToGeneInteraction, Protein

from koza.cli_runner import get_koza_app

Expand Down
1,041 changes: 500 additions & 541 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "koza"
version = "0.4.0"
version = "0.5.0"
description = "Data transformation framework for LinkML data models"
authors = [
"The Monarch Initiative <[email protected]>",
Expand All @@ -16,8 +16,8 @@ packages = [

[tool.poetry.dependencies]
python = "^3.8"
linkml-validator = ">=0.4.4"
pydantic = "^1.10"
linkml = ">=1.6.2"
pydantic = "^2.4"
pyyaml = ">=5.0.0"
requests = "^2.24.0"
ordered-set = ">=4.1.0"
Expand All @@ -30,7 +30,7 @@ sssom = "^0.3.41"
black = "^23.10.0"
ruff = "*"
pytest = ">=6.0.0"
biolink-model = ">=3.0.1"
biolink-model = ">=3.0.1" # ">=3.5.5"
dask = ">=2022.5.2"
mkdocs = ">=1.4.2"
mkdocs-material = ">=9.1.16"
Expand Down
13 changes: 8 additions & 5 deletions src/koza/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict, Union
import yaml

from linkml_validator.validator import Validator
# from linkml_validator.validator import Validator
from pydantic.error_wrappers import ValidationError

from koza.converter.kgx_converter import KGXConverter
Expand Down Expand Up @@ -43,7 +43,7 @@ def __init__(
self.logger = logger

if schema:
self.validator = Validator(schema=schema)
# self.validator = Validator(schema=schema)
self.converter = KGXConverter()

if source.config.depends_on is not None:
Expand Down Expand Up @@ -84,7 +84,8 @@ def process_sources(self):
is_first = True
transform_module = None

self.logger.info(f"Transforming source: {self.source.config.name}")
if self.logger:
self.logger.info(f"Transforming source: {self.source.config.name}")
if self.source.config.transform_mode == 'flat':
while True:
try:
Expand All @@ -94,11 +95,13 @@ def process_sources(self):
else:
importlib.reload(transform_module)
except MapItemException as mie:
self.logger.debug(f"{str(mie)} not found in map")
if self.logger:
self.logger.debug(f"{str(mie)} not found in map")
except NextRowException:
continue
except ValidationError as ve:
self.logger.error(f"Validation error while processing: {self.source.last_row}")
if self.logger:
self.logger.error(f"Validation error while processing: {self.source.last_row}")
raise ve
except StopIteration:
break
Expand Down
Loading

0 comments on commit eb4a332

Please sign in to comment.