prismax 0.1.0__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.
- prismax-0.1.0/LICENSE +132 -0
- prismax-0.1.0/PKG-INFO +203 -0
- prismax-0.1.0/README.md +177 -0
- prismax-0.1.0/prismax/__init__.py +28 -0
- prismax-0.1.0/prismax/cli.py +107 -0
- prismax-0.1.0/prismax/client.py +158 -0
- prismax-0.1.0/prismax/errors.py +14 -0
- prismax-0.1.0/prismax/manifest.py +36 -0
- prismax-0.1.0/prismax/scanner.py +191 -0
- prismax-0.1.0/prismax/upload.py +240 -0
- prismax-0.1.0/prismax.egg-info/PKG-INFO +203 -0
- prismax-0.1.0/prismax.egg-info/SOURCES.txt +17 -0
- prismax-0.1.0/prismax.egg-info/dependency_links.txt +1 -0
- prismax-0.1.0/prismax.egg-info/entry_points.txt +2 -0
- prismax-0.1.0/prismax.egg-info/requires.txt +1 -0
- prismax-0.1.0/prismax.egg-info/top_level.txt +1 -0
- prismax-0.1.0/pyproject.toml +42 -0
- prismax-0.1.0/setup.cfg +4 -0
- prismax-0.1.0/tests/test_upload_helpers.py +342 -0
prismax-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Required Notice: Copyright 2026 PrismaX
|
|
2
|
+
|
|
3
|
+
# PolyForm Noncommercial License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree
|
|
10
|
+
to them as both strict obligations and conditions to all your
|
|
11
|
+
licenses.
|
|
12
|
+
|
|
13
|
+
## Copyright License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a copyright license for the software
|
|
16
|
+
to do everything you might do with the software that would
|
|
17
|
+
otherwise infringe the licensor's copyright in it for any
|
|
18
|
+
permitted purpose. However, you may only distribute the software
|
|
19
|
+
according to [Distribution License](#distribution-license) and
|
|
20
|
+
make changes or new works based on the software according to
|
|
21
|
+
[Changes and New Works License](#changes-and-new-works-license).
|
|
22
|
+
|
|
23
|
+
## Distribution License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to
|
|
26
|
+
distribute copies of the software. Your license to distribute
|
|
27
|
+
covers distributing the software with changes and new works
|
|
28
|
+
permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of the
|
|
33
|
+
software from you also gets a copy of these terms or the URL for
|
|
34
|
+
them above, as well as copies of any plain-text lines beginning
|
|
35
|
+
with `Required Notice:` that the licensor provided with the
|
|
36
|
+
software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to make
|
|
43
|
+
changes and new works based on the software for any permitted
|
|
44
|
+
purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for the
|
|
59
|
+
benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application, is
|
|
62
|
+
use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization, or
|
|
69
|
+
government institution is use for a permitted purpose regardless
|
|
70
|
+
of the source of funding or obligations resulting from the
|
|
71
|
+
funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the law.
|
|
76
|
+
These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply any
|
|
83
|
+
other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms, and
|
|
99
|
+
take practical steps to correct past violations, within 32 days
|
|
100
|
+
of receiving notice. Otherwise, all your licenses end
|
|
101
|
+
immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
As far as the law allows, the software comes as is, without any
|
|
106
|
+
warranty or condition, and the licensor will not be liable to
|
|
107
|
+
you for any damages arising out of these terms or the use or
|
|
108
|
+
nature of the software, under any kind of legal claim.
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The licensor is the individual or entity offering these terms,
|
|
113
|
+
and the software is the software the licensor makes available
|
|
114
|
+
under these terms.
|
|
115
|
+
|
|
116
|
+
You refers to the individual or entity agreeing to these terms.
|
|
117
|
+
|
|
118
|
+
Your company is any legal entity, sole proprietorship, or other
|
|
119
|
+
kind of organization that you work for, plus all organizations
|
|
120
|
+
that have control over, are under the control of, or are under
|
|
121
|
+
common control with that organization. Control means ownership
|
|
122
|
+
of substantially all the assets of an entity, or the power to
|
|
123
|
+
direct its management and policies by vote, contract, or
|
|
124
|
+
otherwise. Control can be direct or indirect.
|
|
125
|
+
|
|
126
|
+
Your licenses are all the licenses granted to you for the
|
|
127
|
+
software under these terms.
|
|
128
|
+
|
|
129
|
+
Use means anything you do with the software requiring one of
|
|
130
|
+
your licenses.
|
|
131
|
+
|
|
132
|
+
© PolyForm Project Inc.
|
prismax-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prismax
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: PrismaX Python SDK for data uploads
|
|
5
|
+
Author: PrismaX
|
|
6
|
+
License: PolyForm Noncommercial License 1.0.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ChrisPrismax/prismax-sdk-python
|
|
8
|
+
Project-URL: Repository, https://github.com/ChrisPrismax/prismax-sdk-python
|
|
9
|
+
Project-URL: Issues, https://github.com/ChrisPrismax/prismax-sdk-python/issues
|
|
10
|
+
Keywords: prismax,upload,sdk,robotics,mcap
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: Other/Proprietary License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: requests>=2.31.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# PrismaX Python SDK
|
|
28
|
+
|
|
29
|
+
Minimal upload SDK for PrismaX data uploads.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
This SDK is source-available for noncommercial use under the PolyForm
|
|
34
|
+
Noncommercial License 1.0.0. Commercial use is not permitted unless PrismaX
|
|
35
|
+
grants a separate commercial license.
|
|
36
|
+
|
|
37
|
+
## Quickstart
|
|
38
|
+
|
|
39
|
+
You need:
|
|
40
|
+
|
|
41
|
+
- a PrismaX upload API key with the `pxu_` prefix
|
|
42
|
+
- a PrismaX task ID
|
|
43
|
+
- the robot serial number for the machine that produced the data
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install prismax
|
|
47
|
+
export PRISMAX_API_KEY="pxu_your_upload_api_key"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Download API keys are not valid for uploads.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import prismax
|
|
54
|
+
|
|
55
|
+
result = prismax.upload("./data", task_id=123, serial_number="robot_serial_number")
|
|
56
|
+
print(result["upload_id"])
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The SDK scans the folder, creates an upload session, uploads raw files to signed
|
|
60
|
+
Google Cloud URLs, generates episode manifests in memory, uploads manifests last,
|
|
61
|
+
and returns the upload summary.
|
|
62
|
+
|
|
63
|
+
You can also pass the API key directly:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import prismax
|
|
67
|
+
|
|
68
|
+
result = prismax.upload(
|
|
69
|
+
"./data",
|
|
70
|
+
task_id=123,
|
|
71
|
+
serial_number="robot_serial_number",
|
|
72
|
+
api_key="pxu_your_upload_api_key",
|
|
73
|
+
)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Expected Folder Structure
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
data/
|
|
80
|
+
1.mcap
|
|
81
|
+
1/
|
|
82
|
+
high.mp4
|
|
83
|
+
left.mp4
|
|
84
|
+
right.mp4
|
|
85
|
+
high2.mp4
|
|
86
|
+
left2.mp4
|
|
87
|
+
right2.mp4
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each episode must contain one root `{episode}.mcap` file and at least three MP4
|
|
91
|
+
files under `{episode}/`: one primary filename containing `left`, one containing
|
|
92
|
+
`right`, and one environment/high video filename containing neither. Additional
|
|
93
|
+
MP4 files are uploaded as raw files, included in downloads, and checked for
|
|
94
|
+
duration consistency. A duration mismatch across any episode videos can fail the
|
|
95
|
+
upload. Only the primary three videos are processed for derived previews, QA,
|
|
96
|
+
and duplicate detection.
|
|
97
|
+
|
|
98
|
+
Use lowercase `.mp4` extensions. Uppercase variants such as `.MP4` are rejected
|
|
99
|
+
so client validation, worker processing, and download manifests choose the same
|
|
100
|
+
primary videos. Hidden files are ignored, including macOS metadata files such as
|
|
101
|
+
`.DS_Store` and `._left.mp4`.
|
|
102
|
+
|
|
103
|
+
Primary video selection is based on filename:
|
|
104
|
+
|
|
105
|
+
- filenames containing `left` are treated as left videos
|
|
106
|
+
- filenames containing `right` are treated as right videos
|
|
107
|
+
- other MP4 files are treated as environment/high videos
|
|
108
|
+
- exact names are preferred, for example `high.mp4`, `left.mp4`, and
|
|
109
|
+
`right.mp4` are selected before `high2.mp4`, `left2.mp4`, and `right2.mp4`
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
data/
|
|
115
|
+
1.mcap
|
|
116
|
+
1/
|
|
117
|
+
high.mp4
|
|
118
|
+
left.mp4
|
|
119
|
+
right.mp4
|
|
120
|
+
high2.mp4
|
|
121
|
+
left2.mp4
|
|
122
|
+
right2.mp4
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Primary videos:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
env/high: high.mp4
|
|
129
|
+
left: left.mp4
|
|
130
|
+
right: right.mp4
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Additional videos:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
high2.mp4
|
|
137
|
+
left2.mp4
|
|
138
|
+
right2.mp4
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## CLI
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number
|
|
145
|
+
prismax status 123
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use `--wait` to wait for the worker to finish. The default maximum wait time is
|
|
149
|
+
30 minutes.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait
|
|
153
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait --max-wait 3600
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Useful CLI options:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --timeout 120 --retries 5
|
|
160
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait --poll-interval 5 --max-poll-errors 3
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Status and Resume
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
import prismax
|
|
167
|
+
|
|
168
|
+
upload_status = prismax.status(123)
|
|
169
|
+
|
|
170
|
+
resume_result = prismax.resume(
|
|
171
|
+
123,
|
|
172
|
+
"./data",
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
prismax status 123
|
|
178
|
+
prismax resume 123 ./data
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Resume expects the same complete upload folder/file list, not only the files
|
|
182
|
+
that are missing from cloud storage. The SDK will ask the API which files still
|
|
183
|
+
need signed upload URLs. Resume is only allowed while the upload is still in
|
|
184
|
+
`UPLOADING` status; once processing has started or the upload reaches a terminal
|
|
185
|
+
status, create a new upload instead.
|
|
186
|
+
|
|
187
|
+
## Error Handling
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
import prismax
|
|
191
|
+
|
|
192
|
+
try:
|
|
193
|
+
prismax.upload("./data", task_id=123, serial_number="robot_serial_number")
|
|
194
|
+
except prismax.PrismaxValidationError as exc:
|
|
195
|
+
print(f"Invalid upload folder: {exc}")
|
|
196
|
+
except prismax.PrismaxAuthError as exc:
|
|
197
|
+
print(f"API key or permission error: {exc}")
|
|
198
|
+
except prismax.PrismaxApiError as exc:
|
|
199
|
+
print(f"PrismaX API error: {exc}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
If raw file upload fails after the session is created, the SDK error includes
|
|
203
|
+
the upload ID and a `prismax resume <upload_id> <folder>` command.
|
prismax-0.1.0/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# PrismaX Python SDK
|
|
2
|
+
|
|
3
|
+
Minimal upload SDK for PrismaX data uploads.
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
This SDK is source-available for noncommercial use under the PolyForm
|
|
8
|
+
Noncommercial License 1.0.0. Commercial use is not permitted unless PrismaX
|
|
9
|
+
grants a separate commercial license.
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
You need:
|
|
14
|
+
|
|
15
|
+
- a PrismaX upload API key with the `pxu_` prefix
|
|
16
|
+
- a PrismaX task ID
|
|
17
|
+
- the robot serial number for the machine that produced the data
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install prismax
|
|
21
|
+
export PRISMAX_API_KEY="pxu_your_upload_api_key"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Download API keys are not valid for uploads.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import prismax
|
|
28
|
+
|
|
29
|
+
result = prismax.upload("./data", task_id=123, serial_number="robot_serial_number")
|
|
30
|
+
print(result["upload_id"])
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The SDK scans the folder, creates an upload session, uploads raw files to signed
|
|
34
|
+
Google Cloud URLs, generates episode manifests in memory, uploads manifests last,
|
|
35
|
+
and returns the upload summary.
|
|
36
|
+
|
|
37
|
+
You can also pass the API key directly:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import prismax
|
|
41
|
+
|
|
42
|
+
result = prismax.upload(
|
|
43
|
+
"./data",
|
|
44
|
+
task_id=123,
|
|
45
|
+
serial_number="robot_serial_number",
|
|
46
|
+
api_key="pxu_your_upload_api_key",
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Expected Folder Structure
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
data/
|
|
54
|
+
1.mcap
|
|
55
|
+
1/
|
|
56
|
+
high.mp4
|
|
57
|
+
left.mp4
|
|
58
|
+
right.mp4
|
|
59
|
+
high2.mp4
|
|
60
|
+
left2.mp4
|
|
61
|
+
right2.mp4
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Each episode must contain one root `{episode}.mcap` file and at least three MP4
|
|
65
|
+
files under `{episode}/`: one primary filename containing `left`, one containing
|
|
66
|
+
`right`, and one environment/high video filename containing neither. Additional
|
|
67
|
+
MP4 files are uploaded as raw files, included in downloads, and checked for
|
|
68
|
+
duration consistency. A duration mismatch across any episode videos can fail the
|
|
69
|
+
upload. Only the primary three videos are processed for derived previews, QA,
|
|
70
|
+
and duplicate detection.
|
|
71
|
+
|
|
72
|
+
Use lowercase `.mp4` extensions. Uppercase variants such as `.MP4` are rejected
|
|
73
|
+
so client validation, worker processing, and download manifests choose the same
|
|
74
|
+
primary videos. Hidden files are ignored, including macOS metadata files such as
|
|
75
|
+
`.DS_Store` and `._left.mp4`.
|
|
76
|
+
|
|
77
|
+
Primary video selection is based on filename:
|
|
78
|
+
|
|
79
|
+
- filenames containing `left` are treated as left videos
|
|
80
|
+
- filenames containing `right` are treated as right videos
|
|
81
|
+
- other MP4 files are treated as environment/high videos
|
|
82
|
+
- exact names are preferred, for example `high.mp4`, `left.mp4`, and
|
|
83
|
+
`right.mp4` are selected before `high2.mp4`, `left2.mp4`, and `right2.mp4`
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
data/
|
|
89
|
+
1.mcap
|
|
90
|
+
1/
|
|
91
|
+
high.mp4
|
|
92
|
+
left.mp4
|
|
93
|
+
right.mp4
|
|
94
|
+
high2.mp4
|
|
95
|
+
left2.mp4
|
|
96
|
+
right2.mp4
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Primary videos:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
env/high: high.mp4
|
|
103
|
+
left: left.mp4
|
|
104
|
+
right: right.mp4
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Additional videos:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
high2.mp4
|
|
111
|
+
left2.mp4
|
|
112
|
+
right2.mp4
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## CLI
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number
|
|
119
|
+
prismax status 123
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Use `--wait` to wait for the worker to finish. The default maximum wait time is
|
|
123
|
+
30 minutes.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait
|
|
127
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait --max-wait 3600
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Useful CLI options:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --timeout 120 --retries 5
|
|
134
|
+
prismax upload ./data --task-id 123 --serial-number robot_serial_number --wait --poll-interval 5 --max-poll-errors 3
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Status and Resume
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
import prismax
|
|
141
|
+
|
|
142
|
+
upload_status = prismax.status(123)
|
|
143
|
+
|
|
144
|
+
resume_result = prismax.resume(
|
|
145
|
+
123,
|
|
146
|
+
"./data",
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
prismax status 123
|
|
152
|
+
prismax resume 123 ./data
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Resume expects the same complete upload folder/file list, not only the files
|
|
156
|
+
that are missing from cloud storage. The SDK will ask the API which files still
|
|
157
|
+
need signed upload URLs. Resume is only allowed while the upload is still in
|
|
158
|
+
`UPLOADING` status; once processing has started or the upload reaches a terminal
|
|
159
|
+
status, create a new upload instead.
|
|
160
|
+
|
|
161
|
+
## Error Handling
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
import prismax
|
|
165
|
+
|
|
166
|
+
try:
|
|
167
|
+
prismax.upload("./data", task_id=123, serial_number="robot_serial_number")
|
|
168
|
+
except prismax.PrismaxValidationError as exc:
|
|
169
|
+
print(f"Invalid upload folder: {exc}")
|
|
170
|
+
except prismax.PrismaxAuthError as exc:
|
|
171
|
+
print(f"API key or permission error: {exc}")
|
|
172
|
+
except prismax.PrismaxApiError as exc:
|
|
173
|
+
print(f"PrismaX API error: {exc}")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
If raw file upload fails after the session is created, the SDK error includes
|
|
177
|
+
the upload ID and a `prismax resume <upload_id> <folder>` command.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from .client import PrismaXClient
|
|
2
|
+
from .errors import (
|
|
3
|
+
PrismaxApiError,
|
|
4
|
+
PrismaxAuthError,
|
|
5
|
+
PrismaxError,
|
|
6
|
+
PrismaxValidationError,
|
|
7
|
+
)
|
|
8
|
+
from .scanner import episode_keys, scan_folder, select_primary_video_paths, validate_mcap_mp4
|
|
9
|
+
from .upload import resume, status, upload, wait_for_upload
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"PrismaXClient",
|
|
15
|
+
"PrismaxApiError",
|
|
16
|
+
"PrismaxAuthError",
|
|
17
|
+
"PrismaxError",
|
|
18
|
+
"PrismaxValidationError",
|
|
19
|
+
"__version__",
|
|
20
|
+
"episode_keys",
|
|
21
|
+
"resume",
|
|
22
|
+
"scan_folder",
|
|
23
|
+
"select_primary_video_paths",
|
|
24
|
+
"status",
|
|
25
|
+
"upload",
|
|
26
|
+
"validate_mcap_mp4",
|
|
27
|
+
"wait_for_upload",
|
|
28
|
+
]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from .errors import PrismaxError
|
|
6
|
+
from .upload import resume, status, upload
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _print_json(payload):
|
|
10
|
+
print(json.dumps(payload, indent=2, default=str))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main(argv=None):
|
|
14
|
+
parser = argparse.ArgumentParser(prog="prismax")
|
|
15
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
16
|
+
|
|
17
|
+
upload_parser = subparsers.add_parser("upload")
|
|
18
|
+
upload_parser.add_argument("folder")
|
|
19
|
+
upload_parser.add_argument("--task-id", required=True, type=int)
|
|
20
|
+
upload_parser.add_argument("--serial-number", required=True)
|
|
21
|
+
upload_parser.add_argument("--api-key")
|
|
22
|
+
upload_parser.add_argument("--base-url")
|
|
23
|
+
upload_parser.add_argument("--wait", action="store_true")
|
|
24
|
+
upload_parser.add_argument("--max-wait", type=int, default=1800)
|
|
25
|
+
upload_parser.add_argument("--poll-interval", type=int, default=10)
|
|
26
|
+
upload_parser.add_argument("--timeout", type=int, default=60)
|
|
27
|
+
upload_parser.add_argument("--retries", type=int, default=3)
|
|
28
|
+
upload_parser.add_argument("--max-poll-errors", type=int, default=3)
|
|
29
|
+
upload_parser.add_argument("--concurrency", type=int, default=5)
|
|
30
|
+
|
|
31
|
+
resume_parser = subparsers.add_parser("resume")
|
|
32
|
+
resume_parser.add_argument("upload_id", type=int)
|
|
33
|
+
resume_parser.add_argument("folder")
|
|
34
|
+
resume_parser.add_argument("--api-key")
|
|
35
|
+
resume_parser.add_argument("--base-url")
|
|
36
|
+
resume_parser.add_argument("--wait", action="store_true")
|
|
37
|
+
resume_parser.add_argument("--max-wait", type=int, default=1800)
|
|
38
|
+
resume_parser.add_argument("--poll-interval", type=int, default=10)
|
|
39
|
+
resume_parser.add_argument("--timeout", type=int, default=60)
|
|
40
|
+
resume_parser.add_argument("--retries", type=int, default=3)
|
|
41
|
+
resume_parser.add_argument("--max-poll-errors", type=int, default=3)
|
|
42
|
+
resume_parser.add_argument("--concurrency", type=int, default=5)
|
|
43
|
+
|
|
44
|
+
status_parser = subparsers.add_parser("status")
|
|
45
|
+
status_parser.add_argument("upload_id", type=int)
|
|
46
|
+
status_parser.add_argument("--api-key")
|
|
47
|
+
status_parser.add_argument("--base-url")
|
|
48
|
+
status_parser.add_argument("--timeout", type=int, default=60)
|
|
49
|
+
status_parser.add_argument("--retries", type=int, default=3)
|
|
50
|
+
|
|
51
|
+
args = parser.parse_args(argv)
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
if args.command == "upload":
|
|
55
|
+
result = upload(
|
|
56
|
+
args.folder,
|
|
57
|
+
task_id=args.task_id,
|
|
58
|
+
serial_number=args.serial_number,
|
|
59
|
+
api_key=args.api_key,
|
|
60
|
+
base_url=args.base_url,
|
|
61
|
+
wait=args.wait,
|
|
62
|
+
poll_interval=args.poll_interval,
|
|
63
|
+
max_wait=args.max_wait,
|
|
64
|
+
max_poll_errors=args.max_poll_errors,
|
|
65
|
+
timeout=args.timeout,
|
|
66
|
+
concurrency=args.concurrency,
|
|
67
|
+
retries=args.retries,
|
|
68
|
+
)
|
|
69
|
+
_print_json(result)
|
|
70
|
+
return 0
|
|
71
|
+
|
|
72
|
+
if args.command == "resume":
|
|
73
|
+
result = resume(
|
|
74
|
+
args.upload_id,
|
|
75
|
+
args.folder,
|
|
76
|
+
api_key=args.api_key,
|
|
77
|
+
base_url=args.base_url,
|
|
78
|
+
wait=args.wait,
|
|
79
|
+
poll_interval=args.poll_interval,
|
|
80
|
+
max_wait=args.max_wait,
|
|
81
|
+
max_poll_errors=args.max_poll_errors,
|
|
82
|
+
timeout=args.timeout,
|
|
83
|
+
concurrency=args.concurrency,
|
|
84
|
+
retries=args.retries,
|
|
85
|
+
)
|
|
86
|
+
_print_json(result)
|
|
87
|
+
return 0
|
|
88
|
+
|
|
89
|
+
if args.command == "status":
|
|
90
|
+
_print_json(status(
|
|
91
|
+
args.upload_id,
|
|
92
|
+
api_key=args.api_key,
|
|
93
|
+
base_url=args.base_url,
|
|
94
|
+
timeout=args.timeout,
|
|
95
|
+
retries=args.retries,
|
|
96
|
+
))
|
|
97
|
+
return 0
|
|
98
|
+
except PrismaxError as exc:
|
|
99
|
+
print(f"prismax: {exc}", file=sys.stderr)
|
|
100
|
+
return 1
|
|
101
|
+
|
|
102
|
+
parser.error(f"Unknown command: {args.command}")
|
|
103
|
+
return 2
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if __name__ == "__main__":
|
|
107
|
+
raise SystemExit(main())
|