Skip to content

Commit

Permalink
fix: define Model API optional type defaults (DS4SD#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <35837085+vagenas@users.noreply.github.com>
  • Loading branch information
vagenas authored and miguel-brandao-ibm committed Jun 19, 2023
1 parent 0180d9d commit 58aabe7
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 32 deletions.
3 changes: 2 additions & 1 deletion deepsearch/model/base/controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from abc import ABC, abstractmethod
from typing import Optional

from deepsearch.model.base.model import BaseDSModel, BaseModelConfig
from deepsearch.model.base.model import BaseDSModel
from deepsearch.model.base.types import BaseModelConfig
from deepsearch.model.server.inference_types import ControllerInput, ControllerOutput


Expand Down
8 changes: 4 additions & 4 deletions deepsearch/model/base/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BaseModelConfig(StrictModel):
kind: Kind
name: str
version: str
url: Optional[str]
author: Optional[str]
description: Optional[str]
expected_compute_time: Optional[PositiveFloat]
url: Optional[str] = None
author: Optional[str] = None
description: Optional[str] = None
expected_compute_time: Optional[PositiveFloat] = None
3 changes: 2 additions & 1 deletion deepsearch/model/examples/dummy_nlp_annotator/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from fastapi import HTTPException, status

from deepsearch.model.base.types import Kind
from deepsearch.model.kinds.nlp.model import BaseNLPModel, NLPConfig
from deepsearch.model.kinds.nlp.model import BaseNLPModel
from deepsearch.model.kinds.nlp.types import (
AnnotateEntitiesOutput,
AnnotatePropertiesOutput,
AnnotateRelationshipsOutput,
AnnotationLabels,
EntityLabel,
NLPConfig,
)


Expand Down
4 changes: 2 additions & 2 deletions deepsearch/model/examples/dummy_qa_generator/model.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List, Tuple

from deepsearch.model.base.types import Kind
from deepsearch.model.kinds.qagen.model import BaseQAGenerator, QAGenConfig
from deepsearch.model.kinds.qagen.types import GenerateAnswersOutput
from deepsearch.model.kinds.qagen.model import BaseQAGenerator
from deepsearch.model.kinds.qagen.types import GenerateAnswersOutput, QAGenConfig


class DummyQAGenerator(BaseQAGenerator):
Expand Down
3 changes: 2 additions & 1 deletion deepsearch/model/examples/simple_geo_nlp_annotator/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from fastapi import HTTPException, status

from deepsearch.model.base.types import Kind
from deepsearch.model.kinds.nlp.model import BaseNLPModel, NLPConfig
from deepsearch.model.kinds.nlp.model import BaseNLPModel
from deepsearch.model.kinds.nlp.types import (
AnnotateEntitiesOutput,
AnnotatePropertiesOutput,
AnnotateRelationshipsOutput,
AnnotationLabels,
EntityLabel,
NLPConfig,
NLPType,
PropertyLabel,
RelationshipLabel,
Expand Down
3 changes: 2 additions & 1 deletion deepsearch/model/kinds/nlp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from copy import deepcopy
from typing import List, Optional

from deepsearch.model.base.model import BaseDSModel, BaseModelConfig
from deepsearch.model.base.model import BaseDSModel
from deepsearch.model.base.types import BaseModelConfig
from deepsearch.model.kinds.nlp.types import (
AnnotateEntitiesOutput,
AnnotatePropertiesOutput,
Expand Down
8 changes: 4 additions & 4 deletions deepsearch/model/kinds/nlp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ class NLPType(str, Enum):


class FindEntitiesText(StrictModel):
entityNames: Optional[List[str]]
entityNames: Optional[List[str]] = None
objectType: Literal[NLPType.text]
texts: List[str]


class FindPropertiesText(StrictModel):
propertyNames: Optional[List[str]]
entities: Optional[List[dict]]
propertyNames: Optional[List[str]] = None
entities: Optional[List[dict]] = None
objectType: Literal[NLPType.text]
texts: List[str]


class FindRelationshipsText(StrictModel):
relationshipNames: Optional[List[str]]
relationshipNames: Optional[List[str]] = None
entities: List[dict]
objectType: Literal[NLPType.text]
texts: List[str]
Expand Down
5 changes: 3 additions & 2 deletions deepsearch/model/kinds/qagen/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from abc import abstractmethod
from typing import List, Literal, Tuple
from typing import List, Tuple

from deepsearch.model.base.model import BaseDSModel, BaseModelConfig
from deepsearch.model.base.model import BaseDSModel
from deepsearch.model.base.types import BaseModelConfig
from deepsearch.model.kinds.qagen.types import GenerateAnswersOutput, QAGenConfig


Expand Down
28 changes: 14 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ python = "^3.8"
# Dependencies from generated packages
urllib3 = "^1.26.8"
six = "^1.16.0"
certifi = "^2021.10.8"
certifi = "^2022.12.07"
python-dateutil = "^2.8.2"

# Actual dependencies
Expand All @@ -46,7 +46,7 @@ tabulate = "^0.8.9"
pluggy = "^1.0.0"
tqdm = "^4.64.0"

fastapi = { version = "^0.95.1", optional = true }
fastapi = { version = "^0.95.2", optional = true }
uvicorn = { version = "^0.21.1", optional = true }
anyio = { version = "^3.6.2", optional = true }
starlette = { version = "^0.26.1", optional = true }
Expand Down

0 comments on commit 58aabe7

Please sign in to comment.