Skip to content

Commit fbb9d81

Browse files
committed
changing the type for organisation requirement..
1 parent 65de7d6 commit fbb9d81

File tree

16 files changed

+195
-278
lines changed

16 files changed

+195
-278
lines changed

samples/llm/chat_pb2.py

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/llm/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
# limitations under the License.
1616
from time import sleep
1717

18+
import chat_pb2
1819
from lmdeploy import GenerationConfig, TurbomindEngineConfig, pipeline
1920

2021
from dubbo import Dubbo
2122
from dubbo.configs import RegistryConfig, ServiceConfig
2223
from dubbo.proxy.handlers import RpcMethodHandler, RpcServiceHandler
23-
import chat_pb2
2424

2525
# the path of a model. It could be one of the following options:
2626
# 1. A local directory path of a turbomind model

src/dubbo/classes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
import abc
1818
import threading
19-
from typing import Any, Callable, Optional, Union, Type
2019
from abc import ABC, abstractmethod
20+
from typing import Any, Callable, Optional, Union
21+
2122
from dubbo.types import DeserializingFunction, RpcType, RpcTypes, SerializingFunction
2223

2324
__all__ = [
@@ -248,7 +249,7 @@ class ReadWriteStream(ReadStream, WriteStream, abc.ABC):
248249

249250

250251
class Codec(ABC):
251-
def __init__(self, model_type: Optional[Type[Any]] = None, **kwargs):
252+
def __init__(self, model_type: Optional[type[Any]] = None, **kwargs):
252253
self.model_type = model_type
253254

254255
@abstractmethod

src/dubbo/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
# limitations under the License.
1616

1717
import threading
18-
from typing import Optional, List, Type
18+
from typing import Optional
1919

2020
from dubbo.bootstrap import Dubbo
2121
from dubbo.classes import MethodDescriptor
22+
from dubbo.codec import DubboTransportService
2223
from dubbo.configs import ReferenceConfig
2324
from dubbo.constants import common_constants
2425
from dubbo.extension import extensionLoader
@@ -32,7 +33,6 @@
3233
SerializingFunction,
3334
)
3435
from dubbo.url import URL
35-
from dubbo.codec import DubboTransportService
3636

3737
__all__ = ["Client"]
3838

@@ -88,8 +88,8 @@ def _create_rpc_callable(
8888
self,
8989
rpc_type: str,
9090
method_name: str,
91-
params_types: List[Type],
92-
return_type: Type,
91+
params_types: list[type],
92+
return_type: type,
9393
codec: Optional[str] = None,
9494
request_serializer: Optional[SerializingFunction] = None,
9595
response_deserializer: Optional[DeserializingFunction] = None,
@@ -118,7 +118,7 @@ def _create_rpc_callable(
118118

119119
return self._callable(descriptor)
120120

121-
def unary(self, method_name: str, params_types: List[Type], return_type: Type, **kwargs) -> RpcCallable:
121+
def unary(self, method_name: str, params_types: list[type], return_type: type, **kwargs) -> RpcCallable:
122122
return self._create_rpc_callable(
123123
rpc_type=RpcTypes.UNARY.value,
124124
method_name=method_name,
@@ -127,7 +127,7 @@ def unary(self, method_name: str, params_types: List[Type], return_type: Type, *
127127
**kwargs,
128128
)
129129

130-
def client_stream(self, method_name: str, params_types: List[Type], return_type: Type, **kwargs) -> RpcCallable:
130+
def client_stream(self, method_name: str, params_types: list[type], return_type: type, **kwargs) -> RpcCallable:
131131
return self._create_rpc_callable(
132132
rpc_type=RpcTypes.CLIENT_STREAM.value,
133133
method_name=method_name,
@@ -136,7 +136,7 @@ def client_stream(self, method_name: str, params_types: List[Type], return_type:
136136
**kwargs,
137137
)
138138

139-
def server_stream(self, method_name: str, params_types: List[Type], return_type: Type, **kwargs) -> RpcCallable:
139+
def server_stream(self, method_name: str, params_types: list[type], return_type: type, **kwargs) -> RpcCallable:
140140
return self._create_rpc_callable(
141141
rpc_type=RpcTypes.SERVER_STREAM.value,
142142
method_name=method_name,
@@ -145,7 +145,7 @@ def server_stream(self, method_name: str, params_types: List[Type], return_type:
145145
**kwargs,
146146
)
147147

148-
def bi_stream(self, method_name: str, params_types: List[Type], return_type: Type, **kwargs) -> RpcCallable:
148+
def bi_stream(self, method_name: str, params_types: list[type], return_type: type, **kwargs) -> RpcCallable:
149149
return self._create_rpc_callable(
150150
rpc_type=RpcTypes.BI_STREAM.value,
151151
method_name=method_name,

src/dubbo/codec/dubbo_codec.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
from typing import Any, Type, Optional, Callable, List, Dict, Tuple
18-
from dataclasses import dataclass
1917
import inspect
2018
import logging
19+
from dataclasses import dataclass
20+
from typing import Any, Callable, Optional
2121

2222
logger = logging.getLogger(__name__)
2323

@@ -38,7 +38,7 @@ class MethodDescriptor:
3838

3939
function: Callable
4040
name: str
41-
parameters: List[ParameterDescriptor]
41+
parameters: list[ParameterDescriptor]
4242
return_parameter: ParameterDescriptor
4343
documentation: Optional[str] = None
4444

@@ -48,27 +48,27 @@ class DubboSerializationService:
4848

4949
@staticmethod
5050
def create_transport_codec(
51-
transport_type: str = "json", parameter_types: List[Type] = None, return_type: Type = None, **codec_options
51+
transport_type: str = "json", parameter_types: list[type] = None, return_type: type = None, **codec_options
5252
):
5353
"""Create transport codec with enhanced parameter structure"""
5454

5555
try:
56-
from dubbo.extension.extension_loader import ExtensionLoader
5756
from dubbo.classes import CodecHelper
57+
from dubbo.extension.extension_loader import ExtensionLoader
5858

5959
codec_class = ExtensionLoader().get_extension(CodecHelper.get_class(), transport_type)
6060
return codec_class(parameter_types=parameter_types or [], return_type=return_type, **codec_options)
6161
except ImportError as e:
62-
logger.error(f"Failed to import required modules: {e}")
62+
logger.error("Failed to import required modules: %s", e)
6363
raise
6464
except Exception as e:
65-
logger.error(f"Failed to create transport codec: {e}")
65+
logger.error("Failed to create transport codec: %s", e)
6666
raise
6767

6868
@staticmethod
6969
def create_encoder_decoder_pair(
70-
transport_type: str, parameter_types: List[Type] = None, return_type: Type = None, **codec_options
71-
) -> Tuple[Any, Any]:
70+
transport_type: str, parameter_types: list[type] = None, return_type: type = None, **codec_options
71+
) -> tuple[Any, Any]:
7272
"""Create separate encoder and decoder instances"""
7373

7474
try:
@@ -85,13 +85,13 @@ def create_encoder_decoder_pair(
8585
return encoder, decoder
8686

8787
except Exception as e:
88-
logger.error(f"Failed to create encoder/decoder pair: {e}")
88+
logger.error("Failed to create encoder/decoder pair: %s", e)
8989
raise
9090

9191
@staticmethod
9292
def create_serialization_functions(
93-
transport_type: str, parameter_types: List[Type] = None, return_type: Type = None, **codec_options
94-
) -> Tuple[Callable, Callable]:
93+
transport_type: str, parameter_types: list[type] = None, return_type: type = None, **codec_options
94+
) -> tuple[Callable, Callable]:
9595
"""Create serializer and deserializer functions for RPC (backward compatibility)"""
9696

9797
try:
@@ -103,7 +103,7 @@ def serialize_method_parameters(*args) -> bytes:
103103
try:
104104
return parameter_encoder.encode(args)
105105
except Exception as e:
106-
logger.error(f"Failed to serialize parameters: {e}")
106+
logger.error("Failed to serialize parameters: %s", e)
107107
raise
108108

109109
def deserialize_method_return(data: bytes):
@@ -112,21 +112,21 @@ def deserialize_method_return(data: bytes):
112112
try:
113113
return return_decoder.decode(data)
114114
except Exception as e:
115-
logger.error(f"Failed to deserialize return value: {e}")
115+
logger.error("Failed to deserialize return value: %s", e)
116116
raise
117117

118118
return serialize_method_parameters, deserialize_method_return
119119

120120
except Exception as e:
121-
logger.error(f"Failed to create serialization functions: {e}")
121+
logger.error("Failed to create serialization functions: %s", e)
122122
raise
123123

124124
@staticmethod
125125
def create_method_descriptor(
126126
func: Callable,
127127
method_name: Optional[str] = None,
128-
parameter_types: List[Type] = None,
129-
return_type: Type = None,
128+
parameter_types: list[type] = None,
129+
return_type: type = None,
130130
interface: Callable = None,
131131
) -> MethodDescriptor:
132132
"""Create a method descriptor from function and configuration"""
@@ -141,7 +141,7 @@ def create_method_descriptor(
141141
try:
142142
sig = inspect.signature(target_function)
143143
except ValueError as e:
144-
logger.error(f"Cannot inspect signature of {target_function}: {e}")
144+
logger.error("Cannot inspect signature of %s: %s", target_function, e)
145145
raise
146146

147147
parameters = []

src/dubbo/codec/json_codec/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
from .json_codec_handler import JsonTransportCodec, JsonTransportEncoder, JsonTransportDecoder
17+
from .json_codec_handler import JsonTransportCodec, JsonTransportDecoder, JsonTransportEncoder
1818

1919
__all__ = ["JsonTransportCodec", "JsonTransportDecoder", "JsonTransportEncoder"]

0 commit comments

Comments
 (0)