sequence-ai 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.
- sequence_ai-0.1.0/.gitignore +5 -0
- sequence_ai-0.1.0/LICENSE +202 -0
- sequence_ai-0.1.0/PKG-INFO +267 -0
- sequence_ai-0.1.0/README.md +237 -0
- sequence_ai-0.1.0/pyproject.toml +117 -0
- sequence_ai-0.1.0/sequence_ai/__init__.py +192 -0
- sequence_ai-0.1.0/sequence_ai/_config.py +72 -0
- sequence_ai-0.1.0/sequence_ai/_policy.py +603 -0
- sequence_ai-0.1.0/sequence_ai/_transport.py +201 -0
- sequence_ai-0.1.0/sequence_ai/cli.py +250 -0
- sequence_ai-0.1.0/sequence_ai/errors.py +96 -0
- sequence_ai-0.1.0/sequence_ai/py.typed +0 -0
- sequence_ai-0.1.0/sequence_ai/types.py +221 -0
- sequence_ai-0.1.0/tests/conftest.py +178 -0
- sequence_ai-0.1.0/tests/test_cli.py +165 -0
- sequence_ai-0.1.0/tests/test_sdk.py +669 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sequence-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cloud inference for robot policies — a control loop that keeps the connection open and the action buffer full.
|
|
5
|
+
Project-URL: Homepage, https://generalsequences.com
|
|
6
|
+
Project-URL: Documentation, https://generalsequences.com/docs/
|
|
7
|
+
Project-URL: Console, https://app.generalsequences.com
|
|
8
|
+
Author: General Sequences
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: inference,manipulation,policy,robotics,vla
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: httpx>=0.24
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# sequence-ai
|
|
32
|
+
|
|
33
|
+
Cloud inference for robot policies.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install sequence-ai
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import sequence_ai
|
|
41
|
+
|
|
42
|
+
with sequence_ai.connect(model="pi05-droid") as policy:
|
|
43
|
+
out = policy.run(
|
|
44
|
+
observe=robot.read_observation,
|
|
45
|
+
act=robot.apply_action,
|
|
46
|
+
validate=robot.is_safe,
|
|
47
|
+
hold=robot.hold,
|
|
48
|
+
max_actions=250,
|
|
49
|
+
)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## What it does for you
|
|
55
|
+
|
|
56
|
+
Four things, and each of them is something a loop written straight against the HTTP endpoints
|
|
57
|
+
has to get right before it behaves properly on a robot:
|
|
58
|
+
|
|
59
|
+
| | Without it |
|
|
60
|
+
|---|---|
|
|
61
|
+
| Keeps the connection open | 185 ms of handshake on every call — 60% of a bare request |
|
|
62
|
+
| Refills before the buffer empties | The arm stops once per chunk, for a full round trip |
|
|
63
|
+
| Classifies errors | No way to tell "wait 118 s" from "stop and page someone" |
|
|
64
|
+
| One driver per buffer | Two loops on one handle interleave, and both report success |
|
|
65
|
+
|
|
66
|
+
None of the four is guesswork. Every one is a defect that existed in this client, was measured,
|
|
67
|
+
and was fixed — the numbers below are those measurements, not estimates.
|
|
68
|
+
|
|
69
|
+
## It keeps the connection open
|
|
70
|
+
|
|
71
|
+
Measured against the production gateway, six samples each:
|
|
72
|
+
|
|
73
|
+
| | median | min | max |
|
|
74
|
+
|---|---|---|---|
|
|
75
|
+
| new connection per call | **305.9 ms** | 246.7 | 766.7 |
|
|
76
|
+
| one reused connection | **121.0 ms** | 116.8 | 133.4 |
|
|
77
|
+
|
|
78
|
+
**184.9 ms per call — 60% of the total — is TCP and TLS handshake.** That is what
|
|
79
|
+
`with sequence_ai.connect(...)` removes. Nothing proprietary: any HTTP client that reuses a
|
|
80
|
+
connection gets the same result. This package just makes it the default rather than
|
|
81
|
+
something you have to remember.
|
|
82
|
+
|
|
83
|
+
Why it matters: a chunk is a deadline. `pi05-droid` returns 1.00 s of motion per call, and a
|
|
84
|
+
warm end-to-end `/v1/act` through this gateway measured **793 ms** — the next chunk has to
|
|
85
|
+
arrive before the current one finishes playing, so 185 ms of avoidable handshake is a fifth
|
|
86
|
+
of the entire budget.
|
|
87
|
+
|
|
88
|
+
## Actions come in chunks
|
|
89
|
+
|
|
90
|
+
One call returns a block of future actions, not a single command — between 0.5 s and 2.1 s
|
|
91
|
+
of motion depending on the model. That is why cloud inference works at all: the control loop
|
|
92
|
+
does not need a network round trip per control step.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
with sequence_ai.connect(model="pi05-droid") as policy:
|
|
96
|
+
pred = policy.predict(observation)
|
|
97
|
+
print(len(pred.action_chunk), "steps covering",
|
|
98
|
+
pred.action_chunk.covers_seconds, "s at",
|
|
99
|
+
pred.action_chunk.control_frequency_hz, "Hz")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## The gap between chunks is the hard part
|
|
103
|
+
|
|
104
|
+
A loop that waits for the buffer to empty before asking for the next chunk stops the arm once
|
|
105
|
+
per chunk, every chunk, for a full round trip. It is not an occasional hiccup — it is
|
|
106
|
+
structural, and on the faster models it dominates:
|
|
107
|
+
|
|
108
|
+
| model | chunk covers | refill | arm actually moving |
|
|
109
|
+
|---|---:|---:|---:|
|
|
110
|
+
| `cosmos3-edge-policy-droid` | 2.13 s | ~0.79 s | 73% |
|
|
111
|
+
| `pi05-droid` | 1.00 s | ~0.79 s | 56% |
|
|
112
|
+
| `lingbot-va-5b` | 0.64 s | ~0.79 s | 45% |
|
|
113
|
+
| `lingbot-vla-v2-6b` | 0.50 s | ~0.79 s | **39%** |
|
|
114
|
+
|
|
115
|
+
So `run()` starts the next inference *while the current chunk is still playing*, and reports
|
|
116
|
+
what happened rather than hoping:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
out = policy.run(observe=..., act=..., max_actions=250, on_underrun=robot.hold_position)
|
|
120
|
+
|
|
121
|
+
print(out) # RunOutcome(250 actions over 17 chunks in 16.8s, completed)
|
|
122
|
+
out.underruns # times the buffer ran dry before the next chunk arrived
|
|
123
|
+
out.underrun_s # total seconds the arm spent with no command
|
|
124
|
+
out.max_seam_jump # largest per-dimension step across a chunk boundary
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**The trade, stated plainly:** a prefetched chunk is computed from an observation taken
|
|
128
|
+
*before* the previous chunk finished, so the overlap window is open-loop. Freshness and
|
|
129
|
+
continuity are in direct opposition here and no setting gets both. `prefetch=False` restores
|
|
130
|
+
strictly closed-loop behaviour, stall included — right for bench work, wrong for a moving arm.
|
|
131
|
+
|
|
132
|
+
`max_seam_jump` is a **measurement, not a correction**, and it stays one unless you ask
|
|
133
|
+
otherwise. `smooth_seam=N` ramps the first N steps of each new chunk out of the last executed
|
|
134
|
+
action, and it is the only setting in this library that changes a number on its way to the
|
|
135
|
+
motors — so it is off by default and guarded twice: it applies only when the chunk declares an
|
|
136
|
+
*absolute* action space (`action_chunk.action_space`), and never to the first chunk of a run.
|
|
137
|
+
Blending deltas is not smoothing; it rescales the increments and moves the arm somewhere the
|
|
138
|
+
model never asked for, so a delta chunk is passed through untouched even when you ask.
|
|
139
|
+
`max_seam_jump` is measured *before* any blending, so turning it on cannot hide what it smooths.
|
|
140
|
+
|
|
141
|
+
## Many robots at once
|
|
142
|
+
|
|
143
|
+
**One `Policy` per control loop.** A `Policy` holds one action buffer, and two loops popping
|
|
144
|
+
from it do not take turns — they interleave. Driving the same handle from a second thread
|
|
145
|
+
raises, because both quieter options are worse: interleaving sends each robot a shuffled half
|
|
146
|
+
of the other's plan while both loops report success, and a blocking lock would make the second
|
|
147
|
+
loop run at half rate, underrunning on every chunk.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
def drive(robot, model):
|
|
151
|
+
with sequence_ai.connect(model=model) as policy: # one each
|
|
152
|
+
return policy.run(observe=robot.read, act=robot.apply,
|
|
153
|
+
validate=robot.is_safe, max_actions=250)
|
|
154
|
+
|
|
155
|
+
with ThreadPoolExecutor() as pool:
|
|
156
|
+
left, right = pool.map(drive, [arm_l, arm_r], ["pi05-droid"] * 2)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This costs nothing to follow. The handshake is paid *once per `Policy`*, not once per call.
|
|
160
|
+
Measured with eight loops running concurrently against one gateway: eight connections, ten
|
|
161
|
+
requests each, zero sequence breaks, zero underruns. Requests arriving while the gateway is
|
|
162
|
+
busy queue on the server rather than displacing work already in flight.
|
|
163
|
+
|
|
164
|
+
## Cold starts
|
|
165
|
+
|
|
166
|
+
A worker that is not loaded takes about **100 seconds** to become ready. The gateway does not
|
|
167
|
+
stall on it — it answers 503 immediately with the number:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
try:
|
|
171
|
+
policy.predict(observation)
|
|
172
|
+
except sequence_ai.Unavailable as exc:
|
|
173
|
+
if exc.warming:
|
|
174
|
+
print(f"loading; ready in ~{exc.retry_after_s}s") # 118
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`run()` can wait that out for you, **but only before the first action**:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
policy.run(..., startup_timeout_s=180)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
That line is the whole design. Before the first action nothing is moving, so waiting is free.
|
|
184
|
+
Once the arm is in motion, silently pausing it for two minutes and resuming from a
|
|
185
|
+
two-minute-old plan is worse than stopping — so mid-run warming is raised, and `hold` fires.
|
|
186
|
+
|
|
187
|
+
## Three ways to drive it
|
|
188
|
+
|
|
189
|
+
From most control to least. They are the same request underneath; the difference is who owns
|
|
190
|
+
the loop.
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
policy.predict(obs) # the whole chunk, you do everything
|
|
194
|
+
policy.next_action(obs) # we hold the buffer, you own the cadence
|
|
195
|
+
policy.run(observe=, act=) # we own the loop
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Safety
|
|
199
|
+
|
|
200
|
+
**An action returned by any model is model output, not a safe robot command.**
|
|
201
|
+
|
|
202
|
+
This library does not check joint limits, reachability, collisions, or whether a step is safe
|
|
203
|
+
at the robot's current velocity. Bounds checking, a watchdog and an e-stop belong between
|
|
204
|
+
this library and your motors.
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
policy.run(
|
|
208
|
+
observe=robot.read_observation,
|
|
209
|
+
act=robot.apply_action,
|
|
210
|
+
validate=robot.is_safe, # return False to stop the loop
|
|
211
|
+
hold=robot.hold, # called if it stops early, or if act() raises
|
|
212
|
+
max_actions=250,
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`max_actions` is required and keyword-only. There is no `run_forever()` — an unbounded loop
|
|
217
|
+
that moves a robot should not be startable by accident.
|
|
218
|
+
|
|
219
|
+
`validate=None` is allowed for bench and simulation work, and warns once so it cannot happen
|
|
220
|
+
silently on real hardware.
|
|
221
|
+
|
|
222
|
+
## Errors are typed
|
|
223
|
+
|
|
224
|
+
Because a controller reacts differently to each:
|
|
225
|
+
|
|
226
|
+
| | meaning | what to do |
|
|
227
|
+
|---|---|---|
|
|
228
|
+
| `AuthError` | key missing, revoked, expired | stop; retrying will not help |
|
|
229
|
+
| `OutOfCredit` | balance exhausted | stop and hold; top up |
|
|
230
|
+
| `InvalidRequest` | bad model, malformed observation, body too large | fix it; deterministic |
|
|
231
|
+
| `Unavailable` | upstream blip, or a cold worker | check `.warming` — see below |
|
|
232
|
+
| `ChunkExhausted` | asked for an action with an empty buffer and no observation | pass `observation=` every call |
|
|
233
|
+
|
|
234
|
+
## Configuration
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
export SEQUENCES_API_KEY=seq_live_... # or pass api_key= to connect()
|
|
238
|
+
export SEQUENCES_BASE_URL=... # for staging; defaults to production
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Get a key at [app.generalsequences.com](https://app.generalsequences.com).
|
|
242
|
+
|
|
243
|
+
## Install footprint
|
|
244
|
+
|
|
245
|
+
One dependency: `httpx`. Python 3.9+.
|
|
246
|
+
|
|
247
|
+
A robot controller is often on a Jetson with a pinned, fragile Python environment, and ROS 2
|
|
248
|
+
Humble ships Python 3.10. Every transitive dependency is another chance for the install to
|
|
249
|
+
fail on the machine that actually matters.
|
|
250
|
+
|
|
251
|
+
## If your controller is not Python
|
|
252
|
+
|
|
253
|
+
The endpoints underneath are public and documented at
|
|
254
|
+
[generalsequences.com/docs](https://generalsequences.com/docs/). There is no private control
|
|
255
|
+
plane and nothing this package reaches that you cannot:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
curl https://api.generalsequences.com/v1/act \
|
|
259
|
+
-H "Authorization: Bearer $SEQUENCES_API_KEY" \
|
|
260
|
+
-d '{"model":"accounts/sequences/models/pi05-droid","observation":{...}}'
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Keeping that door open is deliberate — a vendor SDK that is the *only* supported way in locks
|
|
264
|
+
you to one language, and robot controllers are very often C++. But it is a door, not the front
|
|
265
|
+
entrance. The four items in the table at the top are work your client then has to do itself,
|
|
266
|
+
and [the reference](https://generalsequences.com/docs/python/) documents each precisely enough
|
|
267
|
+
to reimplement. Reaching for Python first is simply cheaper.
|