Skip to content

Commit

Permalink
Rebuild all templates (#303)
Browse files Browse the repository at this point in the history
Just in case any were still out of date re: Pydantic 2.
  • Loading branch information
caufieldjh authored Dec 22, 2023
2 parents 4355202 + 127faeb commit 327a7bc
Show file tree
Hide file tree
Showing 41 changed files with 1,745 additions and 451 deletions.
54 changes: 44 additions & 10 deletions src/ontogpt/templates/biological_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from datetime import datetime, date
from enum import Enum
from typing import List, Dict, Optional, Any, Union
from pydantic import BaseModel as BaseModel, Field
from pydantic import BaseModel as BaseModel, ConfigDict, Field, field_validator
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
Expand All @@ -13,13 +14,13 @@
metamodel_version = "None"
version = "None"

class ConfiguredBaseModel(BaseModel,
validate_assignment = True,
validate_default = True,
extra = 'forbid',
arbitrary_types_allowed = True,
use_enum_values = True):
pass
class ConfiguredBaseModel(BaseModel):
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra = 'forbid',
arbitrary_types_allowed=True,
use_enum_values = True)


class NullDataOptions(str, Enum):
Expand All @@ -38,6 +39,7 @@ class GeneMolecularActivityRelationship(ConfiguredBaseModel):
gene: Optional[str] = Field(None)
molecular_activity: Optional[str] = Field(None)



class ExtractionResult(ConfiguredBaseModel):
"""
Expand All @@ -51,12 +53,14 @@ class ExtractionResult(ConfiguredBaseModel):
extracted_object: Optional[Any] = Field(None, description="""The complex objects extracted from the text""")
named_entities: Optional[List[Any]] = Field(default_factory=list, description="""Named entities extracted from the text""")



class NamedEntity(ConfiguredBaseModel):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class BiologicalProcess(NamedEntity):

Expand All @@ -71,29 +75,41 @@ class BiologicalProcess(NamedEntity):
gene_activities: Optional[List[GeneMolecularActivityRelationship]] = Field(default_factory=list, description="""semicolon-separated list of gene to molecular activity relationships""")
id: str = Field(..., description="""A unique identifier for the named entity""")



class Gene(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class CellType(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class MolecularActivity(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class ChemicalEntity(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class CompoundExpression(ConfiguredBaseModel):

None



class Triple(CompoundExpression):
"""
Expand All @@ -106,18 +122,32 @@ class Triple(CompoundExpression):
subject_qualifier: Optional[str] = Field(None, description="""An optional qualifier or modifier for the subject of the statement, e.g. \"high dose\" or \"intravenously administered\"""")
object_qualifier: Optional[str] = Field(None, description="""An optional qualifier or modifier for the object of the statement, e.g. \"severe\" or \"with additional complications\"""")



class TextWithTriples(ConfiguredBaseModel):

"""
A text containing one or more relations of the Triple type.
"""
publication: Optional[Publication] = Field(None)
triples: Optional[List[Triple]] = Field(default_factory=list)



class TextWithEntity(ConfiguredBaseModel):
"""
A text containing one or more instances of a single type of entity.
"""
publication: Optional[Publication] = Field(None)
entities: Optional[List[str]] = Field(default_factory=list)



class RelationshipType(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class Publication(ConfiguredBaseModel):

Expand All @@ -127,13 +157,15 @@ class Publication(ConfiguredBaseModel):
combined_text: Optional[str] = Field(None)
full_text: Optional[str] = Field(None, description="""The full text of the publication""")



class AnnotatorResult(ConfiguredBaseModel):

subject_text: Optional[str] = Field(None)
object_id: Optional[str] = Field(None)
object_text: Optional[str] = Field(None)




# Model rebuild
Expand All @@ -143,12 +175,14 @@ class AnnotatorResult(ConfiguredBaseModel):
NamedEntity.model_rebuild()
BiologicalProcess.model_rebuild()
Gene.model_rebuild()
CellType.model_rebuild()
MolecularActivity.model_rebuild()
ChemicalEntity.model_rebuild()
CompoundExpression.model_rebuild()
Triple.model_rebuild()
TextWithTriples.model_rebuild()
TextWithEntity.model_rebuild()
RelationshipType.model_rebuild()
Publication.model_rebuild()
AnnotatorResult.model_rebuild()

45 changes: 35 additions & 10 deletions src/ontogpt/templates/biotic_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from datetime import datetime, date
from enum import Enum
from typing import List, Dict, Optional, Any, Union
from pydantic import BaseModel as BaseModel, Field
from pydantic import BaseModel as BaseModel, ConfigDict, Field, field_validator
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
Expand All @@ -13,13 +14,13 @@
metamodel_version = "None"
version = "None"

class ConfiguredBaseModel(BaseModel,
validate_assignment = True,
validate_default = True,
extra = 'forbid',
arbitrary_types_allowed = True,
use_enum_values = True):
pass
class ConfiguredBaseModel(BaseModel):
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra = 'forbid',
arbitrary_types_allowed=True,
use_enum_values = True)


class NullDataOptions(str, Enum):
Expand All @@ -37,13 +38,15 @@ class Container(ConfiguredBaseModel):

interactions: Optional[List[BioticInteraction]] = Field(default_factory=list)



class BioticInteraction(ConfiguredBaseModel):

source_taxon: Optional[str] = Field(None, description="""the taxon that is the subject of the interaction""")
target_taxon: Optional[str] = Field(None, description="""the taxon that is the object of the interaction""")
interaction_type: Optional[str] = Field(None, description="""the type of interaction""")



class ExtractionResult(ConfiguredBaseModel):
"""
Expand All @@ -57,29 +60,34 @@ class ExtractionResult(ConfiguredBaseModel):
extracted_object: Optional[Any] = Field(None, description="""The complex objects extracted from the text""")
named_entities: Optional[List[Any]] = Field(default_factory=list, description="""Named entities extracted from the text""")



class NamedEntity(ConfiguredBaseModel):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class Taxon(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class InteractionType(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class CompoundExpression(ConfiguredBaseModel):

None



class Triple(CompoundExpression):
"""
Expand All @@ -92,18 +100,32 @@ class Triple(CompoundExpression):
subject_qualifier: Optional[str] = Field(None, description="""An optional qualifier or modifier for the subject of the statement, e.g. \"high dose\" or \"intravenously administered\"""")
object_qualifier: Optional[str] = Field(None, description="""An optional qualifier or modifier for the object of the statement, e.g. \"severe\" or \"with additional complications\"""")



class TextWithTriples(ConfiguredBaseModel):

"""
A text containing one or more relations of the Triple type.
"""
publication: Optional[Publication] = Field(None)
triples: Optional[List[Triple]] = Field(default_factory=list)



class TextWithEntity(ConfiguredBaseModel):
"""
A text containing one or more instances of a single type of entity.
"""
publication: Optional[Publication] = Field(None)
entities: Optional[List[str]] = Field(default_factory=list)



class RelationshipType(NamedEntity):

id: str = Field(..., description="""A unique identifier for the named entity""")
label: Optional[str] = Field(None, description="""The label (name) of the named thing""")



class Publication(ConfiguredBaseModel):

Expand All @@ -113,13 +135,15 @@ class Publication(ConfiguredBaseModel):
combined_text: Optional[str] = Field(None)
full_text: Optional[str] = Field(None, description="""The full text of the publication""")



class AnnotatorResult(ConfiguredBaseModel):

subject_text: Optional[str] = Field(None)
object_id: Optional[str] = Field(None)
object_text: Optional[str] = Field(None)




# Model rebuild
Expand All @@ -133,7 +157,8 @@ class AnnotatorResult(ConfiguredBaseModel):
CompoundExpression.model_rebuild()
Triple.model_rebuild()
TextWithTriples.model_rebuild()
TextWithEntity.model_rebuild()
RelationshipType.model_rebuild()
Publication.model_rebuild()
AnnotatorResult.model_rebuild()

Loading

0 comments on commit 327a7bc

Please sign in to comment.