tamar-file-hub-client 0.0.6__py3-none-any.whl → 0.0.8__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.
- file_hub_client/client.py +1 -0
- file_hub_client/services/taple/async_taple_service.py +2291 -2281
- file_hub_client/services/taple/sync_taple_service.py +14 -4
- file_hub_client/utils/retry.py +40 -0
- {tamar_file_hub_client-0.0.6.dist-info → tamar_file_hub_client-0.0.8.dist-info}/METADATA +1 -1
- {tamar_file_hub_client-0.0.6.dist-info → tamar_file_hub_client-0.0.8.dist-info}/RECORD +8 -8
- {tamar_file_hub_client-0.0.6.dist-info → tamar_file_hub_client-0.0.8.dist-info}/WHEEL +0 -0
- {tamar_file_hub_client-0.0.6.dist-info → tamar_file_hub_client-0.0.8.dist-info}/top_level.txt +0 -0
@@ -1487,8 +1487,8 @@ class SyncTapleService(BaseTapleService):
|
|
1487
1487
|
self,
|
1488
1488
|
sheet_id: str,
|
1489
1489
|
operations: List[Any],
|
1490
|
-
sheet_version: int,
|
1491
|
-
client_id: str,
|
1490
|
+
sheet_version: Optional[int] = None,
|
1491
|
+
client_id: Optional[str] = None,
|
1492
1492
|
*,
|
1493
1493
|
idempotency_key: Optional[str] = None,
|
1494
1494
|
request_id: Optional[str] = None,
|
@@ -1500,8 +1500,8 @@ class SyncTapleService(BaseTapleService):
|
|
1500
1500
|
Args:
|
1501
1501
|
sheet_id: Sheet ID
|
1502
1502
|
operations: List of operations
|
1503
|
-
sheet_version: Current version for optimistic locking
|
1504
|
-
client_id: Client ID
|
1503
|
+
sheet_version: Current version for optimistic locking (optional, auto-fetched if not provided)
|
1504
|
+
client_id: Client ID (optional, auto-generated if not provided)
|
1505
1505
|
idempotency_key: 幂等性键(可选)
|
1506
1506
|
request_id: 请求ID(可选,如果不提供则自动生成)
|
1507
1507
|
**metadata: Extra metadata
|
@@ -1510,6 +1510,16 @@ class SyncTapleService(BaseTapleService):
|
|
1510
1510
|
BatchEditSheetResponse
|
1511
1511
|
"""
|
1512
1512
|
from ...rpc.gen import taple_service_pb2, taple_service_pb2_grpc
|
1513
|
+
import uuid
|
1514
|
+
|
1515
|
+
# 如果没有提供sheet_version,自动获取
|
1516
|
+
if sheet_version is None:
|
1517
|
+
version_result = self.get_sheet_version(sheet_id=sheet_id, **metadata)
|
1518
|
+
sheet_version = version_result.version
|
1519
|
+
|
1520
|
+
# 如果没有提供client_id,自动生成
|
1521
|
+
if client_id is None:
|
1522
|
+
client_id = str(uuid.uuid4())
|
1513
1523
|
|
1514
1524
|
stub = self.client.get_stub(taple_service_pb2_grpc.TapleServiceStub)
|
1515
1525
|
|
file_hub_client/utils/retry.py
CHANGED
@@ -59,8 +59,12 @@ def retry_with_backoff(
|
|
59
59
|
is_retryable, _ = ErrorClassifier.is_retryable(e)
|
60
60
|
|
61
61
|
if not is_retryable:
|
62
|
+
# 尝试从 kwargs 中获取 request_id
|
63
|
+
request_id = kwargs.get('request_id', 'unknown')
|
64
|
+
|
62
65
|
logger.debug(
|
63
66
|
f"🚫 不可重试错误 | 操作: {func.__name__} | "
|
67
|
+
f"request_id: {request_id} | "
|
64
68
|
f"错误: {type(e).__name__}: {str(e)} | "
|
65
69
|
f"直接抛出异常"
|
66
70
|
)
|
@@ -76,8 +80,12 @@ def retry_with_backoff(
|
|
76
80
|
# HTTP 错误
|
77
81
|
error_details = f"HTTP {e.response.status_code}: {str(e)}"
|
78
82
|
|
83
|
+
# 尝试从 kwargs 中获取 request_id
|
84
|
+
request_id = kwargs.get('request_id', 'unknown')
|
85
|
+
|
79
86
|
logger.warning(
|
80
87
|
f"🔄 触发重试 | 操作: {func.__name__} | "
|
88
|
+
f"request_id: {request_id} | "
|
81
89
|
f"尝试: {attempt + 1}/{max_retries + 1} | "
|
82
90
|
f"错误类型: {type(e).__name__} | "
|
83
91
|
f"错误详情: {error_details} | "
|
@@ -86,8 +94,12 @@ def retry_with_backoff(
|
|
86
94
|
await asyncio.sleep(delay)
|
87
95
|
delay = min(delay * backoff_factor, max_delay)
|
88
96
|
else:
|
97
|
+
# 尝试从 kwargs 中获取 request_id
|
98
|
+
request_id = kwargs.get('request_id', 'unknown')
|
99
|
+
|
89
100
|
logger.error(
|
90
101
|
f"❌ 重试失败 | 操作: {func.__name__} | "
|
102
|
+
f"request_id: {request_id} | "
|
91
103
|
f"已达最大重试次数: {max_retries} | "
|
92
104
|
f"最终错误: {type(e).__name__}: {str(e)}"
|
93
105
|
)
|
@@ -111,8 +123,12 @@ def retry_with_backoff(
|
|
111
123
|
is_retryable, _ = ErrorClassifier.is_retryable(e)
|
112
124
|
|
113
125
|
if not is_retryable:
|
126
|
+
# 尝试从 kwargs 中获取 request_id
|
127
|
+
request_id = kwargs.get('request_id', 'unknown')
|
128
|
+
|
114
129
|
logger.debug(
|
115
130
|
f"🚫 不可重试错误 | 操作: {func.__name__} | "
|
131
|
+
f"request_id: {request_id} | "
|
116
132
|
f"错误: {type(e).__name__}: {str(e)} | "
|
117
133
|
f"直接抛出异常"
|
118
134
|
)
|
@@ -128,8 +144,12 @@ def retry_with_backoff(
|
|
128
144
|
# HTTP 错误
|
129
145
|
error_details = f"HTTP {e.response.status_code}: {str(e)}"
|
130
146
|
|
147
|
+
# 尝试从 kwargs 中获取 request_id
|
148
|
+
request_id = kwargs.get('request_id', 'unknown')
|
149
|
+
|
131
150
|
logger.warning(
|
132
151
|
f"🔄 触发重试 | 操作: {func.__name__} | "
|
152
|
+
f"request_id: {request_id} | "
|
133
153
|
f"尝试: {attempt + 1}/{max_retries + 1} | "
|
134
154
|
f"错误类型: {type(e).__name__} | "
|
135
155
|
f"错误详情: {error_details} | "
|
@@ -138,8 +158,12 @@ def retry_with_backoff(
|
|
138
158
|
time.sleep(delay)
|
139
159
|
delay = min(delay * backoff_factor, max_delay)
|
140
160
|
else:
|
161
|
+
# 尝试从 kwargs 中获取 request_id
|
162
|
+
request_id = kwargs.get('request_id', 'unknown')
|
163
|
+
|
141
164
|
logger.error(
|
142
165
|
f"❌ 重试失败 | 操作: {func.__name__} | "
|
166
|
+
f"request_id: {request_id} | "
|
143
167
|
f"已达最大重试次数: {max_retries} | "
|
144
168
|
f"最终错误: {type(e).__name__}: {str(e)}"
|
145
169
|
)
|
@@ -193,8 +217,12 @@ def retry_on_lock_conflict(
|
|
193
217
|
if 'error_message' in result:
|
194
218
|
conflict_details += f" - {result['error_message']}"
|
195
219
|
|
220
|
+
# 尝试从 kwargs 中获取 request_id
|
221
|
+
request_id = kwargs.get('request_id', 'unknown')
|
222
|
+
|
196
223
|
logger.warning(
|
197
224
|
f"🔒 锁冲突重试 | 操作: {func.__name__} | "
|
225
|
+
f"request_id: {request_id} | "
|
198
226
|
f"尝试: {attempt + 1}/{max_retries + 1} | "
|
199
227
|
f"冲突详情: {conflict_details} | "
|
200
228
|
f"延迟: {delay:.1f}秒"
|
@@ -203,8 +231,12 @@ def retry_on_lock_conflict(
|
|
203
231
|
delay = min(delay * backoff_factor, max_delay)
|
204
232
|
continue
|
205
233
|
else:
|
234
|
+
# 尝试从 kwargs 中获取 request_id
|
235
|
+
request_id = kwargs.get('request_id', 'unknown')
|
236
|
+
|
206
237
|
logger.error(
|
207
238
|
f"❌ 锁冲突重试失败 | 操作: {func.__name__} | "
|
239
|
+
f"request_id: {request_id} | "
|
208
240
|
f"已达最大重试次数: {max_retries} | "
|
209
241
|
f"返回最后的冲突结果"
|
210
242
|
)
|
@@ -238,8 +270,12 @@ def retry_on_lock_conflict(
|
|
238
270
|
if 'error_message' in result:
|
239
271
|
conflict_details += f" - {result['error_message']}"
|
240
272
|
|
273
|
+
# 尝试从 kwargs 中获取 request_id
|
274
|
+
request_id = kwargs.get('request_id', 'unknown')
|
275
|
+
|
241
276
|
logger.warning(
|
242
277
|
f"🔒 锁冲突重试 | 操作: {func.__name__} | "
|
278
|
+
f"request_id: {request_id} | "
|
243
279
|
f"尝试: {attempt + 1}/{max_retries + 1} | "
|
244
280
|
f"冲突详情: {conflict_details} | "
|
245
281
|
f"延迟: {delay:.1f}秒"
|
@@ -248,8 +284,12 @@ def retry_on_lock_conflict(
|
|
248
284
|
delay = min(delay * backoff_factor, max_delay)
|
249
285
|
continue
|
250
286
|
else:
|
287
|
+
# 尝试从 kwargs 中获取 request_id
|
288
|
+
request_id = kwargs.get('request_id', 'unknown')
|
289
|
+
|
251
290
|
logger.error(
|
252
291
|
f"❌ 锁冲突重试失败 | 操作: {func.__name__} | "
|
292
|
+
f"request_id: {request_id} | "
|
253
293
|
f"已达最大重试次数: {max_retries} | "
|
254
294
|
f"返回最后的冲突结果"
|
255
295
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
file_hub_client/__init__.py,sha256=5pOOgw8YLzsQ49o81j5xCFtiH7VHFObNlbAYZwsU7ts,2918
|
2
|
-
file_hub_client/client.py,sha256=
|
2
|
+
file_hub_client/client.py,sha256=kOis7hw0WAi-YAmEM_1PEzp0hsOD9JSxLbJi2cvTd_o,17338
|
3
3
|
file_hub_client/py.typed,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
4
4
|
file_hub_client/enums/__init__.py,sha256=e3Io6-IC9Nezbdc8H4TzuWqiDw0T1fsdbSi-fsgSQM4,203
|
5
5
|
file_hub_client/enums/export_format.py,sha256=C9P0q8v5eTszUBqKBmERxoA9UrTgLuX3a_bZeUxkdlQ,296
|
@@ -38,20 +38,20 @@ file_hub_client/services/folder/__init__.py,sha256=vGbMOlNiEBdnWZB1xE74RJtoroI28
|
|
38
38
|
file_hub_client/services/folder/async_folder_service.py,sha256=uFEmtW8EXYvaKYT2JCitWbdTGR1EtHlx_eBN5P3JUZg,7293
|
39
39
|
file_hub_client/services/folder/sync_folder_service.py,sha256=T00k1nD0txjOFQXxeIbF_ZOkNUhsBF45sDxyaDk8rf8,7167
|
40
40
|
file_hub_client/services/taple/__init__.py,sha256=AQgYVRXgISye8cRd0J5QEK-5AoepeAw5726esFzs2Gg,199
|
41
|
-
file_hub_client/services/taple/async_taple_service.py,sha256=
|
41
|
+
file_hub_client/services/taple/async_taple_service.py,sha256=yDWJyeEbK0DD2CgtVnl1WV30D6qpf7eqi_E2ujXrsvA,90526
|
42
42
|
file_hub_client/services/taple/base_taple_service.py,sha256=Ker16Lk7TWaRJ6z4OSgR3kMcAQeU3bJawRve8VmflPs,14573
|
43
43
|
file_hub_client/services/taple/idempotent_taple_mixin.py,sha256=lZeMF59dU-KVnc2p7epGrclidCv0nYg8TP_qVUezJ48,4295
|
44
|
-
file_hub_client/services/taple/sync_taple_service.py,sha256=
|
44
|
+
file_hub_client/services/taple/sync_taple_service.py,sha256=qXCCm-JwFD0Xxmn4a6BUnfJADe_CLey3H9PDDd4STIk,86768
|
45
45
|
file_hub_client/utils/__init__.py,sha256=0WS1R9VEPEqIN6_ksHEbO6Eu0G1Ps6oNTuOtoDMdDMM,1832
|
46
46
|
file_hub_client/utils/converter.py,sha256=TX69Bqk-PwNdv2hYQ07_tW6HQnQycHcJkGeRnskeF3A,3734
|
47
47
|
file_hub_client/utils/download_helper.py,sha256=Mc8TQSWjHxIglJMkKlGy9r3LZe8e_Mwe6D3sfn6IOnY,13338
|
48
48
|
file_hub_client/utils/file_utils.py,sha256=Ly8R5KJS_3lbgJxNZkc4sSBKuGgn-fYeh17GEY4pyy8,4359
|
49
49
|
file_hub_client/utils/idempotency.py,sha256=zuXDlpAc9VTkTsarlnkO0VuJ77yON6j1TX0GvL9Xd9k,6029
|
50
50
|
file_hub_client/utils/logging.py,sha256=IxcvWkA0G9s9BMiXIeFAdJX5G-Lc5-JFlS2yxOX1Swo,11741
|
51
|
-
file_hub_client/utils/retry.py,sha256=
|
51
|
+
file_hub_client/utils/retry.py,sha256=A2MBdJCEY-Ks0guq8dd5wXX22sD27N30Qy3nQIW1B_s,18019
|
52
52
|
file_hub_client/utils/smart_retry.py,sha256=RjBhyG6SNDfMXxNxKU_qayWDD6Ihp7ow6_BPjhgflM0,16465
|
53
53
|
file_hub_client/utils/upload_helper.py,sha256=gEtn9OXVJiGUpVev_fqrDnRQ6AFiiP9goLzFrVpqXmU,22569
|
54
|
-
tamar_file_hub_client-0.0.
|
55
|
-
tamar_file_hub_client-0.0.
|
56
|
-
tamar_file_hub_client-0.0.
|
57
|
-
tamar_file_hub_client-0.0.
|
54
|
+
tamar_file_hub_client-0.0.8.dist-info/METADATA,sha256=v5SKeND4uUT_klNENHC9rnYi0gR3MFvdTe6OZVP6B3M,64873
|
55
|
+
tamar_file_hub_client-0.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
56
|
+
tamar_file_hub_client-0.0.8.dist-info/top_level.txt,sha256=9wcR7hyAJQdJg_kuH6WR3nmpJ8O-j8aJNK8f_kcFy6U,16
|
57
|
+
tamar_file_hub_client-0.0.8.dist-info/RECORD,,
|
File without changes
|
{tamar_file_hub_client-0.0.6.dist-info → tamar_file_hub_client-0.0.8.dist-info}/top_level.txt
RENAMED
File without changes
|