forked from SeldonIO/MLServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
74 lines (65 loc) · 1.87 KB
/
__init__.py
File metadata and controls
74 lines (65 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from typing import TYPE_CHECKING
from .numpy import NumpyCodec, NumpyRequestCodec
from .string import StringCodec, StringRequestCodec
from .base64 import Base64Codec
from .datetime import DatetimeCodec
from .errors import CodecError
from .decorator import decode_args
from .base import (
InputCodec,
RequestCodec,
register_input_codec,
register_request_codec,
InputCodecLike,
RequestCodecLike,
)
from .utils import (
DecodedParameterName,
has_decoded,
get_decoded,
get_decoded_or_raw,
encode_inference_response,
encode_response_output,
decode_request_input,
decode_inference_request,
)
if TYPE_CHECKING: # pragma: no cover - type checking only
from .pandas import PandasCodec # noqa: F401
__all__ = [
"CodecError",
"NumpyCodec",
"NumpyRequestCodec",
"StringCodec",
"StringRequestCodec",
"Base64Codec",
"DatetimeCodec",
"PandasCodec",
"InputCodec",
"InputCodecLike",
"RequestCodec",
"RequestCodecLike",
"DecodedParameterName",
"register_input_codec",
"register_request_codec",
"has_decoded",
"get_decoded",
"get_decoded_or_raw",
"encode_inference_response",
"encode_response_output",
"decode_request_input",
"decode_inference_request",
"decode_args",
]
def __getattr__(name: str): # pragma: no cover - lightweight lazy import
if name == "PandasCodec":
return _load_pandas_codec()
raise AttributeError(f"module 'mlserver.codecs' has no attribute {name!r}")
def _load_pandas_codec():
try:
from .pandas import PandasCodec as _PandasCodec # Local import to stay optional
except Exception as exc: # pragma: no cover - propagate useful context
raise ImportError(
"PandasCodec requires the optional 'pandas' dependency"
) from exc
globals()["PandasCodec"] = _PandasCodec
return _PandasCodec