Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: define Model API optional type default values #103

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

7 changes: 2 additions & 5 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,10 +46,9 @@ 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 }

[tool.poetry.extras]
# MANUAL MAINTENANCE REQUIRED: for every change in the extras, "all" must be updated,
Expand All @@ -60,14 +59,12 @@ api = [
"fastapi",
"uvicorn",
"anyio",
"starlette",
]

all = [
"fastapi",
"uvicorn",
"anyio",
"starlette",
]

[tool.poetry.group.dev.dependencies]
Expand Down