rocket-welder-sdk 1.1.33__py3-none-any.whl → 1.1.34__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rocket_welder_sdk/__init__.py +34 -0
- rocket_welder_sdk/controllers.py +7 -3
- rocket_welder_sdk/frame_metadata.py +2 -2
- rocket_welder_sdk/high_level/__init__.py +11 -25
- rocket_welder_sdk/high_level/client.py +262 -0
- rocket_welder_sdk/high_level/connection_strings.py +56 -55
- rocket_welder_sdk/high_level/data_context.py +17 -11
- rocket_welder_sdk/high_level/schema.py +44 -27
- rocket_welder_sdk/high_level/transport_protocol.py +180 -108
- rocket_welder_sdk/rocket_welder_client.py +77 -0
- rocket_welder_sdk/session_id.py +238 -0
- rocket_welder_sdk/transport/__init__.py +0 -8
- {rocket_welder_sdk-1.1.33.dist-info → rocket_welder_sdk-1.1.34.dist-info}/METADATA +1 -1
- {rocket_welder_sdk-1.1.33.dist-info → rocket_welder_sdk-1.1.34.dist-info}/RECORD +16 -14
- {rocket_welder_sdk-1.1.33.dist-info → rocket_welder_sdk-1.1.34.dist-info}/WHEEL +0 -0
- {rocket_welder_sdk-1.1.33.dist-info → rocket_welder_sdk-1.1.34.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"""SessionId parsing utilities for NNG URL generation.
|
|
2
|
+
|
|
3
|
+
SessionId format: ps-{guid} (e.g., ps-a1b2c3d4-e5f6-7890-abcd-ef1234567890)
|
|
4
|
+
Prefix "ps" = PipelineSession.
|
|
5
|
+
|
|
6
|
+
This module provides utilities to:
|
|
7
|
+
1. Parse SessionId from environment variable
|
|
8
|
+
2. Extract the Guid portion
|
|
9
|
+
3. Generate NNG IPC URLs for streaming results
|
|
10
|
+
4. Read explicit NNG URLs from environment variables (preferred)
|
|
11
|
+
|
|
12
|
+
## URL Configuration Priority
|
|
13
|
+
|
|
14
|
+
The SDK supports two ways to configure NNG URLs:
|
|
15
|
+
|
|
16
|
+
1. **Explicit URLs (PREFERRED)** - Set by rocket-welder2:
|
|
17
|
+
- SEGMENTATION_SINK_URL
|
|
18
|
+
- KEYPOINTS_SINK_URL
|
|
19
|
+
- ACTIONS_SINK_URL
|
|
20
|
+
|
|
21
|
+
2. **Derived from SessionId (FALLBACK)** - For backwards compatibility:
|
|
22
|
+
- SessionId env var → parse GUID → generate URLs
|
|
23
|
+
|
|
24
|
+
Use `get_nng_urls_from_env()` for explicit URLs (preferred).
|
|
25
|
+
Use `get_nng_urls(session_id)` for SessionId-derived URLs (fallback).
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import logging
|
|
31
|
+
import os
|
|
32
|
+
import uuid
|
|
33
|
+
|
|
34
|
+
logger = logging.getLogger(__name__)
|
|
35
|
+
|
|
36
|
+
SESSION_ID_PREFIX = "ps-"
|
|
37
|
+
SESSION_ID_ENV_VAR = "SessionId"
|
|
38
|
+
|
|
39
|
+
# Explicit URL environment variables (set by rocket-welder2)
|
|
40
|
+
SEGMENTATION_SINK_URL_ENV = "SEGMENTATION_SINK_URL"
|
|
41
|
+
KEYPOINTS_SINK_URL_ENV = "KEYPOINTS_SINK_URL"
|
|
42
|
+
ACTIONS_SINK_URL_ENV = "ACTIONS_SINK_URL"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def parse_session_id(session_id: str) -> uuid.UUID:
|
|
46
|
+
"""Parse SessionId (ps-{guid}) to extract Guid.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
session_id: SessionId string (e.g., "ps-a1b2c3d4-...")
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
UUID extracted from SessionId
|
|
53
|
+
|
|
54
|
+
Raises:
|
|
55
|
+
ValueError: If session_id format is invalid
|
|
56
|
+
|
|
57
|
+
Examples:
|
|
58
|
+
>>> parse_session_id("ps-a1b2c3d4-e5f6-7890-abcd-ef1234567890")
|
|
59
|
+
UUID('a1b2c3d4-e5f6-7890-abcd-ef1234567890')
|
|
60
|
+
>>> parse_session_id("a1b2c3d4-e5f6-7890-abcd-ef1234567890") # backwards compat
|
|
61
|
+
UUID('a1b2c3d4-e5f6-7890-abcd-ef1234567890')
|
|
62
|
+
"""
|
|
63
|
+
if session_id.startswith(SESSION_ID_PREFIX):
|
|
64
|
+
return uuid.UUID(session_id[len(SESSION_ID_PREFIX) :])
|
|
65
|
+
# Fallback: try parsing as raw guid for backwards compatibility
|
|
66
|
+
return uuid.UUID(session_id)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_session_id_from_env() -> str | None:
|
|
70
|
+
"""Get SessionId from environment variable.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
SessionId string or None if not set
|
|
74
|
+
"""
|
|
75
|
+
return os.environ.get(SESSION_ID_ENV_VAR)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def get_nng_urls(session_id: str) -> dict[str, str]:
|
|
79
|
+
"""Generate NNG IPC URLs from SessionId.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
session_id: SessionId string (e.g., "ps-a1b2c3d4-...")
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
Dictionary with 'segmentation', 'keypoints', 'actions' URLs
|
|
86
|
+
|
|
87
|
+
Examples:
|
|
88
|
+
>>> urls = get_nng_urls("ps-a1b2c3d4-e5f6-7890-abcd-ef1234567890")
|
|
89
|
+
>>> urls["segmentation"]
|
|
90
|
+
'ipc:///tmp/rw-a1b2c3d4-e5f6-7890-abcd-ef1234567890-seg.sock'
|
|
91
|
+
"""
|
|
92
|
+
guid = parse_session_id(session_id)
|
|
93
|
+
return {
|
|
94
|
+
"segmentation": f"ipc:///tmp/rw-{guid}-seg.sock",
|
|
95
|
+
"keypoints": f"ipc:///tmp/rw-{guid}-kp.sock",
|
|
96
|
+
"actions": f"ipc:///tmp/rw-{guid}-actions.sock",
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def get_segmentation_url(session_id: str) -> str:
|
|
101
|
+
"""Get NNG URL for segmentation stream.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
session_id: SessionId string (e.g., "ps-a1b2c3d4-...")
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
IPC URL for segmentation stream
|
|
108
|
+
"""
|
|
109
|
+
guid = parse_session_id(session_id)
|
|
110
|
+
return f"ipc:///tmp/rw-{guid}-seg.sock"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def get_keypoints_url(session_id: str) -> str:
|
|
114
|
+
"""Get NNG URL for keypoints stream.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
session_id: SessionId string (e.g., "ps-a1b2c3d4-...")
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
IPC URL for keypoints stream
|
|
121
|
+
"""
|
|
122
|
+
guid = parse_session_id(session_id)
|
|
123
|
+
return f"ipc:///tmp/rw-{guid}-kp.sock"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def get_actions_url(session_id: str) -> str:
|
|
127
|
+
"""Get NNG URL for actions stream.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
session_id: SessionId string (e.g., "ps-a1b2c3d4-...")
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
IPC URL for actions stream
|
|
134
|
+
"""
|
|
135
|
+
guid = parse_session_id(session_id)
|
|
136
|
+
return f"ipc:///tmp/rw-{guid}-actions.sock"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# ============================================================================
|
|
140
|
+
# Explicit URL functions (PREFERRED - URLs set by rocket-welder2)
|
|
141
|
+
# ============================================================================
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def get_nng_urls_from_env() -> dict[str, str | None]:
|
|
145
|
+
"""Get NNG URLs from explicit environment variables.
|
|
146
|
+
|
|
147
|
+
This is the PREFERRED method for getting NNG URLs. rocket-welder2
|
|
148
|
+
sets these environment variables when starting containers.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Dictionary with 'segmentation', 'keypoints', 'actions' URLs.
|
|
152
|
+
Values are None if not configured.
|
|
153
|
+
|
|
154
|
+
Examples:
|
|
155
|
+
>>> os.environ["SEGMENTATION_SINK_URL"] = "ipc:///tmp/rw-abc-seg.sock"
|
|
156
|
+
>>> urls = get_nng_urls_from_env()
|
|
157
|
+
>>> urls["segmentation"]
|
|
158
|
+
'ipc:///tmp/rw-abc-seg.sock'
|
|
159
|
+
"""
|
|
160
|
+
return {
|
|
161
|
+
"segmentation": os.environ.get(SEGMENTATION_SINK_URL_ENV),
|
|
162
|
+
"keypoints": os.environ.get(KEYPOINTS_SINK_URL_ENV),
|
|
163
|
+
"actions": os.environ.get(ACTIONS_SINK_URL_ENV),
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def get_segmentation_url_from_env() -> str | None:
|
|
168
|
+
"""Get segmentation NNG URL from environment variable.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
IPC URL for segmentation stream, or None if not configured.
|
|
172
|
+
"""
|
|
173
|
+
return os.environ.get(SEGMENTATION_SINK_URL_ENV)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def get_keypoints_url_from_env() -> str | None:
|
|
177
|
+
"""Get keypoints NNG URL from environment variable.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
IPC URL for keypoints stream, or None if not configured.
|
|
181
|
+
"""
|
|
182
|
+
return os.environ.get(KEYPOINTS_SINK_URL_ENV)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def get_actions_url_from_env() -> str | None:
|
|
186
|
+
"""Get actions NNG URL from environment variable.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
IPC URL for actions stream, or None if not configured.
|
|
190
|
+
"""
|
|
191
|
+
return os.environ.get(ACTIONS_SINK_URL_ENV)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def has_explicit_nng_urls() -> bool:
|
|
195
|
+
"""Check if explicit NNG URLs are configured.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
True if at least segmentation OR keypoints URL is configured.
|
|
199
|
+
"""
|
|
200
|
+
urls = get_nng_urls_from_env()
|
|
201
|
+
return bool(urls["segmentation"] or urls["keypoints"])
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def get_configured_nng_urls() -> dict[str, str]:
|
|
205
|
+
"""Get all configured NNG URLs (explicit or derived from SessionId).
|
|
206
|
+
|
|
207
|
+
Priority:
|
|
208
|
+
1. Explicit URLs from environment (SEGMENTATION_SINK_URL, etc.)
|
|
209
|
+
2. Derived from SessionId environment variable (fallback)
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
Dictionary with 'segmentation', 'keypoints', 'actions' URLs.
|
|
213
|
+
Only includes URLs that are actually configured.
|
|
214
|
+
|
|
215
|
+
Raises:
|
|
216
|
+
ValueError: If no NNG URLs are configured (neither explicit nor SessionId).
|
|
217
|
+
"""
|
|
218
|
+
# Try explicit URLs first (preferred)
|
|
219
|
+
explicit_urls = get_nng_urls_from_env()
|
|
220
|
+
result: dict[str, str] = {}
|
|
221
|
+
|
|
222
|
+
for name, url in explicit_urls.items():
|
|
223
|
+
if url:
|
|
224
|
+
result[name] = url
|
|
225
|
+
|
|
226
|
+
# If we have at least one explicit URL, return what we have
|
|
227
|
+
if result:
|
|
228
|
+
return result
|
|
229
|
+
|
|
230
|
+
# Fallback: derive from SessionId
|
|
231
|
+
session_id = get_session_id_from_env()
|
|
232
|
+
if session_id:
|
|
233
|
+
return get_nng_urls(session_id)
|
|
234
|
+
|
|
235
|
+
raise ValueError(
|
|
236
|
+
"No NNG URLs configured. Set SEGMENTATION_SINK_URL/KEYPOINTS_SINK_URL "
|
|
237
|
+
"environment variables, or set SessionId for URL derivation."
|
|
238
|
+
)
|
|
@@ -28,11 +28,3 @@ __all__ = [
|
|
|
28
28
|
"UnixSocketFrameSource",
|
|
29
29
|
"UnixSocketServer",
|
|
30
30
|
]
|
|
31
|
-
|
|
32
|
-
# NNG transport is optional (requires pynng package)
|
|
33
|
-
try:
|
|
34
|
-
from .nng_transport import NngFrameSink, NngFrameSource
|
|
35
|
-
|
|
36
|
-
__all__.extend(["NngFrameSink", "NngFrameSource"])
|
|
37
|
-
except ImportError:
|
|
38
|
-
pass # pynng not installed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rocket-welder-sdk
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.34
|
|
4
4
|
Summary: High-performance video streaming SDK for RocketWelder services using ZeroBuffer IPC
|
|
5
5
|
Home-page: https://github.com/modelingevolution/rocket-welder-sdk
|
|
6
6
|
Author: ModelingEvolution
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
rocket_welder_sdk/__init__.py,sha256=
|
|
1
|
+
rocket_welder_sdk/__init__.py,sha256=pcYOCqqYuK8oJwkFRnWej4uNfEkuYWXP6jcUhPSLgrc,3041
|
|
2
2
|
rocket_welder_sdk/bytes_size.py,sha256=Myl29-wyWCIYdbMmgaxXebT8Dz8_Fwcr3fnfaNW81P0,7463
|
|
3
3
|
rocket_welder_sdk/connection_string.py,sha256=NIC6OiOXF-DeBFCWzgMFOWsenrSS45hY81j_HLMSpgo,9974
|
|
4
|
-
rocket_welder_sdk/controllers.py,sha256=
|
|
5
|
-
rocket_welder_sdk/frame_metadata.py,sha256=
|
|
4
|
+
rocket_welder_sdk/controllers.py,sha256=tPfQ2GZRfLbj-M21uAa9X3cFzrBBvqSbxTUxPiaZ5xc,32690
|
|
5
|
+
rocket_welder_sdk/frame_metadata.py,sha256=TMLIY47cIdIlxqk9xj7I3M8FZFmZ3GcVoLZht7prjQM,3929
|
|
6
6
|
rocket_welder_sdk/gst_metadata.py,sha256=jEQvZX4BdR6OR3lqp12PV-HEXZhcxfiS010diA2CbMM,14213
|
|
7
7
|
rocket_welder_sdk/keypoints_protocol.py,sha256=NKiSPrevWG4_RrD6jtFxPjwftlaPWe1CqoFVKRMwp4k,21858
|
|
8
8
|
rocket_welder_sdk/opencv_controller.py,sha256=MDM6_yFBB9BaMa5jnZRqw7xZZB-WuLr7EPrrfHQ2DK4,9905
|
|
9
9
|
rocket_welder_sdk/periodic_timer.py,sha256=hnObybmrnf3J47QrNKJhYAytLKwria016123NvPRfQ0,9369
|
|
10
10
|
rocket_welder_sdk/py.typed,sha256=0cXFZXmes4Y-vnl4lO3HtyyyWaFNw85B7tJdFeCtHDc,67
|
|
11
|
-
rocket_welder_sdk/rocket_welder_client.py,sha256=
|
|
11
|
+
rocket_welder_sdk/rocket_welder_client.py,sha256=0SNsrP9SePTHNLbfKyt-71UYs2owrZwesiwOXNglI4c,18515
|
|
12
12
|
rocket_welder_sdk/segmentation_result.py,sha256=q3n8m1sooPcattfXisL9em5gZKbEZ1ueGqeXfOrdaHY,13417
|
|
13
|
+
rocket_welder_sdk/session_id.py,sha256=sRhzQw90shqq_DJVtrsSggcGZ775kz7cRfbI-1LMeSA,7027
|
|
13
14
|
rocket_welder_sdk/external_controls/__init__.py,sha256=ldOLGhLLS5BQL8m4VKFYV0SvsNNlV2tghlc7rkqadU8,699
|
|
14
15
|
rocket_welder_sdk/external_controls/contracts.py,sha256=3DU6pdpteN50gF2fsS7C2279dGjDa0tZLrLntkBa2LM,2607
|
|
15
16
|
rocket_welder_sdk/external_controls/contracts_old.py,sha256=XWriuXJZu5caTSS0bcTIOZcKnj-IRCm96voA4gqLBfU,2980
|
|
16
|
-
rocket_welder_sdk/high_level/__init__.py,sha256=
|
|
17
|
-
rocket_welder_sdk/high_level/
|
|
18
|
-
rocket_welder_sdk/high_level/
|
|
19
|
-
rocket_welder_sdk/high_level/
|
|
20
|
-
rocket_welder_sdk/high_level/
|
|
21
|
-
rocket_welder_sdk/
|
|
17
|
+
rocket_welder_sdk/high_level/__init__.py,sha256=C1Gan74Ce_JQZKJmXhpP3L3O11wvOClesBVaAxRZQaA,1305
|
|
18
|
+
rocket_welder_sdk/high_level/client.py,sha256=kVtxpzP9qZgv-SYG_0glDckHapEod4MFl5NQ75TR_b4,9584
|
|
19
|
+
rocket_welder_sdk/high_level/connection_strings.py,sha256=q1uZJQ7mt1RR-E8MJzIwG6vz3Ddruoc3pTCdTvg_pe4,10434
|
|
20
|
+
rocket_welder_sdk/high_level/data_context.py,sha256=SXJvDpDBFi8Lm4XqSRSHK7YUUHuugXGo4ZRCb6_z5l0,4833
|
|
21
|
+
rocket_welder_sdk/high_level/schema.py,sha256=7F5DfPACHUfOpbJE4YZJRpro9VL8tLa6Kt9ZJuY7R7w,5397
|
|
22
|
+
rocket_welder_sdk/high_level/transport_protocol.py,sha256=EFF0bgNn9hxRMj67FwU6MVu-UiEFINSGhd2VC8agrgc,7393
|
|
23
|
+
rocket_welder_sdk/transport/__init__.py,sha256=DYmZpohGPU7RhS6EdVT_BwCy5MZzyTQ6Eymm8TpmxJ8,751
|
|
22
24
|
rocket_welder_sdk/transport/frame_sink.py,sha256=16dUefZF1QJv62Ig0ezPR6nEho_7A3WJu4M9_PPMqJM,2164
|
|
23
25
|
rocket_welder_sdk/transport/frame_source.py,sha256=G1rBAQS1AgOOdtASB0_CYon8g20hUGXpP2exCp5hlhk,2169
|
|
24
26
|
rocket_welder_sdk/transport/nng_transport.py,sha256=o-qgcmHCGnwtdPe-mwwrC-a9H0rgS-VdH2QvU-6kFlI,5838
|
|
@@ -31,7 +33,7 @@ rocket_welder_sdk/ui/icons.py,sha256=DcDklZkPmiEzlOD4IR7VTJOtGPCuuh_OM_WN7ScghWE
|
|
|
31
33
|
rocket_welder_sdk/ui/ui_events_projection.py,sha256=siiNhjLEBOPfTKw1ZhOPGkwIN5rLDH7V9VCZTNrhEtQ,7836
|
|
32
34
|
rocket_welder_sdk/ui/ui_service.py,sha256=uRdpyJGoCQmtOli_HKSrxLwhZYG-XRuHIYdkmFz1zNk,12026
|
|
33
35
|
rocket_welder_sdk/ui/value_types.py,sha256=f7OA_9zgXEDPoITc8v8SfAR23I4XeFhE3E2_GcAbR6k,1616
|
|
34
|
-
rocket_welder_sdk-1.1.
|
|
35
|
-
rocket_welder_sdk-1.1.
|
|
36
|
-
rocket_welder_sdk-1.1.
|
|
37
|
-
rocket_welder_sdk-1.1.
|
|
36
|
+
rocket_welder_sdk-1.1.34.dist-info/METADATA,sha256=zI8JTjId1nm1yfU6y-10l4vKl2vOiJqj6uL4GZUfkVc,24847
|
|
37
|
+
rocket_welder_sdk-1.1.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
+
rocket_welder_sdk-1.1.34.dist-info/top_level.txt,sha256=2iZvBjnwVCUW-uDE23-eJld5PZ9-mlPI69QiXM5IrTA,18
|
|
39
|
+
rocket_welder_sdk-1.1.34.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|