tamar-model-client 0.1.18__py3-none-any.whl → 0.1.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tamar_model_client/__init__.py +2 -0
- tamar_model_client/async_client.py +6 -6
- tamar_model_client/logging_icons.py +60 -0
- tamar_model_client/sync_client.py +3 -3
- {tamar_model_client-0.1.18.dist-info → tamar_model_client-0.1.19.dist-info}/METADATA +1 -1
- {tamar_model_client-0.1.18.dist-info → tamar_model_client-0.1.19.dist-info}/RECORD +8 -7
- {tamar_model_client-0.1.18.dist-info → tamar_model_client-0.1.19.dist-info}/WHEEL +0 -0
- {tamar_model_client-0.1.18.dist-info → tamar_model_client-0.1.19.dist-info}/top_level.txt +0 -0
tamar_model_client/__init__.py
CHANGED
@@ -2,6 +2,7 @@ from .sync_client import TamarModelClient
|
|
2
2
|
from .async_client import AsyncTamarModelClient
|
3
3
|
from .exceptions import ModelManagerClientError, ConnectionError, ValidationError
|
4
4
|
from .json_formatter import JSONFormatter
|
5
|
+
from . import logging_icons
|
5
6
|
|
6
7
|
__all__ = [
|
7
8
|
"TamarModelClient",
|
@@ -10,4 +11,5 @@ __all__ = [
|
|
10
11
|
"ConnectionError",
|
11
12
|
"ValidationError",
|
12
13
|
"JSONFormatter",
|
14
|
+
"logging_icons",
|
13
15
|
]
|
@@ -183,7 +183,7 @@ class AsyncTamarModelClient:
|
|
183
183
|
# 对于取消的情况进行指数退避重试
|
184
184
|
if isinstance(e, grpc.aio.AioRpcError) and e.code() == grpc.StatusCode.CANCELLED:
|
185
185
|
retry_count += 1
|
186
|
-
logger.
|
186
|
+
logger.warning(f"⚠️ RPC cancelled, retrying {retry_count}/{self.max_retries}...",
|
187
187
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "error_code": "CANCELLED"}})
|
188
188
|
if retry_count < self.max_retries:
|
189
189
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
@@ -196,7 +196,7 @@ class AsyncTamarModelClient:
|
|
196
196
|
elif isinstance(e, grpc.RpcError) and e.code() in {grpc.StatusCode.UNAVAILABLE,
|
197
197
|
grpc.StatusCode.DEADLINE_EXCEEDED}:
|
198
198
|
retry_count += 1
|
199
|
-
logger.
|
199
|
+
logger.warning(f"⚠️ gRPC error {e.code()}, retrying {retry_count}/{self.max_retries}...",
|
200
200
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "error_code": str(e.code())}})
|
201
201
|
if retry_count < self.max_retries:
|
202
202
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
@@ -219,7 +219,7 @@ class AsyncTamarModelClient:
|
|
219
219
|
# 对于取消的情况进行指数退避重试
|
220
220
|
if isinstance(e, grpc.aio.AioRpcError) and e.code() == grpc.StatusCode.CANCELLED:
|
221
221
|
retry_count += 1
|
222
|
-
logger.
|
222
|
+
logger.warning(f"⚠️ RPC cancelled, retrying {retry_count}/{self.max_retries}...",
|
223
223
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "error_code": "CANCELLED"}})
|
224
224
|
if retry_count < self.max_retries:
|
225
225
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
@@ -232,7 +232,7 @@ class AsyncTamarModelClient:
|
|
232
232
|
elif isinstance(e, grpc.RpcError) and e.code() in {grpc.StatusCode.UNAVAILABLE,
|
233
233
|
grpc.StatusCode.DEADLINE_EXCEEDED}:
|
234
234
|
retry_count += 1
|
235
|
-
logger.
|
235
|
+
logger.warning(f"⚠️ gRPC error {e.code()}, retrying {retry_count}/{self.max_retries}...",
|
236
236
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "error_code": str(e.code())}})
|
237
237
|
if retry_count < self.max_retries:
|
238
238
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
@@ -310,7 +310,7 @@ class AsyncTamarModelClient:
|
|
310
310
|
|
311
311
|
# 指数退避:延迟时间 = retry_delay * (2 ^ (retry_count - 1))
|
312
312
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
313
|
-
logger.
|
313
|
+
logger.warning(f"🔄 Retrying connection (attempt {retry_count}/{self.max_retries}) after {delay:.2f}s delay...",
|
314
314
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "delay": delay}})
|
315
315
|
await asyncio.sleep(delay)
|
316
316
|
|
@@ -740,7 +740,7 @@ class AsyncTamarModelClient:
|
|
740
740
|
else:
|
741
741
|
loop.run_until_complete(self.close())
|
742
742
|
except Exception as e:
|
743
|
-
logger.
|
743
|
+
logger.warning(f"⚠️ gRPC channel close failed at exit: {e}",
|
744
744
|
extra={"log_type": "info", "data": {"status": "failed", "error": str(e)}})
|
745
745
|
|
746
746
|
async def __aenter__(self):
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"""
|
2
|
+
日志图标规范
|
3
|
+
|
4
|
+
本模块定义了统一的日志图标标准,确保整个项目中日志消息的视觉一致性。
|
5
|
+
"""
|
6
|
+
|
7
|
+
# 请求生命周期图标
|
8
|
+
REQUEST_START = "🔵" # 请求开始
|
9
|
+
RESPONSE_SUCCESS = "✅" # 响应成功
|
10
|
+
RESPONSE_ERROR = "❌" # 响应错误
|
11
|
+
|
12
|
+
# 连接和网络图标
|
13
|
+
SECURE_CONNECTION = "🔐" # 安全连接 (TLS)
|
14
|
+
INSECURE_CONNECTION = "🔓" # 不安全连接 (无TLS)
|
15
|
+
CONNECTION_SUCCESS = "✅" # 连接成功
|
16
|
+
CONNECTION_RETRY = "🔄" # 连接重试
|
17
|
+
CONNECTION_ERROR = "❌" # 连接错误
|
18
|
+
|
19
|
+
# 操作状态图标
|
20
|
+
SUCCESS = "✅" # 成功
|
21
|
+
ERROR = "❌" # 错误
|
22
|
+
WARNING = "⚠️" # 警告
|
23
|
+
INFO = "ℹ️" # 信息
|
24
|
+
RETRY = "🔄" # 重试
|
25
|
+
PROCESSING = "⚙️" # 处理中
|
26
|
+
|
27
|
+
# 流式响应图标
|
28
|
+
STREAM_SUCCESS = "✅" # 流完成
|
29
|
+
STREAM_ERROR = "❌" # 流错误
|
30
|
+
STREAM_CHUNK = "📦" # 流数据块
|
31
|
+
|
32
|
+
# 批量操作图标
|
33
|
+
BATCH_START = "🔵" # 批量开始
|
34
|
+
BATCH_SUCCESS = "✅" # 批量成功
|
35
|
+
BATCH_ERROR = "❌" # 批量错误
|
36
|
+
|
37
|
+
# 系统操作图标
|
38
|
+
INIT = "🚀" # 初始化
|
39
|
+
CLOSE = "🔚" # 关闭
|
40
|
+
CLEANUP = "🧹" # 清理
|
41
|
+
|
42
|
+
def get_icon_for_log_type(log_type: str, is_success: bool = True) -> str:
|
43
|
+
"""
|
44
|
+
根据日志类型和状态获取合适的图标
|
45
|
+
|
46
|
+
Args:
|
47
|
+
log_type: 日志类型 (request, response, info)
|
48
|
+
is_success: 是否成功
|
49
|
+
|
50
|
+
Returns:
|
51
|
+
对应的图标字符串
|
52
|
+
"""
|
53
|
+
if log_type == "request":
|
54
|
+
return REQUEST_START
|
55
|
+
elif log_type == "response":
|
56
|
+
return RESPONSE_SUCCESS if is_success else RESPONSE_ERROR
|
57
|
+
elif log_type == "info":
|
58
|
+
return INFO if is_success else WARNING
|
59
|
+
else:
|
60
|
+
return INFO
|
@@ -176,7 +176,7 @@ class TamarModelClient:
|
|
176
176
|
except (grpc.RpcError) as e:
|
177
177
|
if e.code() in {grpc.StatusCode.UNAVAILABLE, grpc.StatusCode.DEADLINE_EXCEEDED}:
|
178
178
|
retry_count += 1
|
179
|
-
logger.
|
179
|
+
logger.warning(f"⚠️ gRPC error {e.code()}, retrying {retry_count}/{self.max_retries}...",
|
180
180
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "error_code": str(e.code())}})
|
181
181
|
if retry_count < self.max_retries:
|
182
182
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
@@ -255,7 +255,7 @@ class TamarModelClient:
|
|
255
255
|
|
256
256
|
# 指数退避:延迟时间 = retry_delay * (2 ^ (retry_count - 1))
|
257
257
|
delay = self.retry_delay * (2 ** (retry_count - 1))
|
258
|
-
logger.
|
258
|
+
logger.warning(f"🔄 Retrying connection (attempt {retry_count}/{self.max_retries}) after {delay:.2f}s delay...",
|
259
259
|
extra={"log_type": "info", "data": {"retry_count": retry_count, "max_retries": self.max_retries, "delay": delay}})
|
260
260
|
time.sleep(delay) # Blocking sleep in sync version
|
261
261
|
|
@@ -679,7 +679,7 @@ class TamarModelClient:
|
|
679
679
|
try:
|
680
680
|
self.close() # 直接调用关闭方法
|
681
681
|
except Exception as e:
|
682
|
-
logger.
|
682
|
+
logger.warning(f"⚠️ gRPC channel close failed at exit: {e}",
|
683
683
|
extra={"log_type": "info", "data": {"status": "failed", "error": str(e)}})
|
684
684
|
|
685
685
|
def __enter__(self):
|
@@ -1,9 +1,10 @@
|
|
1
|
-
tamar_model_client/__init__.py,sha256=
|
2
|
-
tamar_model_client/async_client.py,sha256=
|
1
|
+
tamar_model_client/__init__.py,sha256=4DEIUGlLTeiaECjJQbGYik7C0JO6hHwwfbLYpYpMdzg,444
|
2
|
+
tamar_model_client/async_client.py,sha256=PaI0a-hSkp7s99Aib-eL2-Ouh8d3A4E-L6EdSsfeE3w,36843
|
3
3
|
tamar_model_client/auth.py,sha256=gbwW5Aakeb49PMbmYvrYlVx1mfyn1LEDJ4qQVs-9DA4,438
|
4
4
|
tamar_model_client/exceptions.py,sha256=jYU494OU_NeIa4X393V-Y73mTNm0JZ9yZApnlOM9CJQ,332
|
5
5
|
tamar_model_client/json_formatter.py,sha256=9iO4Qn7FiyPTjcn07uHuP4q80upVlmqI_P1UV12YPxI,991
|
6
|
-
tamar_model_client/
|
6
|
+
tamar_model_client/logging_icons.py,sha256=MRTZ1Xvkep9ce_jdltj54_XZUXvIpQ95soRNmLdJ4qw,1837
|
7
|
+
tamar_model_client/sync_client.py,sha256=FXdBeAqCHuLDPKzOyLMsPi33ibbNFLf9hWYfP1NFHuw,32507
|
7
8
|
tamar_model_client/utils.py,sha256=Kn6pFz9GEC96H4eejEax66AkzvsrXI3WCSDtgDjnVTI,5238
|
8
9
|
tamar_model_client/enums/__init__.py,sha256=3cYYn8ztNGBa_pI_5JGRVYf2QX8fkBVWdjID1PLvoBQ,182
|
9
10
|
tamar_model_client/enums/channel.py,sha256=wCzX579nNpTtwzGeS6S3Ls0UzVAgsOlfy4fXMzQTCAw,199
|
@@ -15,7 +16,7 @@ tamar_model_client/generated/model_service_pb2_grpc.py,sha256=k4tIbp3XBxdyuOVR18
|
|
15
16
|
tamar_model_client/schemas/__init__.py,sha256=AxuI-TcvA4OMTj2FtK4wAItvz9LrK_293pu3cmMLE7k,394
|
16
17
|
tamar_model_client/schemas/inputs.py,sha256=dz1m8NbUIxA99JXZc8WlyzbKpDuz1lEzx3VghC33zYI,14625
|
17
18
|
tamar_model_client/schemas/outputs.py,sha256=M_fcqUtXPJnfiLabHlyA8BorlC5pYkf5KLjXO1ysKIQ,1031
|
18
|
-
tamar_model_client-0.1.
|
19
|
-
tamar_model_client-0.1.
|
20
|
-
tamar_model_client-0.1.
|
21
|
-
tamar_model_client-0.1.
|
19
|
+
tamar_model_client-0.1.19.dist-info/METADATA,sha256=-eCR9u_ULva97BJ0GwuaAuwEL7xyXGlmD2TwQUNSMxw,16562
|
20
|
+
tamar_model_client-0.1.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
tamar_model_client-0.1.19.dist-info/top_level.txt,sha256=_LfDhPv_fvON0PoZgQuo4M7EjoWtxPRoQOBJziJmip8,19
|
22
|
+
tamar_model_client-0.1.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|