Skip to content

Commit

Permalink
Fourth pass at type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
caufieldjh committed Sep 14, 2023
1 parent 2f44181 commit 1215385
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/ontogpt/engines/enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class EnrichmentPayload(BaseModel):
summary: str = ""
"""The summary of the gene set generated by the LLM."""

term_strings: List[str] = []
term_strings: List[str] = [""]
"""The raw term labels parsed from the LLM completion payload"""

term_ids: List[str] = []
term_ids: List[str] = [""]
"""The normalized terms"""

ontological_synopsis: bool = None
Expand All @@ -74,7 +74,7 @@ class EnrichmentPayload(BaseModel):
annotations: bool = None
"""True if the gene descriptions used the annotations (vs latent KB)"""

response_token_length: int = None
response_token_length: int = 0
"""The number of tokens in the response text"""

model: str = ""
Expand Down
10 changes: 5 additions & 5 deletions src/ontogpt/engines/halo_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@


class StructuredPrompt(pydantic.BaseModel):
header: str = None
body: str = None
main_prompt: str = None
header: str = ""
body: str = ""
main_prompt: str = ""

@property
def text(self) -> str:
Expand All @@ -58,8 +58,8 @@ class HALOEngine(KnowledgeEngine):
traverse_slots: List[FIELD] = field(
default_factory=lambda: ["subtypes", "parts", "subclass_of", "part_of"]
)
fixed_slot_values: Dict[str, str] = None
adapter: OboGraphInterface = None
fixed_slot_values: Optional[Dict[str, str]] = None
adapter: OboGraphInterface
visited: Set[ELEMENT_NAME] = field(default_factory=lambda: set())
candidates: List[ELEMENT_NAME] = None
always_extend: bool = False
Expand Down
2 changes: 1 addition & 1 deletion src/ontogpt/engines/hfhub_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _raw_extract(self, text, cls: ClassDefinition = None, object: OBJECT = None)
return payload

def get_completion_prompt(
self, cls: ClassDefinition = None, text: str = None, object: OBJECT = None
self, cls: ClassDefinition = None, text: str = "", object: OBJECT = None
) -> str:
"""Get the prompt for the given template."""
if cls is None:
Expand Down
14 changes: 7 additions & 7 deletions src/ontogpt/engines/pheno_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@

class DiagnosisPrediction(BaseModel):
case_id: str
validated_disease_ids: List[str] = None
validated_disease_labels: List[str] = None
validated_mondo_disease_ids: List[str] = None
validated_mondo_disease_labels: List[str] = None
predicted_disease_ids: List[str] = None
predicted_disease_labels: List[str] = None
matching_disease_ids: List[str] = None
validated_disease_ids: Optional[List[str]] = None
validated_disease_labels: Optional[List[str]] = None
validated_mondo_disease_ids: Optional[List[str]] = None
validated_mondo_disease_labels: Optional[List[str]] = None
predicted_disease_ids: Optional[List[str]] = None
predicted_disease_labels: Optional[List[str]] = None
matching_disease_ids: Optional[List[str]] = None
rank: Optional[int] = None
model: Optional[str] = None
prompt: Optional[str] = None
Expand Down
14 changes: 7 additions & 7 deletions src/ontogpt/evaluation/ctd/eval_ctd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from dataclasses import dataclass
from pathlib import Path
from random import shuffle
from typing import Any, Dict, Iterable, List, Set, Tuple
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple

import yaml
from bioc import biocxml
Expand Down Expand Up @@ -59,12 +59,12 @@ class PredictionRE(BaseModel):
test_object: TextWithTriples = None
"""source of truth to evaluate against"""

true_positives: List[Tuple] = None
num_true_positives: int = None
false_positives: List[Tuple] = None
num_false_positives: int = None
false_negatives: List[Tuple] = None
num_false_negatives: int = None
true_positives: Optional[List[Tuple]] = None
num_true_positives: Optional[int] = None
false_positives: Optional[List[Tuple]] = None
num_false_positives: Optional[int] = None
false_negatives: Optional[List[Tuple]] = None
num_false_negatives: Optional[int] = None
scores: Dict[str, SimilarityScore] = None
predicted_object: TextWithTriples = None
named_entities: List[Any] = None
Expand Down
8 changes: 4 additions & 4 deletions src/ontogpt/evaluation/enrichment/eval_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class Overlap(BaseModel):
jaccard: Optional[float] = None
common: Optional[List[str]] = None
overlap_score: Optional[int] = None
left_jaccard: float = None
right_jaccard: float = None
summary_jaccard: float = None
left_jaccard: Optional[float] = None
right_jaccard: Optional[float] = None
summary_jaccard: Optional[float] = None


class GeneSetComparison(BaseModel):
name: str
name: str = ""
gene_symbols: List[str]
gene_ids: List[str] = None
model: str = ""
Expand Down
10 changes: 5 additions & 5 deletions src/ontogpt/evaluation/hpoa/eval_hpoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ class EvaluationObjectSetHPOA(BaseModel):

test: List[MendelianDisease] = None
training: List[MendelianDisease] = None
predictions: List = None
predictions: List = []


class HPOAnnotation(BaseModel):
subject: DISEASE_ID = None
term: TERM = None
aspect: ASPECT = None
publication: PUBLICATION = None
subject: DISEASE_ID = ""
term: TERM = ""
aspect: ASPECT = ""
publication: PUBLICATION = ""


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/ontogpt/io/html_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HTMLExporter(Exporter):
TODO: rewrite to use bootstrap
"""

output: TextIO = None
output: TextIO

def export(self, extraction_output: ExtractionResult, output: Union[str, Path, TextIO]):
if isinstance(output, Path):
Expand Down
5 changes: 2 additions & 3 deletions src/ontogpt/ontex/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class Ontology(BaseModel):
axioms: List[Axiom]
"""All axioms in the ontology"""

terms: List[CURIE] = None
predicates: List[PRED_CURIE] = None
terms: List[CURIE] = [""]
predicates: List[PRED_CURIE] = [""]

comments: Optional[List[str]] = None

Expand Down Expand Up @@ -196,7 +196,6 @@ class Task(BaseModel):
query: Query = None
answers: Optional[List[Answer]] = None
examples: Optional[List[Example]] = None
description: Optional[str] = None
obfuscated: Optional[bool] = False

method: Optional[GPTReasonMethodType] = None
Expand Down

0 comments on commit 1215385

Please sign in to comment.