current-data-py 0.1.13__tar.gz → 0.1.14__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.
- {current_data_py-0.1.13/current_data_py.egg-info → current_data_py-0.1.14}/PKG-INFO +40 -2
- {current_data_py-0.1.13 → current_data_py-0.1.14}/README.md +39 -1
- current_data_py-0.1.14/_multipart.py +52 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14/current_data_py.egg-info}/PKG-INFO +40 -2
- {current_data_py-0.1.13 → current_data_py-0.1.14}/current_data_py.egg-info/SOURCES.txt +2 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/management.py +12 -1
- {current_data_py-0.1.13 → current_data_py-0.1.14}/oss.py +34 -5
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/management/metadata/metadata_pb2.py +16 -16
- current_data_py-0.1.14/proto_gen/python/msg/custom_msgs/keypoints_validity_pb2.py +26 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/pyproject.toml +1 -1
- {current_data_py-0.1.13 → current_data_py-0.1.14}/schema/__init__.py +2 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_management.py +16 -1
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tos.py +23 -2
- {current_data_py-0.1.13 → current_data_py-0.1.14}/MANIFEST.in +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/__init__.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/current_data_py.egg-info/dependency_links.txt +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/current_data_py.egg-info/requires.txt +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/current_data_py.egg-info/top_level.txt +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/decoding.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/examples/__init__.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/examples/list_schemas.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/examples/read_remote_td.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/examples/read_td.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/examples/write_td.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/labeling.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/service/service_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/service/service_pb2_grpc.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/task/task_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/template/template_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/management/selection/selection_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/management/service/service_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/management/service/service_pb2_grpc.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/builtin_interfaces/duration_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/builtin_interfaces/time_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/joint_current_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/pose_rpy_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/slam_quality_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/sonic_frame_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/subtask_description_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/target_quality_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/foxglove/compressed_audio_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/foxglove/compressed_video_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/point32_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/point_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_array_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_with_covariance_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_with_covariance_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/quaternion_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/transform_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/transform_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/twist_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/twist_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/twist_with_covariance_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/twist_with_covariance_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/vector3_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/wrench_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/wrench_stamped_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/map_meta_data_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/occupancy_grid_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/odometry_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/path_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/battery_state_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/camera_info_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/compressed_image_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/image_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/imu_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/joint_state_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/laser_scan_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/nav_sat_fix_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/nav_sat_status_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/point_cloud2_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/point_field_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/range_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/region_of_interest_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/bool_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/color_rgba_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/float32_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/float64_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/header_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/int32_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/string_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/uint32_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/tf2_msgs/tf_message_pb2.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/remote/__init__.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/remote/client.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/remote/source.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/remote/tos_source.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/schema/message_metadata.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/setup.cfg +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/setup.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_environment.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_labeling.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_oss.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_package.py +0 -0
- {current_data_py-0.1.13 → current_data_py-0.1.14}/tests/check_remote.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: current-data-py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: Current Data protobuf messages and schema metadata
|
|
5
5
|
Requires-Python: >=3.9
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -49,6 +49,44 @@ Set `ENV=test` before the first SDK import to select the test service; an unset
|
|
|
49
49
|
empty value defaults to production. An explicit client `address=` overrides the
|
|
50
50
|
default. Remote examples require service connectivity and accessible data.
|
|
51
51
|
|
|
52
|
+
## Upload files
|
|
53
|
+
|
|
54
|
+
Use `OSSClient` or `TOSClient` with upload permission. The management service
|
|
55
|
+
selects the bucket and allowed object prefix; keep it open during transfers:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from current_data_py.management import ManagementClient
|
|
59
|
+
from current_data_py.tos import TOSClient
|
|
60
|
+
|
|
61
|
+
with ManagementClient() as management:
|
|
62
|
+
with TOSClient(management, permission="upload", data_type="YAM",
|
|
63
|
+
data_kind="CONVERTED") as storage:
|
|
64
|
+
storage.upload_file(storage.object_prefix + "recording.td", "/data/recording.td",
|
|
65
|
+
multipart_threshold=100 * 1024**2,
|
|
66
|
+
part_size=16 * 1024**2, max_workers=4)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Both clients accept the same transfer options. Files at or above
|
|
70
|
+
`multipart_threshold` use multipart upload; `0` forces multipart for nonempty
|
|
71
|
+
files. Empty files always use PutObject. Sizes are in bytes. `part_size` must be
|
|
72
|
+
5 MiB–5 GiB, and the file must fit within 10,000 parts; increase it for larger
|
|
73
|
+
files. `max_workers` controls parallel requests (1–64); part buffers use roughly
|
|
74
|
+
`part_size * max_workers` memory, plus SDK overhead. Do not modify the source
|
|
75
|
+
file during upload.
|
|
76
|
+
|
|
77
|
+
Uploads reject existing objects by default, including when completing multipart
|
|
78
|
+
uploads. Set `forbid_overwrite=False` to replace one. Content type and metadata
|
|
79
|
+
are preserved. The return value is the provider's PutObject result for small
|
|
80
|
+
files or CompleteMultipartUpload result for multipart files.
|
|
81
|
+
|
|
82
|
+
Failed multipart transfers attempt to abort and delete incomplete parts. A failed
|
|
83
|
+
cleanup emits a warning; check the bucket's incomplete uploads. The upload role
|
|
84
|
+
and its scoped STS policy must allow `oss:AbortMultipartUpload` or
|
|
85
|
+
`tos:AbortMultipartUpload` in addition to PutObject. Deploy the management-service
|
|
86
|
+
policy update and ensure the underlying cloud role permits cleanup before use.
|
|
87
|
+
There is no persistent checkpoint: a later call starts a new upload. Uploading
|
|
88
|
+
does not register the data; call `ManagementClient.register_data` separately.
|
|
89
|
+
|
|
52
90
|
## Test changes
|
|
53
91
|
|
|
54
92
|
The package bundles generated Protobuf modules during its build. After protocol
|
|
@@ -65,7 +103,7 @@ shared dependencies are left unchanged:
|
|
|
65
103
|
(cd current_data_py && python -m build --no-isolation --outdir "$sdk_dist")
|
|
66
104
|
python current_data_py/tests/check_distribution.py --dist-dir "$sdk_dist"
|
|
67
105
|
python -m pip install --no-deps --force-reinstall "$sdk_dist"/*.whl
|
|
68
|
-
for check in package environment management labeling remote oss tos decoding; do
|
|
106
|
+
for check in package environment management labeling remote oss tos decoding multipart; do
|
|
69
107
|
python -I "current_data_py/tests/check_${check}.py"
|
|
70
108
|
done
|
|
71
109
|
)
|
|
@@ -35,6 +35,44 @@ Set `ENV=test` before the first SDK import to select the test service; an unset
|
|
|
35
35
|
empty value defaults to production. An explicit client `address=` overrides the
|
|
36
36
|
default. Remote examples require service connectivity and accessible data.
|
|
37
37
|
|
|
38
|
+
## Upload files
|
|
39
|
+
|
|
40
|
+
Use `OSSClient` or `TOSClient` with upload permission. The management service
|
|
41
|
+
selects the bucket and allowed object prefix; keep it open during transfers:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from current_data_py.management import ManagementClient
|
|
45
|
+
from current_data_py.tos import TOSClient
|
|
46
|
+
|
|
47
|
+
with ManagementClient() as management:
|
|
48
|
+
with TOSClient(management, permission="upload", data_type="YAM",
|
|
49
|
+
data_kind="CONVERTED") as storage:
|
|
50
|
+
storage.upload_file(storage.object_prefix + "recording.td", "/data/recording.td",
|
|
51
|
+
multipart_threshold=100 * 1024**2,
|
|
52
|
+
part_size=16 * 1024**2, max_workers=4)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Both clients accept the same transfer options. Files at or above
|
|
56
|
+
`multipart_threshold` use multipart upload; `0` forces multipart for nonempty
|
|
57
|
+
files. Empty files always use PutObject. Sizes are in bytes. `part_size` must be
|
|
58
|
+
5 MiB–5 GiB, and the file must fit within 10,000 parts; increase it for larger
|
|
59
|
+
files. `max_workers` controls parallel requests (1–64); part buffers use roughly
|
|
60
|
+
`part_size * max_workers` memory, plus SDK overhead. Do not modify the source
|
|
61
|
+
file during upload.
|
|
62
|
+
|
|
63
|
+
Uploads reject existing objects by default, including when completing multipart
|
|
64
|
+
uploads. Set `forbid_overwrite=False` to replace one. Content type and metadata
|
|
65
|
+
are preserved. The return value is the provider's PutObject result for small
|
|
66
|
+
files or CompleteMultipartUpload result for multipart files.
|
|
67
|
+
|
|
68
|
+
Failed multipart transfers attempt to abort and delete incomplete parts. A failed
|
|
69
|
+
cleanup emits a warning; check the bucket's incomplete uploads. The upload role
|
|
70
|
+
and its scoped STS policy must allow `oss:AbortMultipartUpload` or
|
|
71
|
+
`tos:AbortMultipartUpload` in addition to PutObject. Deploy the management-service
|
|
72
|
+
policy update and ensure the underlying cloud role permits cleanup before use.
|
|
73
|
+
There is no persistent checkpoint: a later call starts a new upload. Uploading
|
|
74
|
+
does not register the data; call `ManagementClient.register_data` separately.
|
|
75
|
+
|
|
38
76
|
## Test changes
|
|
39
77
|
|
|
40
78
|
The package bundles generated Protobuf modules during its build. After protocol
|
|
@@ -51,7 +89,7 @@ shared dependencies are left unchanged:
|
|
|
51
89
|
(cd current_data_py && python -m build --no-isolation --outdir "$sdk_dist")
|
|
52
90
|
python current_data_py/tests/check_distribution.py --dist-dir "$sdk_dist"
|
|
53
91
|
python -m pip install --no-deps --force-reinstall "$sdk_dist"/*.whl
|
|
54
|
-
for check in package environment management labeling remote oss tos decoding; do
|
|
92
|
+
for check in package environment management labeling remote oss tos decoding multipart; do
|
|
55
93
|
python -I "current_data_py/tests/check_${check}.py"
|
|
56
94
|
done
|
|
57
95
|
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Bounded-memory multipart scheduling shared by OSS and TOS."""
|
|
2
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
3
|
+
import os
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def upload_size(path, threshold, part_size, max_workers):
|
|
8
|
+
for name, value, minimum, maximum in (
|
|
9
|
+
("multipart_threshold", threshold, 0, 5 * 1024**3),
|
|
10
|
+
("part_size", part_size, 5 * 1024**2, 5 * 1024**3),
|
|
11
|
+
("max_workers", max_workers, 1, 64),
|
|
12
|
+
):
|
|
13
|
+
if isinstance(value, bool) or not isinstance(value, int) or not minimum <= value <= maximum:
|
|
14
|
+
raise ValueError(f"{name} must be an integer between {minimum} and {maximum}")
|
|
15
|
+
size = os.stat(path).st_size
|
|
16
|
+
if (size + part_size - 1) // part_size > 10000:
|
|
17
|
+
raise ValueError("Upload exceeds 10000 parts; increase part_size")
|
|
18
|
+
return size
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def transfer(path, size, part_size, max_workers, start, put, complete, abort):
|
|
22
|
+
# Verify the file before creating any remote upload. Each worker opens its
|
|
23
|
+
# own handle and retains at most one part; queued tasks contain only offsets.
|
|
24
|
+
with open(path, "rb") as source:
|
|
25
|
+
before = os.fstat(source.fileno())
|
|
26
|
+
if before.st_size != size:
|
|
27
|
+
raise ValueError("Upload source changed before transfer")
|
|
28
|
+
upload_id = start()
|
|
29
|
+
|
|
30
|
+
def send(number):
|
|
31
|
+
offset = (number - 1) * part_size
|
|
32
|
+
length = min(part_size, size - offset)
|
|
33
|
+
with open(path, "rb") as source:
|
|
34
|
+
source.seek(offset)
|
|
35
|
+
data = source.read(length)
|
|
36
|
+
if len(data) != length:
|
|
37
|
+
raise ValueError("Upload source changed during transfer")
|
|
38
|
+
return number, put(upload_id, number, data)
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
with ThreadPoolExecutor(max_workers=max_workers) as pool:
|
|
42
|
+
parts = list(pool.map(send, range(1, (size + part_size - 1) // part_size + 1)))
|
|
43
|
+
after = os.stat(path)
|
|
44
|
+
if (before.st_size, before.st_mtime_ns, before.st_ino) != (after.st_size, after.st_mtime_ns, after.st_ino):
|
|
45
|
+
raise ValueError("Upload source changed during transfer")
|
|
46
|
+
return complete(upload_id, parts)
|
|
47
|
+
except BaseException:
|
|
48
|
+
try:
|
|
49
|
+
abort(upload_id)
|
|
50
|
+
except Exception:
|
|
51
|
+
warnings.warn("Multipart cleanup failed; incomplete parts may remain in storage", RuntimeWarning)
|
|
52
|
+
raise
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: current-data-py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: Current Data protobuf messages and schema metadata
|
|
5
5
|
Requires-Python: >=3.9
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -49,6 +49,44 @@ Set `ENV=test` before the first SDK import to select the test service; an unset
|
|
|
49
49
|
empty value defaults to production. An explicit client `address=` overrides the
|
|
50
50
|
default. Remote examples require service connectivity and accessible data.
|
|
51
51
|
|
|
52
|
+
## Upload files
|
|
53
|
+
|
|
54
|
+
Use `OSSClient` or `TOSClient` with upload permission. The management service
|
|
55
|
+
selects the bucket and allowed object prefix; keep it open during transfers:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from current_data_py.management import ManagementClient
|
|
59
|
+
from current_data_py.tos import TOSClient
|
|
60
|
+
|
|
61
|
+
with ManagementClient() as management:
|
|
62
|
+
with TOSClient(management, permission="upload", data_type="YAM",
|
|
63
|
+
data_kind="CONVERTED") as storage:
|
|
64
|
+
storage.upload_file(storage.object_prefix + "recording.td", "/data/recording.td",
|
|
65
|
+
multipart_threshold=100 * 1024**2,
|
|
66
|
+
part_size=16 * 1024**2, max_workers=4)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Both clients accept the same transfer options. Files at or above
|
|
70
|
+
`multipart_threshold` use multipart upload; `0` forces multipart for nonempty
|
|
71
|
+
files. Empty files always use PutObject. Sizes are in bytes. `part_size` must be
|
|
72
|
+
5 MiB–5 GiB, and the file must fit within 10,000 parts; increase it for larger
|
|
73
|
+
files. `max_workers` controls parallel requests (1–64); part buffers use roughly
|
|
74
|
+
`part_size * max_workers` memory, plus SDK overhead. Do not modify the source
|
|
75
|
+
file during upload.
|
|
76
|
+
|
|
77
|
+
Uploads reject existing objects by default, including when completing multipart
|
|
78
|
+
uploads. Set `forbid_overwrite=False` to replace one. Content type and metadata
|
|
79
|
+
are preserved. The return value is the provider's PutObject result for small
|
|
80
|
+
files or CompleteMultipartUpload result for multipart files.
|
|
81
|
+
|
|
82
|
+
Failed multipart transfers attempt to abort and delete incomplete parts. A failed
|
|
83
|
+
cleanup emits a warning; check the bucket's incomplete uploads. The upload role
|
|
84
|
+
and its scoped STS policy must allow `oss:AbortMultipartUpload` or
|
|
85
|
+
`tos:AbortMultipartUpload` in addition to PutObject. Deploy the management-service
|
|
86
|
+
policy update and ensure the underlying cloud role permits cleanup before use.
|
|
87
|
+
There is no persistent checkpoint: a later call starts a new upload. Uploading
|
|
88
|
+
does not register the data; call `ManagementClient.register_data` separately.
|
|
89
|
+
|
|
52
90
|
## Test changes
|
|
53
91
|
|
|
54
92
|
The package bundles generated Protobuf modules during its build. After protocol
|
|
@@ -65,7 +103,7 @@ shared dependencies are left unchanged:
|
|
|
65
103
|
(cd current_data_py && python -m build --no-isolation --outdir "$sdk_dist")
|
|
66
104
|
python current_data_py/tests/check_distribution.py --dist-dir "$sdk_dist"
|
|
67
105
|
python -m pip install --no-deps --force-reinstall "$sdk_dist"/*.whl
|
|
68
|
-
for check in package environment management labeling remote oss tos decoding; do
|
|
106
|
+
for check in package environment management labeling remote oss tos decoding multipart; do
|
|
69
107
|
python -I "current_data_py/tests/check_${check}.py"
|
|
70
108
|
done
|
|
71
109
|
)
|
|
@@ -80,7 +80,7 @@ class ManagementClient:
|
|
|
80
80
|
"""Fetch an upload destination and credentials; omitted data_type means RAW.
|
|
81
81
|
|
|
82
82
|
Accepts metadata DataType integers or names such as "RAW" and
|
|
83
|
-
"CURRENT_V2". The server owns the mapping and rejects unmapped types.
|
|
83
|
+
"CURRENT_V2", or "PICO_GLOVE". The server owns the mapping and rejects unmapped types.
|
|
84
84
|
No credentials are cached here; timeout is in seconds.
|
|
85
85
|
"""
|
|
86
86
|
if isinstance(data_type, str):
|
|
@@ -154,6 +154,17 @@ class ManagementClient:
|
|
|
154
154
|
service_pb2.RegisterDataRequest(data=data), timeout=timeout, metadata=metadata,
|
|
155
155
|
).data
|
|
156
156
|
|
|
157
|
+
def get_data(
|
|
158
|
+
self, data_id: str, *, timeout: Optional[float] = 30,
|
|
159
|
+
metadata: _CallMetadata = None,
|
|
160
|
+
) -> Metadata:
|
|
161
|
+
"""Return one registered data record by its stable data ID."""
|
|
162
|
+
if not isinstance(data_id, str) or not data_id or data_id != data_id.strip():
|
|
163
|
+
raise ValueError("data_id must be a nonempty string without surrounding whitespace")
|
|
164
|
+
return self.stub.GetData(
|
|
165
|
+
service_pb2.GetDataRequest(data_id=data_id), timeout=timeout, metadata=metadata,
|
|
166
|
+
).data
|
|
167
|
+
|
|
157
168
|
def get_read_credentials(
|
|
158
169
|
self, *, bucket: str = "", timeout: Optional[float] = 30, metadata: _CallMetadata = None,
|
|
159
170
|
) -> GetReadCredentialsResponse:
|
|
@@ -12,6 +12,8 @@ from urllib.parse import urlparse
|
|
|
12
12
|
import alibabacloud_oss_v2 as oss
|
|
13
13
|
from alibabacloud_oss_v2.transport import RequestsHttpClient
|
|
14
14
|
|
|
15
|
+
from ._multipart import transfer, upload_size
|
|
16
|
+
|
|
15
17
|
__all__ = ["OSSClient"]
|
|
16
18
|
|
|
17
19
|
|
|
@@ -137,7 +139,7 @@ class OSSClient:
|
|
|
137
139
|
"""The server-selected upload prefix, or an empty string for bucket reads."""
|
|
138
140
|
return self._credentials.scope[3]
|
|
139
141
|
|
|
140
|
-
def _request(self, permission, method, request, path):
|
|
142
|
+
def _request(self, permission, method, request, path=None):
|
|
141
143
|
if self._closed:
|
|
142
144
|
raise ValueError("OSS client is closed")
|
|
143
145
|
if self._permission != permission:
|
|
@@ -147,8 +149,9 @@ class OSSClient:
|
|
|
147
149
|
raise ValueError("Object is outside the management credential scope")
|
|
148
150
|
value = self._credentials.get()
|
|
149
151
|
operation = getattr(self._client, method)
|
|
152
|
+
args = (request,) if path is None else (request, os.fspath(path))
|
|
150
153
|
try:
|
|
151
|
-
return operation(
|
|
154
|
+
return operation(*args)
|
|
152
155
|
except oss.exceptions.OperationError as error:
|
|
153
156
|
cause = error.unwrap()
|
|
154
157
|
if not isinstance(cause, oss.exceptions.ServiceError) or cause.code != "SecurityTokenExpired":
|
|
@@ -156,7 +159,7 @@ class OSSClient:
|
|
|
156
159
|
self._credentials.invalidate(value)
|
|
157
160
|
# Refresh and validate the scope before opening/truncating any file.
|
|
158
161
|
self._credentials.get()
|
|
159
|
-
return operation(
|
|
162
|
+
return operation(*args)
|
|
160
163
|
|
|
161
164
|
def download_file(self, key, path, *, bucket=None):
|
|
162
165
|
"""Download an object, replacing the local destination only on success.
|
|
@@ -175,12 +178,38 @@ class OSSClient:
|
|
|
175
178
|
finally:
|
|
176
179
|
temporary_path.unlink(missing_ok=True)
|
|
177
180
|
|
|
178
|
-
def upload_file(self, key, path, *, bucket=None, content_type=None, metadata=None, forbid_overwrite=True
|
|
179
|
-
|
|
181
|
+
def upload_file(self, key, path, *, bucket=None, content_type=None, metadata=None, forbid_overwrite=True,
|
|
182
|
+
multipart_threshold=100 * 1024**2, part_size=16 * 1024**2, max_workers=4):
|
|
183
|
+
"""Upload a file, using parallel multipart at the threshold (bytes).
|
|
180
184
|
|
|
181
185
|
The caller supplies the full key within object_prefix. Returns the OSS
|
|
182
186
|
result; registering metadata remains an explicit management call.
|
|
187
|
+
Small/empty files return PutObjectResult; multipart returns
|
|
188
|
+
CompleteMultipartUploadResult. Failed multipart transfers are aborted;
|
|
189
|
+
uploads restart from scratch on a later call, without checkpoints.
|
|
183
190
|
"""
|
|
191
|
+
bucket = self.bucket if bucket is None else bucket
|
|
192
|
+
if self._closed:
|
|
193
|
+
raise ValueError("OSS client is closed")
|
|
194
|
+
if self._permission != "upload":
|
|
195
|
+
raise PermissionError("Operation does not match this client's requested permission")
|
|
196
|
+
if bucket != self.bucket or not isinstance(key, str) or not key.startswith(self.object_prefix) or key == self.object_prefix:
|
|
197
|
+
raise ValueError("Object is outside the management credential scope")
|
|
198
|
+
size = upload_size(path, multipart_threshold, part_size, max_workers)
|
|
199
|
+
if size and size >= multipart_threshold:
|
|
200
|
+
def request(method, model, **kwargs):
|
|
201
|
+
return self._request("upload", method, model(bucket=bucket, key=key, **kwargs))
|
|
202
|
+
|
|
203
|
+
return transfer(path, size, part_size, max_workers,
|
|
204
|
+
lambda: request("initiate_multipart_upload", oss.InitiateMultipartUploadRequest,
|
|
205
|
+
content_type=content_type, metadata=metadata, forbid_overwrite=forbid_overwrite).upload_id,
|
|
206
|
+
lambda uid, number, data: request("upload_part", oss.UploadPartRequest,
|
|
207
|
+
upload_id=uid, part_number=number, body=data, content_length=len(data)).etag,
|
|
208
|
+
lambda uid, parts: request("complete_multipart_upload", oss.CompleteMultipartUploadRequest,
|
|
209
|
+
upload_id=uid, forbid_overwrite=forbid_overwrite,
|
|
210
|
+
complete_multipart_upload=oss.CompleteMultipartUpload(parts=[
|
|
211
|
+
oss.UploadPart(part_number=n, etag=etag) for n, etag in parts])),
|
|
212
|
+
lambda uid: request("abort_multipart_upload", oss.AbortMultipartUploadRequest, upload_id=uid))
|
|
184
213
|
return self._request("upload", "put_object_from_file", oss.PutObjectRequest(
|
|
185
214
|
bucket=self.bucket if bucket is None else bucket, key=key,
|
|
186
215
|
content_type=content_type, metadata=metadata, forbid_overwrite=forbid_overwrite,
|
|
@@ -15,7 +15,7 @@ from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb
|
|
|
15
15
|
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"management/metadata/metadata.proto\x12\x16management.metadata.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xa6\x03\n\x08Metadata\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12.\n\ncreated_at\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x31\n\x08storages\x18\x05 \x03(\x0b\x32\x1f.management.metadata.v1.Storage\x12\x33\n\tfile_info\x18\x06 \x01(\x0b\x32 .management.metadata.v1.FileInfo\x12/\n\x07\x64\x65vices\x18\x07 \x03(\x0b\x32\x1e.management.metadata.v1.Device\x12=\n\x0erecording_info\x18\x08 \x01(\x0b\x32%.management.metadata.v1.RecordingInfo\x12\x33\n\tdata_type\x18\t \x01(\x0e\x32 .management.metadata.v1.DataType\x12\x13\n\x0boptional_id\x18\n \x01(\t\"h\n\x07Storage\x12\x0e\n\x06\x62ucket\x18\x01 \x01(\t\x12\x12\n\nobject_key\x18\x02 \x01(\t\x12\x39\n\x08provider\x18\x03 \x01(\x0e\x32\'.management.metadata.v1.StorageProvider\"_\n\x08\x46ileInfo\x12\x12\n\nsize_bytes\x18\x01 \x01(\x03\x12-\n\x06topics\x18\x02 \x03(\x0b\x32\x1d.management.metadata.v1.Topic\x12\x10\n\x08\x63hecksum\x18\x03 \x01(\t\"3\n\x05Topic\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07samples\x18\x02 \x01(\x03\x12\x0b\n\x03\x66ps\x18\x03 \x01(\x02\"\x9c\x02\n\x06\x44\x65vice\x12\r\n\x05model\x18\x01 \x01(\t\x12\x30\n\x04type\x18\x02 \x01(\x0e\x32\".management.metadata.v1.DeviceType\x12\x18\n\x10\x66irmware_version\x18\x03 \x01(\t\x12\x0b\n\x03\x66ps\x18\x04 \x01(\x02\x12\x32\n\x08modality\x18\x05 \x01(\x0e\x32 .management.metadata.v1.Modality\x12>\n\x0fmount_body_part\x18\x06 \x01(\x0e\x32%.management.metadata.v1.MountBodyPart\x12\x36\n\nresolution\x18\x07 \x01(\x0b\x32\".management.metadata.v1.Resolution\"+\n\nResolution\x12\x0e\n\x06height\x18\x01 \x01(\r\x12\r\n\x05width\x18\x02 \x01(\r\"\x8b\x02\n\rRecordingInfo\x12\x39\n\x0erecording_time\x18\x01 \x01(\x0b\x32!.management.metadata.v1.TimeRange\x12+\n\x08\x64uration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x32\n\x08location\x18\x03 \x01(\x0b\x32 .management.metadata.v1.Location\x12*\n\x04task\x18\x04 \x01(\x0b\x32\x1c.management.metadata.v1.Task\x12\x32\n\x08operator\x18\x05 \x01(\x0b\x32 .management.metadata.v1.Operator\"J\n\x08Location\x12\x19\n\x11\x63oordinate_system\x18\x01 \x01(\t\x12\x10\n\x08latitude\x18\x02 \x01(\x01\x12\x11\n\tlongitude\x18\x03 \x01(\x01\"}\n\x04Task\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\r\n\x05scene\x18\x03 \x01(\t\x12\x43\n\x11\x63ollection_method\x18\x04 \x01(\x0b\x32(.management.metadata.v1.CollectionMethod\"9\n\x10\x43ollectionMethod\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\x12\x10\n\x08paradigm\x18\x02 \x01(\t\"L\n\x08Operator\x12\n\n\x02id\x18\x01 \x01(\t\x12\x10\n\x08\x61rm_span\x18\x02 \x01(\x01\x12\x0e\n\x06height\x18\x03 \x01(\x01\x12\x12\n\nleg_length\x18\x04 \x01(\x01\"\
|
|
18
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"management/metadata/metadata.proto\x12\x16management.metadata.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xa6\x03\n\x08Metadata\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12.\n\ncreated_at\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\nupdated_at\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x31\n\x08storages\x18\x05 \x03(\x0b\x32\x1f.management.metadata.v1.Storage\x12\x33\n\tfile_info\x18\x06 \x01(\x0b\x32 .management.metadata.v1.FileInfo\x12/\n\x07\x64\x65vices\x18\x07 \x03(\x0b\x32\x1e.management.metadata.v1.Device\x12=\n\x0erecording_info\x18\x08 \x01(\x0b\x32%.management.metadata.v1.RecordingInfo\x12\x33\n\tdata_type\x18\t \x01(\x0e\x32 .management.metadata.v1.DataType\x12\x13\n\x0boptional_id\x18\n \x01(\t\"h\n\x07Storage\x12\x0e\n\x06\x62ucket\x18\x01 \x01(\t\x12\x12\n\nobject_key\x18\x02 \x01(\t\x12\x39\n\x08provider\x18\x03 \x01(\x0e\x32\'.management.metadata.v1.StorageProvider\"_\n\x08\x46ileInfo\x12\x12\n\nsize_bytes\x18\x01 \x01(\x03\x12-\n\x06topics\x18\x02 \x03(\x0b\x32\x1d.management.metadata.v1.Topic\x12\x10\n\x08\x63hecksum\x18\x03 \x01(\t\"3\n\x05Topic\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07samples\x18\x02 \x01(\x03\x12\x0b\n\x03\x66ps\x18\x03 \x01(\x02\"\x9c\x02\n\x06\x44\x65vice\x12\r\n\x05model\x18\x01 \x01(\t\x12\x30\n\x04type\x18\x02 \x01(\x0e\x32\".management.metadata.v1.DeviceType\x12\x18\n\x10\x66irmware_version\x18\x03 \x01(\t\x12\x0b\n\x03\x66ps\x18\x04 \x01(\x02\x12\x32\n\x08modality\x18\x05 \x01(\x0e\x32 .management.metadata.v1.Modality\x12>\n\x0fmount_body_part\x18\x06 \x01(\x0e\x32%.management.metadata.v1.MountBodyPart\x12\x36\n\nresolution\x18\x07 \x01(\x0b\x32\".management.metadata.v1.Resolution\"+\n\nResolution\x12\x0e\n\x06height\x18\x01 \x01(\r\x12\r\n\x05width\x18\x02 \x01(\r\"\x8b\x02\n\rRecordingInfo\x12\x39\n\x0erecording_time\x18\x01 \x01(\x0b\x32!.management.metadata.v1.TimeRange\x12+\n\x08\x64uration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x32\n\x08location\x18\x03 \x01(\x0b\x32 .management.metadata.v1.Location\x12*\n\x04task\x18\x04 \x01(\x0b\x32\x1c.management.metadata.v1.Task\x12\x32\n\x08operator\x18\x05 \x01(\x0b\x32 .management.metadata.v1.Operator\"J\n\x08Location\x12\x19\n\x11\x63oordinate_system\x18\x01 \x01(\t\x12\x10\n\x08latitude\x18\x02 \x01(\x01\x12\x11\n\tlongitude\x18\x03 \x01(\x01\"}\n\x04Task\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\r\n\x05scene\x18\x03 \x01(\t\x12\x43\n\x11\x63ollection_method\x18\x04 \x01(\x0b\x32(.management.metadata.v1.CollectionMethod\"9\n\x10\x43ollectionMethod\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\x12\x10\n\x08paradigm\x18\x02 \x01(\t\"L\n\x08Operator\x12\n\n\x02id\x18\x01 \x01(\t\x12\x10\n\x08\x61rm_span\x18\x02 \x01(\x01\x12\x0e\n\x06height\x18\x03 \x01(\x01\x12\x12\n\nleg_length\x18\x04 \x01(\x01\"\x93\x02\n\x0eMetadataFilter\x12\x13\n\x0bname_prefix\x18\x01 \x01(\t\x12\x34\n\ndata_types\x18\x02 \x03(\x0e\x32 .management.metadata.v1.DataType\x12\x42\n\x17recording_started_range\x18\x03 \x01(\x0b\x32!.management.metadata.v1.TimeRange\x12G\n\x18recording_duration_range\x18\x04 \x01(\x0b\x32%.management.metadata.v1.DurationRange\x12\x18\n\x10task_name_prefix\x18\x05 \x01(\t\x12\x0f\n\x07\x64\x61ta_id\x18\x06 \x01(\t\"]\n\tTimeRange\x12(\n\x04\x66rom\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12&\n\x02to\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"_\n\rDurationRange\x12&\n\x03min\x18\x01 \x01(\x0b\x32\x19.google.protobuf.Duration\x12&\n\x03max\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration*g\n\x0fStorageProvider\x12 \n\x1cSTORAGE_PROVIDER_UNSPECIFIED\x10\x00\x12\x18\n\x14STORAGE_PROVIDER_OSS\x10\x01\x12\x18\n\x14STORAGE_PROVIDER_TOS\x10\x02*S\n\nDeviceType\x12\x1b\n\x17\x44\x45VICE_TYPE_UNSPECIFIED\x10\x00\x12\x13\n\x0f\x44\x45VICE_TYPE_CAM\x10\x01\x12\x13\n\x0f\x44\x45VICE_TYPE_IMU\x10\x02*J\n\x08Modality\x12\x18\n\x14MODALITY_UNSPECIFIED\x10\x00\x12\x10\n\x0cMODALITY_RGB\x10\x01\x12\x12\n\x0eMODALITY_DEPTH\x10\x02*0\n\rMountBodyPart\x12\x1f\n\x1bMOUNT_BODY_PART_UNSPECIFIED\x10\x00*\x84\x01\n\x08\x44\x61taType\x12\x19\n\x15\x44\x41TA_TYPE_UNSPECIFIED\x10\x00\x12\x16\n\x12\x44\x41TA_TYPE_EGOSUITE\x10\x01\x12\x11\n\rDATA_TYPE_YAM\x10\x02\x12\x18\n\x14\x44\x41TA_TYPE_CURRENT_V2\x10\x03\x12\x18\n\x14\x44\x41TA_TYPE_PICO_GLOVE\x10\x04\x42*Z(proto_gen/management/metadata;metadatapbb\x06proto3')
|
|
19
19
|
|
|
20
20
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
|
21
21
|
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'management.metadata.metadata_pb2', globals())
|
|
@@ -23,16 +23,16 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|
|
23
23
|
|
|
24
24
|
DESCRIPTOR._options = None
|
|
25
25
|
DESCRIPTOR._serialized_options = b'Z(proto_gen/management/metadata;metadatapb'
|
|
26
|
-
_STORAGEPROVIDER._serialized_start=
|
|
27
|
-
_STORAGEPROVIDER._serialized_end=
|
|
28
|
-
_DEVICETYPE._serialized_start=
|
|
29
|
-
_DEVICETYPE._serialized_end=
|
|
30
|
-
_MODALITY._serialized_start=
|
|
31
|
-
_MODALITY._serialized_end=
|
|
32
|
-
_MOUNTBODYPART._serialized_start=
|
|
33
|
-
_MOUNTBODYPART._serialized_end=
|
|
34
|
-
_DATATYPE._serialized_start=
|
|
35
|
-
_DATATYPE._serialized_end=
|
|
26
|
+
_STORAGEPROVIDER._serialized_start=2220
|
|
27
|
+
_STORAGEPROVIDER._serialized_end=2323
|
|
28
|
+
_DEVICETYPE._serialized_start=2325
|
|
29
|
+
_DEVICETYPE._serialized_end=2408
|
|
30
|
+
_MODALITY._serialized_start=2410
|
|
31
|
+
_MODALITY._serialized_end=2484
|
|
32
|
+
_MOUNTBODYPART._serialized_start=2486
|
|
33
|
+
_MOUNTBODYPART._serialized_end=2534
|
|
34
|
+
_DATATYPE._serialized_start=2537
|
|
35
|
+
_DATATYPE._serialized_end=2669
|
|
36
36
|
_METADATA._serialized_start=128
|
|
37
37
|
_METADATA._serialized_end=550
|
|
38
38
|
_STORAGE._serialized_start=552
|
|
@@ -56,9 +56,9 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|
|
56
56
|
_OPERATOR._serialized_start=1672
|
|
57
57
|
_OPERATOR._serialized_end=1748
|
|
58
58
|
_METADATAFILTER._serialized_start=1751
|
|
59
|
-
_METADATAFILTER._serialized_end=
|
|
60
|
-
_TIMERANGE._serialized_start=
|
|
61
|
-
_TIMERANGE._serialized_end=
|
|
62
|
-
_DURATIONRANGE._serialized_start=
|
|
63
|
-
_DURATIONRANGE._serialized_end=
|
|
59
|
+
_METADATAFILTER._serialized_end=2026
|
|
60
|
+
_TIMERANGE._serialized_start=2028
|
|
61
|
+
_TIMERANGE._serialized_end=2121
|
|
62
|
+
_DURATIONRANGE._serialized_start=2123
|
|
63
|
+
_DURATIONRANGE._serialized_end=2218
|
|
64
64
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: custom_msgs/keypoints_validity.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf.internal import builder as _builder
|
|
6
|
+
from google.protobuf import descriptor as _descriptor
|
|
7
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
8
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
9
|
+
# @@protoc_insertion_point(imports)
|
|
10
|
+
|
|
11
|
+
_sym_db = _symbol_database.Default()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from std_msgs import header_pb2 as std__msgs_dot_header__pb2
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$custom_msgs/keypoints_validity.proto\x12\x0b\x63ustom_msgs\x1a\x15std_msgs/header.proto\"Y\n\x11KeypointsValidity\x12 \n\x06header\x18\x01 \x01(\x0b\x32\x10.std_msgs.Header\x12\x13\n\x0bjoint_names\x18\x02 \x03(\t\x12\r\n\x05valid\x18\x03 \x03(\x08\x62\x06proto3')
|
|
18
|
+
|
|
19
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
|
|
20
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'custom_msgs.keypoints_validity_pb2', globals())
|
|
21
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
22
|
+
|
|
23
|
+
DESCRIPTOR._options = None
|
|
24
|
+
_KEYPOINTSVALIDITY._serialized_start=76
|
|
25
|
+
_KEYPOINTSVALIDITY._serialized_end=165
|
|
26
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -2,6 +2,7 @@ from .._proto.builtin_interfaces.duration_pb2 import Duration
|
|
|
2
2
|
from .._proto.builtin_interfaces.time_pb2 import Time
|
|
3
3
|
from .._proto.custom_msgs.joint_current_pb2 import JointCurrent
|
|
4
4
|
from .._proto.custom_msgs.slam_quality_pb2 import SlamQuality
|
|
5
|
+
from .._proto.custom_msgs.keypoints_validity_pb2 import KeypointsValidity
|
|
5
6
|
from .._proto.custom_msgs.sonic_frame_pb2 import SonicFrame
|
|
6
7
|
from .._proto.custom_msgs.subtask_description_pb2 import SubtaskDescription
|
|
7
8
|
from .._proto.custom_msgs.target_quality_pb2 import TargetQuality
|
|
@@ -57,6 +58,7 @@ SCHEMA_TO_CLASS = {
|
|
|
57
58
|
"builtin_interfaces.Time": Time,
|
|
58
59
|
"custom_msgs.JointCurrent": JointCurrent,
|
|
59
60
|
"custom_msgs.SlamQuality": SlamQuality,
|
|
61
|
+
"custom_msgs.KeypointsValidity": KeypointsValidity,
|
|
60
62
|
"custom_msgs.SonicFrame": SonicFrame,
|
|
61
63
|
"custom_msgs.SubtaskDescription": SubtaskDescription,
|
|
62
64
|
"custom_msgs.TargetQuality": TargetQuality,
|
|
@@ -106,6 +106,10 @@ class ManagementService(rpc.DataManagementServiceServicer):
|
|
|
106
106
|
data.created_at.seconds = 1000
|
|
107
107
|
return pb.RegisterDataResponse(data=data)
|
|
108
108
|
|
|
109
|
+
def GetData(self, request, context):
|
|
110
|
+
self.record("get_data", request, context)
|
|
111
|
+
return pb.GetDataResponse(data=Metadata(id=request.data_id, name="recording"))
|
|
112
|
+
|
|
109
113
|
def StreamDataReferences(self, request, context):
|
|
110
114
|
self.record("stream", request, context)
|
|
111
115
|
mode = request.filter.name_prefix
|
|
@@ -159,7 +163,7 @@ class ManagementTest(unittest.TestCase):
|
|
|
159
163
|
self.assertLessEqual(remaining, 31)
|
|
160
164
|
|
|
161
165
|
def test_credential_scope_arguments_and_defaults(self):
|
|
162
|
-
for value, expected in (("RAW", 0), ("CURRENT_V2", 3), ("DATA_TYPE_CURRENT_V2", 3),
|
|
166
|
+
for value, expected in (("RAW", 0), ("PICO_GLOVE", 4), ("DATA_TYPE_PICO_GLOVE", 4), ("CURRENT_V2", 3), ("DATA_TYPE_CURRENT_V2", 3),
|
|
163
167
|
(metadata_pb2.DATA_TYPE_CURRENT_V2, 3)):
|
|
164
168
|
with self.subTest(data_type=value):
|
|
165
169
|
self.client.get_upload_credentials(data_type=value)
|
|
@@ -344,6 +348,17 @@ class ManagementTest(unittest.TestCase):
|
|
|
344
348
|
self.assertEqual(caught.exception.details(), "already registered")
|
|
345
349
|
self.assertEqual(len(self.service.calls), 1)
|
|
346
350
|
|
|
351
|
+
def test_get_data_by_id_and_validate_input(self):
|
|
352
|
+
result = self.client.get_data("data-1", timeout=5, metadata=(("authorization", "token"),))
|
|
353
|
+
self.assertEqual((result.id, result.name), ("data-1", "recording"))
|
|
354
|
+
name, request, headers, remaining = self.service.calls[-1]
|
|
355
|
+
self.assertEqual((name, request.data_id), ("get_data", "data-1"))
|
|
356
|
+
self.assertEqual(headers["authorization"], "token")
|
|
357
|
+
self.assertGreater(remaining, 0)
|
|
358
|
+
for value in ("", " data-1", "data-1 ", None):
|
|
359
|
+
with self.subTest(value=value), self.assertRaises(ValueError):
|
|
360
|
+
self.client.get_data(value)
|
|
361
|
+
|
|
347
362
|
def test_call_metadata_and_deadlines(self):
|
|
348
363
|
headers = (("authorization", "Bearer test"), ("trace-bin", b"trace"))
|
|
349
364
|
self.client.get_upload_credentials(timeout=5, metadata=headers)
|
|
@@ -12,6 +12,7 @@ import tos
|
|
|
12
12
|
from tos.credential import Credentials, CredentialsProvider
|
|
13
13
|
|
|
14
14
|
from ._proto.management.metadata import metadata_pb2 as pb
|
|
15
|
+
from ._multipart import transfer, upload_size
|
|
15
16
|
|
|
16
17
|
__all__ = ["TOSClient"]
|
|
17
18
|
|
|
@@ -149,9 +150,29 @@ class TOSClient:
|
|
|
149
150
|
os.replace(temporary_path, destination)
|
|
150
151
|
return result
|
|
151
152
|
|
|
152
|
-
def upload_file(self, key, path, *, bucket=None, content_type=None, metadata=None, forbid_overwrite=True
|
|
153
|
-
|
|
153
|
+
def upload_file(self, key, path, *, bucket=None, content_type=None, metadata=None, forbid_overwrite=True,
|
|
154
|
+
multipart_threshold=100 * 1024**2, part_size=16 * 1024**2, max_workers=4):
|
|
155
|
+
"""Upload with parallel multipart at the threshold (bytes).
|
|
156
|
+
|
|
157
|
+
Returns PutObjectOutput for small/empty files or
|
|
158
|
+
CompleteMultipartUploadOutput for multipart. Failed uploads are aborted;
|
|
159
|
+
no cross-call checkpoints are kept. Registration is a separate call.
|
|
160
|
+
"""
|
|
154
161
|
self._check("upload", bucket, key)
|
|
162
|
+
size = upload_size(path, multipart_threshold, part_size, max_workers)
|
|
163
|
+
if size and size >= multipart_threshold:
|
|
164
|
+
def request(method, **kwargs):
|
|
165
|
+
return _request(self._client, self._credentials, method, bucket=self.bucket, key=key, **kwargs)
|
|
166
|
+
|
|
167
|
+
return transfer(path, size, part_size, max_workers,
|
|
168
|
+
lambda: request("create_multipart_upload", content_type=content_type, meta=metadata,
|
|
169
|
+
forbid_overwrite=forbid_overwrite).upload_id,
|
|
170
|
+
lambda uid, number, data: request("upload_part", upload_id=uid, part_number=number,
|
|
171
|
+
content=data, content_length=len(data)).etag,
|
|
172
|
+
lambda uid, parts: request("complete_multipart_upload", upload_id=uid,
|
|
173
|
+
forbid_overwrite=forbid_overwrite,
|
|
174
|
+
parts=[tos.models2.UploadedPart(n, etag) for n, etag in parts]),
|
|
175
|
+
lambda uid: request("abort_multipart_upload", upload_id=uid))
|
|
155
176
|
return _request(self._client, self._credentials, "put_object_from_file", bucket=self.bucket,
|
|
156
177
|
key=key, file_path=os.fspath(path), content_type=content_type,
|
|
157
178
|
meta=metadata, forbid_overwrite=forbid_overwrite)
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/current_data_py.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/service/service_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/task/task_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/labeling/template/template_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/management/service/service_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/custom_msgs/pose_rpy_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/point32_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/point_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/pose_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/twist_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/vector3_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/geometry_msgs/wrench_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/map_meta_data_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/nav_msgs/odometry_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/image_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/imu_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/laser_scan_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/sensor_msgs/range_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/color_rgba_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/float32_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/float64_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/header_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/int32_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/string_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/std_msgs/uint32_pb2.py
RENAMED
|
File without changes
|
{current_data_py-0.1.13 → current_data_py-0.1.14}/proto_gen/python/msg/tf2_msgs/tf_message_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|