Skip to content

Commit

Permalink
Ran linting
Browse files Browse the repository at this point in the history
  • Loading branch information
HAKSOAT committed Nov 26, 2024
1 parent 92cddd2 commit de724a6
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 386 deletions.
102 changes: 1 addition & 101 deletions ahnlich/Cargo.lock

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

1 change: 0 additions & 1 deletion ahnlich/ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ strum = { version = "0.26", features = ["derive"] }
log.workspace = true
fallible_collections.workspace = true
rayon.workspace = true
fastembed = { version = "4.0.0", features = ["default"] }
hf-hub = { version = "0.3", default-features = false }
dirs = "5.0.1"
ort = { version = "=2.0.0-rc.5", default-features = false }
Expand Down
82 changes: 9 additions & 73 deletions sdk/ahnlich-client-py/ahnlich_client_py/internals/ai_query.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# pyre-strict
import typing
from dataclasses import dataclass

from ahnlich_client_py.internals import bincode
import typing
from ahnlich_client_py.internals import serde_types as st
from ahnlich_client_py.internals import bincode


class AIModel:
Expand Down Expand Up @@ -55,6 +54,7 @@ class AIModel__ClipVitB32Image(AIModel):
INDEX = 5 # type: int
pass


@dataclass(frozen=True)
class AIModel__ClipVitB32Text(AIModel):
INDEX = 6 # type: int
Expand Down Expand Up @@ -305,38 +305,6 @@ class Algorithm__KDTree(Algorithm):
]


class ImageAction:
VARIANTS = [] # type: typing.Sequence[typing.Type[ImageAction]]

def bincode_serialize(self) -> bytes:
return bincode.serialize(self, ImageAction)

@staticmethod
def bincode_deserialize(input: bytes) -> "ImageAction":
v, buffer = bincode.deserialize(input, ImageAction)
if buffer:
raise st.DeserializationError("Some input bytes were not read")
return v


@dataclass(frozen=True)
class ImageAction__ResizeImage(ImageAction):
INDEX = 0 # type: int
pass


@dataclass(frozen=True)
class ImageAction__ErrorIfDimensionsMismatch(ImageAction):
INDEX = 1 # type: int
pass


ImageAction.VARIANTS = [
ImageAction__ResizeImage,
ImageAction__ErrorIfDimensionsMismatch,
]


class MetadataValue:
VARIANTS = [] # type: typing.Sequence[typing.Type[MetadataValue]]

Expand Down Expand Up @@ -498,20 +466,20 @@ def bincode_deserialize(input: bytes) -> "PreprocessAction":


@dataclass(frozen=True)
class PreprocessAction__RawString(PreprocessAction):
class PreprocessAction__NoPreprocessing(PreprocessAction):
INDEX = 0 # type: int
value: "StringAction"
pass


@dataclass(frozen=True)
class PreprocessAction__Image(PreprocessAction):
class PreprocessAction__ModelPreprocessing(PreprocessAction):
INDEX = 1 # type: int
value: "ImageAction"
pass


PreprocessAction.VARIANTS = [
PreprocessAction__RawString,
PreprocessAction__Image,
PreprocessAction__NoPreprocessing,
PreprocessAction__ModelPreprocessing,
]


Expand Down Expand Up @@ -545,35 +513,3 @@ class StoreInput__Image(StoreInput):
StoreInput__RawString,
StoreInput__Image,
]


class StringAction:
VARIANTS = [] # type: typing.Sequence[typing.Type[StringAction]]

def bincode_serialize(self) -> bytes:
return bincode.serialize(self, StringAction)

@staticmethod
def bincode_deserialize(input: bytes) -> "StringAction":
v, buffer = bincode.deserialize(input, StringAction)
if buffer:
raise st.DeserializationError("Some input bytes were not read")
return v


@dataclass(frozen=True)
class StringAction__TruncateIfTokensExceed(StringAction):
INDEX = 0 # type: int
pass


@dataclass(frozen=True)
class StringAction__ErrorIfTokensExceed(StringAction):
INDEX = 1 # type: int
pass


StringAction.VARIANTS = [
StringAction__TruncateIfTokensExceed,
StringAction__ErrorIfTokensExceed,
]
12 changes: 9 additions & 3 deletions sdk/ahnlich-client-py/ahnlich_client_py/internals/ai_response.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# pyre-strict
import typing
from dataclasses import dataclass

from ahnlich_client_py.internals import bincode
import typing
from ahnlich_client_py.internals import serde_types as st
from ahnlich_client_py.internals import bincode


class AIModel:
Expand Down Expand Up @@ -56,13 +55,20 @@ class AIModel__ClipVitB32Image(AIModel):
pass


@dataclass(frozen=True)
class AIModel__ClipVitB32Text(AIModel):
INDEX = 6 # type: int
pass


AIModel.VARIANTS = [
AIModel__AllMiniLML6V2,
AIModel__AllMiniLML12V2,
AIModel__BGEBaseEnV15,
AIModel__BGELargeEnV15,
AIModel__Resnet50,
AIModel__ClipVitB32Image,
AIModel__ClipVitB32Text,
]


Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (c) Facebook, Inc. and its affiliates
# SPDX-License-Identifier: MIT OR Apache-2.0

import collections
import dataclasses
import collections
import io
import struct
import typing
from copy import copy
from typing import get_type_hints

from ahnlich_client_py.internals import serde_binary as sb
from ahnlich_client_py.internals import serde_types as st
from ahnlich_client_py.internals import serde_binary as sb

# Maximum length in practice for sequences (e.g. in Java).
MAX_LENGTH = (1 << 31) - 1
Expand Down
5 changes: 2 additions & 3 deletions sdk/ahnlich-client-py/ahnlich_client_py/internals/db_query.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# pyre-strict
import typing
from dataclasses import dataclass

from ahnlich_client_py.internals import bincode
import typing
from ahnlich_client_py.internals import serde_types as st
from ahnlich_client_py.internals import bincode


class Algorithm:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# pyre-strict
import typing
from dataclasses import dataclass

from ahnlich_client_py.internals import bincode
import typing
from ahnlich_client_py.internals import serde_types as st
from ahnlich_client_py.internals import bincode


@dataclass(frozen=True)
Expand Down
Loading

0 comments on commit de724a6

Please sign in to comment.