cdt-data-uploader 1.0.1__tar.gz

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.

Potentially problematic release.


This version of cdt-data-uploader might be problematic. Click here for more details.

Files changed (32) hide show
  1. cdt_data_uploader-1.0.1/CHANGELOG.md +75 -0
  2. cdt_data_uploader-1.0.1/LICENSE +21 -0
  3. cdt_data_uploader-1.0.1/MANIFEST.in +7 -0
  4. cdt_data_uploader-1.0.1/PKG-INFO +387 -0
  5. cdt_data_uploader-1.0.1/README.md +357 -0
  6. cdt_data_uploader-1.0.1/REQUIREMENTS.txt +3 -0
  7. cdt_data_uploader-1.0.1/cdt_data_uploader.egg-info/PKG-INFO +387 -0
  8. cdt_data_uploader-1.0.1/cdt_data_uploader.egg-info/SOURCES.txt +30 -0
  9. cdt_data_uploader-1.0.1/cdt_data_uploader.egg-info/dependency_links.txt +1 -0
  10. cdt_data_uploader-1.0.1/cdt_data_uploader.egg-info/requires.txt +10 -0
  11. cdt_data_uploader-1.0.1/cdt_data_uploader.egg-info/top_level.txt +1 -0
  12. cdt_data_uploader-1.0.1/examples/basic_upload.py +71 -0
  13. cdt_data_uploader-1.0.1/examples/batch_upload.py +110 -0
  14. cdt_data_uploader-1.0.1/pyproject.toml +62 -0
  15. cdt_data_uploader-1.0.1/setup.cfg +4 -0
  16. cdt_data_uploader-1.0.1/setup.py +52 -0
  17. cdt_data_uploader-1.0.1/tests/__init__.py +3 -0
  18. cdt_data_uploader-1.0.1/tests/conftest.py +97 -0
  19. cdt_data_uploader-1.0.1/tests/run_tests.py +83 -0
  20. cdt_data_uploader-1.0.1/tests/test_client.py +135 -0
  21. cdt_data_uploader-1.0.1/tests/test_exceptions.py +181 -0
  22. cdt_data_uploader-1.0.1/tests/test_models.py +208 -0
  23. cdt_data_uploader-1.0.1/tests/test_sdk.py +283 -0
  24. cdt_data_uploader-1.0.1/tests/test_utils.py +266 -0
  25. cdt_data_uploader-1.0.1/vla_uploader/__init__.py +47 -0
  26. cdt_data_uploader-1.0.1/vla_uploader/client.py +369 -0
  27. cdt_data_uploader-1.0.1/vla_uploader/constants.py +65 -0
  28. cdt_data_uploader-1.0.1/vla_uploader/credentials.py +138 -0
  29. cdt_data_uploader-1.0.1/vla_uploader/exceptions.py +45 -0
  30. cdt_data_uploader-1.0.1/vla_uploader/models.py +116 -0
  31. cdt_data_uploader-1.0.1/vla_uploader/uploader.py +364 -0
  32. cdt_data_uploader-1.0.1/vla_uploader/utils.py +273 -0
@@ -0,0 +1,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial project setup
12
+
13
+ ## [1.0.0] - 2026-08-12
14
+
15
+ ### Added
16
+ - Initial release of VLA Uploader SDK
17
+ - Support for uploading VLA datasets from directories and ZIP files
18
+ - Concurrent upload support with configurable worker threads
19
+ - Automatic retry mechanism for failed uploads
20
+ - Failed upload recovery with retry functionality
21
+ - Comprehensive API documentation
22
+ - Type hints for better code readability
23
+ - Python 3.6+ compatibility using attrs library
24
+ - Complete test suite and examples
25
+
26
+ ### Features
27
+ - **Concurrent Upload**: Multi-threaded upload for improved performance
28
+ - **Auto Retry**: Automatic retry on upload/sync failures with exponential backoff
29
+ - **Failure Recovery**: Save failed upload records for later retry
30
+ - **Flexible Configuration**: Configurable workers, retry attempts, delays, etc.
31
+ - **Comprehensive Logging**: Detailed logging for debugging and monitoring
32
+ - **Type Safety**: Full type annotations for better IDE support
33
+
34
+ ### Supported Formats
35
+ - Video: `.mp4`, `.mov`, `.avi`, `.mkv`, `.webm`
36
+ - Image: `.jpg`, `.jpeg`, `.png`, `.bmp`, `.webp`, `.tif`, `.tiff`
37
+ - Text: `.json`, `.jsonl`
38
+
39
+ ### Dependencies
40
+ - requests >= 2.28.0
41
+ - tos >= 2.5.0
42
+ - attrs >= 21.0.0
43
+
44
+ ### Compatibility
45
+ - Python 3.6+
46
+ - Windows, Linux, macOS
47
+
48
+ ### Documentation
49
+ - Complete README with installation and usage instructions
50
+ - API reference documentation
51
+ - Code examples for basic and advanced usage
52
+ - Publishing guide for PyPI distribution
53
+
54
+ ### Testing
55
+ - Unit tests for core functionality
56
+ - Integration tests for upload workflows
57
+ - Environment compatibility tests
58
+
59
+ ## [0.1.0] - 2026-08-10
60
+
61
+ ### Added
62
+ - Initial project structure
63
+ - Basic upload functionality
64
+ - Core utility functions
65
+
66
+ ---
67
+
68
+ ## Version History
69
+
70
+ - **1.0.0** (2026-08-12): Initial public release
71
+ - **0.1.0** (2026-08-10): Development version
72
+
73
+ [Unreleased]: https://github.com/yourorg/cdt_data_uploader/compare/v1.0.0...HEAD
74
+ [1.0.0]: https://github.com/yourorg/cdt_data_uploader/releases/tag/v1.0.0
75
+ [0.1.0]: https://github.com/yourorg/cdt_data_uploader/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VLA Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include LICENSE
2
+ include README.md
3
+ include REQUIREMENTS.txt
4
+ include CHANGELOG.md
5
+ recursive-include vla_uploader *.py
6
+ recursive-include examples *.py
7
+ recursive-include tests *.py
@@ -0,0 +1,387 @@
1
+ Metadata-Version: 2.1
2
+ Name: cdt_data_uploader
3
+ Version: 1.0.1
4
+ Summary: Python SDK for uploading CDT datasets (VLA, etc.)
5
+ Home-page: https://github.com/yourorg/cdt-data-uploader
6
+ Author: CDT Team
7
+ Author-email: cdt@example.com
8
+ License: UNKNOWN
9
+ Project-URL: Bug Reports, https://github.com/yourorg/cdt-data-uploader/issues
10
+ Project-URL: Source, https://github.com/yourorg/cdt-data-uploader
11
+ Keywords: cdt data uploader sdk machine learning ai vla
12
+ Platform: UNKNOWN
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.6
19
+ Classifier: Programming Language :: Python :: 3.7
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Requires-Python: >=3.6
25
+ Description-Content-Type: text/markdown
26
+ Provides-Extra: dev
27
+ License-File: LICENSE
28
+
29
+ # CDT Data Uploader SDK
30
+
31
+ [![Python 3.6+](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
+
34
+ 一个用于上传CDT数据集的Python SDK,支持VLA(Visual Language Action)等多种数据格式,提供并发上传、自动重试和失败恢复功能。
35
+
36
+ ## 特性
37
+
38
+ - ✅ **并发上传** - 支持多线程并发上传,提高效率
39
+ - ✅ **自动重试** - 上传失败时自动重试,支持可配置的重试次数和延迟
40
+ - ✅ **失败恢复** - 记录失败的上传任务,支持后续重试
41
+ - ✅ **灵活配置** - 支持多种配置参数,满足不同场景需求
42
+ - ✅ **完整日志** - 提供详细的日志输出,便于调试和监控
43
+ - ✅ **类型提示** - 完整的类型注解,提高代码可读性
44
+ - ✅ **Python 3.6+兼容** - 使用attrs库兼容Python 3.6及以上版本
45
+
46
+ ## 安装
47
+
48
+ ```bash
49
+ pip install cdt_data_uploader
50
+ ```
51
+
52
+ ## 依赖
53
+
54
+ - Python 3.6+
55
+ - `requests>=2.20.0` - HTTP请求库
56
+ - `tos>=2.5.0` - 腾讯云对象存储SDK
57
+ - `attrs>=21.0.0` - 数据类库(兼容Python 3.6)
58
+
59
+ **兼容性:** Windows/Linux/macOS
60
+
61
+ ## 模块说明
62
+
63
+ SDK包含以下数据上传模块:
64
+
65
+ - **vla_uploader** - VLA (Visual Language Action) 数据上传
66
+ - 更多数据格式支持即将推出...
67
+
68
+ ## 快速开始
69
+
70
+ ### 1. 导入SDK
71
+
72
+ ```python
73
+ from vla_uploader import VLAUploader
74
+ ```
75
+
76
+ ### 2. 初始化上传器
77
+
78
+ ```python
79
+ uploader = VLAUploader(
80
+ api_key="your_api_key", # 从系统管理员获取
81
+ dataset_id="your_dataset_id", # 数据集ID
82
+ api_base="https://nebula.core-dt.com/api/v1", # API地址
83
+ workers=4 # 并发线程数
84
+ )
85
+ ```
86
+
87
+ ### 3. 上传数据
88
+
89
+ #### 上传目录
90
+
91
+ ```python
92
+ # 上传整个目录
93
+ result = uploader.upload_directory("./dataset")
94
+
95
+ # 查看结果
96
+ print(f"总数: {result.total_rows}")
97
+ print(f"成功: {result.success_count}")
98
+ print(f"失败: {result.failure_count}")
99
+ print(f"成功率: {result.success_rate:.2f}%")
100
+ ```
101
+
102
+ #### 上传ZIP文件
103
+
104
+ ```python
105
+ # 上传ZIP压缩包
106
+ result = uploader.upload_zip(
107
+ zip_path="./dataset.zip",
108
+ workers=4
109
+ )
110
+ ```
111
+
112
+ #### 重试失败的上传
113
+
114
+ ```python
115
+ # SDK自动记录失败的上传,可以重试
116
+ result = uploader.retry_failed("./.vla_upload_work/run-xxx/failed_rows.json")
117
+ ```
118
+
119
+ ## 使用场景
120
+
121
+ ### 场景1: 首次上传VLA数据集
122
+
123
+ ```python
124
+ from vla_uploader import VLAUploader
125
+
126
+ # 1. 初始化
127
+ uploader = VLAUploader(
128
+ api_key="your_api_key",
129
+ dataset_id="your_dataset_id"
130
+ )
131
+
132
+ # 2. 准备数据目录结构
133
+ # dataset/
134
+ # ├── episode_0001/
135
+ # │ ├── data/
136
+ # │ │ ├── video/front.mp4
137
+ # │ │ ├── actions/actions.jsonl
138
+ # │ │ └── depth/frame_000001.png
139
+ # └── episode_0002/
140
+
141
+ # 3. 上传
142
+ result = uploader.upload_directory("./dataset")
143
+
144
+ # 4. 检查结果
145
+ if result.success_rate == 100.0:
146
+ print("✅ 所有数据上传成功!")
147
+ else:
148
+ print(f"⚠️ 部分失败: {result.failure_count} 行")
149
+ for failed in result.failed_rows:
150
+ print(f" 失败: {failed.row_name} - {failed.error}")
151
+ ```
152
+
153
+ ### 场景2: 上传ZIP压缩包并记录源路径
154
+
155
+ ```python
156
+ # 适用于数据集已经打包成ZIP的情况
157
+ result = uploader.upload_zip(
158
+ zip_path="./my_dataset.zip",
159
+ source_path="D:/raw/my_dataset.zip", # 原始路径
160
+ cloud_source_path="tos://bucket/raw/my_dataset.zip" # 云端路径
161
+ )
162
+ ```
163
+
164
+ ### 场景3: 并发上传大型数据集
165
+
166
+ ```python
167
+ # 增加并发数以提高上传速度
168
+ uploader = VLAUploader(
169
+ api_key="your_api_key",
170
+ dataset_id="your_dataset_id",
171
+ workers=8 # 8个并发线程
172
+ )
173
+
174
+ result = uploader.upload_directory("./large_dataset")
175
+ ```
176
+
177
+ ### 场景4: 重试失败的上传
178
+
179
+ ```python
180
+ import glob
181
+
182
+ # 查找最新的失败记录
183
+ failed_files = glob.glob("./.vla_upload_work/run-*/failed_rows.json")
184
+ if failed_files:
185
+ latest_failed = max(failed_files)
186
+ print(f"重试: {latest_failed}")
187
+
188
+ result = uploader.retry_failed(latest_failed)
189
+ print(f"重试结果: {result.success_count}/{result.total_rows}")
190
+ ```
191
+
192
+ ### 场景5: 批量处理多个数据集
193
+
194
+ ```python
195
+ datasets = [
196
+ "./dataset1",
197
+ "./dataset2.zip",
198
+ "./dataset3"
199
+ ]
200
+
201
+ for dataset_path in datasets:
202
+ print(f"\n处理: {dataset_path}")
203
+
204
+ try:
205
+ if dataset_path.endswith(".zip"):
206
+ result = uploader.upload_zip(dataset_path)
207
+ else:
208
+ result = uploader.upload_directory(dataset_path)
209
+
210
+ if result.success_rate == 100.0:
211
+ print(f"✅ 成功: {result.success_count} 行")
212
+ else:
213
+ print(f"⚠️ 部分失败: {result.failure_count} 行")
214
+
215
+ except Exception as e:
216
+ print(f"❌ 失败: {e}")
217
+ ```
218
+
219
+ ## API参考
220
+
221
+ ### 主要方法
222
+
223
+ #### `upload_directory(data_path, workers=None, ...)`
224
+
225
+ 上传目录中的VLA数据
226
+
227
+ **参数:**
228
+
229
+ - `data_path` - 数据目录路径
230
+ - `workers` - 并发线程数(默认3)
231
+ - `source_path` - 原始路径(可选)
232
+ - `cloud_source_path` - 云端路径(可选)
233
+
234
+ **返回:** `BatchUploadResult` 对象
235
+
236
+ #### `upload_zip(zip_path, workers=None, ...)`
237
+
238
+ 上传ZIP压缩包
239
+
240
+ **参数:** 同上
241
+
242
+ #### `retry_failed(failed_json_path)`
243
+
244
+ 重试失败的上传
245
+
246
+ **参数:**
247
+
248
+ - `failed_json_path` - 失败记录文件路径
249
+
250
+ ### 返回结果
251
+
252
+ #### `BatchUploadResult`
253
+
254
+ ```python
255
+ result.total_rows # 总行数
256
+ result.success_count # 成功数量
257
+ result.failure_count # 失败数量
258
+ result.success_rate # 成功率(%)
259
+ result.succeeded_rows # 成功的行列表
260
+ result.failed_rows # 失败的行列表
261
+ ```
262
+
263
+ #### `UploadResult`
264
+
265
+ ```python
266
+ row.success # 是否成功
267
+ row.row_name # 行名称
268
+ row.datarow_id # 数据行ID
269
+ row.error # 错误信息(如果失败)
270
+ ```
271
+
272
+ ## 数据格式要求
273
+
274
+ SDK要求VLA数据集遵循以下目录结构:
275
+
276
+ ```
277
+ dataset/
278
+ ├── episode_0001/
279
+ │ ├── data/
280
+ │ │ ├── video/
281
+ │ │ │ └── front.mp4
282
+ │ │ ├── actions/
283
+ │ │ │ └── actions.jsonl
284
+ │ │ ├── depth/
285
+ │ │ │ └── frame_000001.png
286
+ │ │ └── camera_params.json
287
+ │ └── manifest.json (可选)
288
+ ├── episode_0002/
289
+ │ └── ...
290
+ ```
291
+
292
+ **必需文件:**
293
+
294
+ - 每个episode必须包含至少一个视频文件
295
+ - 视频文件位于 `data/video/` 或 `video/` 目录
296
+
297
+ **支持的格式:**
298
+
299
+ - 视频: `.mp4`, `.mov`, `.avi`, `.mkv`, `.webm`
300
+ - 图像: `.jpg`, `.jpeg`, `.png`, `.bmp`, `.webp`, `.tif`, `.tiff`
301
+ - 文本: `.json`, `.jsonl`
302
+
303
+ ## 配置参数
304
+
305
+ SDK支持以下配置:
306
+
307
+ ```python
308
+ uploader = VLAUploader(
309
+ api_key="...", # 必需:API密钥
310
+ dataset_id="...", # 必需:数据集ID
311
+
312
+ # 可选配置
313
+ api_base="https://...", # API地址
314
+ workers=4, # 并发线程数(默认3)
315
+
316
+ # 重试配置
317
+ max_upload_attempts=5, # 上传重试次数(默认5)
318
+ max_sync_attempts=3, # 同步重试次数(默认3)
319
+
320
+ # 其他配置
321
+ media_type="video", # 媒体类型(默认video)
322
+ dedupe_by_filename=True # 按文件名去重(默认True)
323
+ )
324
+ ```
325
+
326
+ ## 故障排查
327
+
328
+ ### 常见问题
329
+
330
+ **Q: 上传失败怎么办?**
331
+
332
+ ```python
333
+ # SDK自动保存失败记录到 .vla_upload_work/run-*/failed_rows.json
334
+ # 可以重试:
335
+ result = uploader.retry_failed("./.vla_upload_work/run-xxx/failed_rows.json")
336
+ ```
337
+
338
+ **Q: 如何查看详细日志?**
339
+
340
+ ```python
341
+ import logging
342
+ logging.basicConfig(level=logging.DEBUG)
343
+ ```
344
+
345
+ **Q: 如何调整并发数?**
346
+
347
+ ```python
348
+ # 根据网络带宽和服务器性能调整
349
+ uploader = VLAUploader(..., workers=8) # 增加
350
+ uploader = VLAUploader(..., workers=1) # 减少
351
+ ```
352
+
353
+ **Q: 如何获取API密钥?**
354
+ 联系系统管理员获取API密钥和数据集ID。
355
+
356
+ ### 错误处理
357
+
358
+ ```python
359
+ from vla_uploader import VLAUploader, UploadError, CredentialError
360
+
361
+ try:
362
+ result = uploader.upload_directory("./dataset")
363
+ except CredentialError as e:
364
+ print(f"凭证错误: {e}")
365
+ print("请检查API密钥是否正确")
366
+ except UploadError as e:
367
+ print(f"上传错误: {e}")
368
+ print("请检查网络连接和数据格式")
369
+ ```
370
+
371
+ ## 更多信息
372
+
373
+ - **项目地址**: https://github.com/yourorg/cdt-data-uploader
374
+ - **问题反馈**: https://github.com/yourorg/cdt-data-uploader/issues
375
+ - **许可证**: MIT License
376
+
377
+ ## 版本历史
378
+
379
+ - **v1.0.1** (2026-08-12): 修正包名,重新发版
380
+ - 统一包名为 cdt_data_uploader(下划线)
381
+ - 支持目录和ZIP文件上传
382
+ - 支持并发上传和自动重试
383
+ - 支持失败恢复
384
+ - Python 3.6+兼容
385
+ - **v1.0.0** (2026-08-12): 首次发布(包名有误,已废弃)
386
+
387
+