Skip to content

Commit

Permalink
bumped fastapi version. updated deps. fix mypy errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Santana <[email protected]>
  • Loading branch information
SantanaTiago committed Aug 30, 2023
1 parent 1447f57 commit 5822b6c
Show file tree
Hide file tree
Showing 10 changed files with 1,178 additions and 1,049 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
using: 'composite'
steps:
- name: Install poetry
run: pipx install poetry==1.2.2
run: pipx install poetry==1.6.1
shell: bash
- uses: actions/setup-python@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion deepsearch/core/cli/profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

import typer
from pydantic import SecretStr
from rich.console import Console
from rich.table import Table
from typing_extensions import Annotated
Expand Down Expand Up @@ -42,7 +43,7 @@ def add_profile(
profile_settings = ProfileSettings(
host=host,
username=username,
api_key=api_key,
api_key=SecretStr(api_key),
verify_ssl=verify_ssl,
)

Expand Down
6 changes: 4 additions & 2 deletions deepsearch/core/client/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def from_cli_prompt(cls) -> ProfileSettings:
return cls(
host=input("Host: "),
username=input("Username: "),
api_key=getpass("API key: "),
verify_ssl=input("SSL verification [y/n]: "),
api_key=SecretStr(getpass("API key: ")),
verify_ssl=True
if input("SSL verification [y/n]: ") == "y" or "Y"
else False,
)


Expand Down
10 changes: 5 additions & 5 deletions deepsearch/core/client/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict, Optional

import platformdirs
from pydantic import ValidationError
from pydantic import SecretStr, ValidationError

from deepsearch.core.cli.profile_utils import (
MSG_AMBIGUOUS_SUCCESSOR,
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self) -> None:
)
)
self._main_path = self.config_root_path / MAIN_DOTENV_FILENAME
self._main_settings = MainSettings(_env_file=self._main_path)
self._main_settings = MainSettings(_env_file=self._main_path) # type: ignore
self._profile_root_path = self.config_root_path / PROFILES_DIR_NAME
self._profile_root_path.mkdir(exist_ok=True)

Expand All @@ -51,7 +51,7 @@ def __init__(self) -> None:
profile_name = file_path.stem
self._profile_cache[profile_name] = ProfileSettingsEntry(
path=file_path,
settings=ProfileSettings(_env_file=file_path),
settings=ProfileSettings(_env_file=file_path), # type: ignore
)

# reset any stale active profile config
Expand Down Expand Up @@ -85,7 +85,7 @@ def _migrate_legacy_config(self) -> None:
new_cfg = ProfileSettings(
host=legacy_cfg.host,
username=legacy_cfg.auth.username,
api_key=legacy_cfg.auth.api_key,
api_key=SecretStr(legacy_cfg.auth.api_key),
verify_ssl=legacy_cfg.verify_ssl,
)
self.save_settings(
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_profile_settings(
prfl_name = profile_name or self.get_active_profile()
if prfl_name is None:
try: # try to instantiate from environment alone
return ProfileSettings()
return ProfileSettings() # type: ignore
except ValidationError:
if len(self._profile_cache) == 0:
raise RuntimeError(MSG_NO_PROFILES_DEFINED)
Expand Down
4 changes: 2 additions & 2 deletions deepsearch/documents/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class ConversionSettings(BaseModel):

@classmethod
def from_project(cls, api: CpsApi, proj_key: str) -> "ConversionSettings":
conv_settings = cls()
conv_settings = cls() # type: ignore

proj_key, _ = get_ccs_project_key(api, proj_key)

Expand All @@ -372,7 +372,7 @@ def from_project(cls, api: CpsApi, proj_key: str) -> "ConversionSettings":

@classmethod
def from_defaults(cls, api: CpsApi) -> "ConversionSettings":
conv_settings = cls()
conv_settings = cls() # type: ignore

request_conv_settings = api.client.session.get(
url=URLNavigator(api).url_conversion_defaults()
Expand Down
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 @@ -12,6 +12,7 @@
AnnotationLabels,
EntityLabel,
NLPConfig,
NLPType,
)


Expand All @@ -23,7 +24,7 @@ def __init__(self) -> None:
kind=Kind.NLPModel,
name="DummyNLPAnnotator",
version="0.1.0",
supported_types=["text"],
supported_types=[NLPType("text")],
labels=self._generate_labels(),
)

Expand Down
8 changes: 5 additions & 3 deletions deepsearch/model/kinds/nlp/controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Literal

from fastapi import HTTPException, status

from deepsearch.model.base.controller import BaseController
Expand Down Expand Up @@ -29,11 +31,11 @@ def __init__(self, model: BaseNLPModel):
def get_info(self) -> NLPInfoOutput:
cfg = self._model.get_nlp_config()
metadata = NLPModelMetadata(
supported_object_types=cfg.supported_types,
supported_object_types=cfg.supported_types, # type: ignore
**self._get_metadata().dict(), # passing parent metadata dict as kwargs
)
spec = NLPInfoOutputDefinitionsSpec(
definition=cfg.labels,
definition=cfg.labels.dict(),
metadata=metadata,
)
definitions = NLPInfoOutputDefinitions(
Expand All @@ -43,7 +45,7 @@ def get_info(self) -> NLPInfoOutput:
)
return NLPInfoOutput(definitions=definitions)

def get_kind(self) -> str:
def get_kind(self) -> Literal[Kind.NLPModel]:
return Kind.NLPModel

def _get_model(self) -> BaseDSModel:
Expand Down
4 changes: 3 additions & 1 deletion deepsearch/model/kinds/qagen/controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Literal

from fastapi import HTTPException, status

from deepsearch.model.base.controller import BaseController
Expand Down Expand Up @@ -32,7 +34,7 @@ def get_info(self) -> QAGenInfoOutput:
def _get_model(self) -> BaseDSModel:
return self._model

def get_kind(self) -> str:
def get_kind(self) -> Literal[Kind.QAGenModel]:
return Kind.QAGenModel

def dispatch_predict(self, spec: CtrlPredInput) -> CtrlPredOutput:
Expand Down
Loading

0 comments on commit 5822b6c

Please sign in to comment.