dora-rs 0.3.14rc0__cp37-abi3-manylinux_2_28_x86_64.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.
dora/__init__.py ADDED
@@ -0,0 +1,42 @@
1
+ """
2
+ # dora-rs.
3
+
4
+ This is the dora python client for interacting with dora dataflow.
5
+ You can install it via:
6
+ ```bash
7
+ pip install dora-rs
8
+ ```.
9
+ """
10
+
11
+ from enum import Enum
12
+
13
+ from .dora import *
14
+ from .dora import (
15
+ Node,
16
+ Ros2Context,
17
+ Ros2Durability,
18
+ Ros2Liveliness,
19
+ Ros2Node,
20
+ Ros2NodeOptions,
21
+ Ros2Publisher,
22
+ Ros2QosPolicies,
23
+ Ros2Subscription,
24
+ Ros2Topic,
25
+ __author__,
26
+ __version__,
27
+ start_runtime,
28
+ )
29
+
30
+
31
+ class DoraStatus(Enum):
32
+ """Dora status to indicate if operator `on_input` loop should be stopped.
33
+
34
+ Args:
35
+ Enum (u8): Status signaling to dora operator to
36
+ stop or continue the operator.
37
+
38
+ """
39
+
40
+ CONTINUE = 0
41
+ STOP = 1
42
+ STOP_ALL = 2
dora/__init__.pyi ADDED
@@ -0,0 +1,461 @@
1
+ import typing
2
+
3
+ import pyarrow
4
+
5
+ import dora
6
+
7
+ @typing.final
8
+ class Enum:
9
+ """Create a collection of name/value pairs.
10
+
11
+ Example enumeration:
12
+
13
+ >>> class Color(Enum):
14
+ ... RED = 1
15
+ ... BLUE = 2
16
+ ... GREEN = 3
17
+
18
+ Access them by:
19
+
20
+ - attribute access:
21
+
22
+ >>> Color.RED
23
+ <Color.RED: 1>
24
+
25
+ - value lookup:
26
+
27
+ >>> Color(1)
28
+ <Color.RED: 1>
29
+
30
+ - name lookup:
31
+
32
+ >>> Color['RED']
33
+ <Color.RED: 1>
34
+
35
+ Enumerations can be iterated over, and know how many members they have:
36
+
37
+ >>> len(Color)
38
+ 3
39
+
40
+ >>> list(Color)
41
+ [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
42
+
43
+ Methods can be added to enumerations, and members can have their own
44
+ attributes -- see the documentation for details."""
45
+
46
+ @staticmethod
47
+ def __contains__(value: typing.Any) -> bool:
48
+ """Return True if `value` is in `cls`.
49
+
50
+ `value` is in `cls` if:
51
+ 1) `value` is a member of `cls`, or
52
+ 2) `value` is the value of one of the `cls`'s members."""
53
+
54
+ @staticmethod
55
+ def __getitem__(name: typing.Any) -> typing.Any:
56
+ """Return the member matching `name`."""
57
+
58
+ @staticmethod
59
+ def __iter__() -> typing.Any:
60
+ """Return members in definition order."""
61
+
62
+ @staticmethod
63
+ def __len__() -> int:
64
+ """Return the number of members (no aliases)"""
65
+
66
+ @typing.final
67
+ class Node:
68
+ """The custom node API lets you integrate `dora` into your application.
69
+ It allows you to retrieve input and send output in any fashion you want.
70
+
71
+ Use with:
72
+
73
+ ```python
74
+ from dora import Node
75
+
76
+ node = Node()
77
+ ```"""
78
+
79
+ def __init__(self, node_id: str = None) -> None:
80
+ """The custom node API lets you integrate `dora` into your application.
81
+ It allows you to retrieve input and send output in any fashion you want.
82
+
83
+ Use with:
84
+
85
+ ```python
86
+ from dora import Node
87
+
88
+ node = Node()
89
+ ```"""
90
+
91
+ def dataflow_descriptor(self) -> dict:
92
+ """Returns the full dataflow descriptor that this node is part of.
93
+
94
+ This method returns the parsed dataflow YAML file."""
95
+
96
+ def dataflow_id(self) -> str:
97
+ """Returns the dataflow id."""
98
+
99
+ def merge_external_events(self, subscription: dora.Ros2Subscription) -> None:
100
+ """Merge an external event stream with dora main loop.
101
+ This currently only work with ROS2."""
102
+
103
+ def next(self, timeout: float = None) -> dict:
104
+ """`.next()` gives you the next input that the node has received.
105
+ It blocks until the next event becomes available.
106
+ You can use timeout in seconds to return if no input is available.
107
+ It will return `None` when all senders has been dropped.
108
+
109
+ ```python
110
+ event = node.next()
111
+ ```
112
+
113
+ You can also iterate over the event stream with a loop
114
+
115
+ ```python
116
+ for event in node:
117
+ match event["type"]:
118
+ case "INPUT":
119
+ match event["id"]:
120
+ case "image":
121
+ ```"""
122
+
123
+ def node_config(self) -> dict:
124
+ """Returns the node configuration."""
125
+
126
+ def recv_async(self, timeout: float = None) -> dict:
127
+ """`.recv_async()` gives you the next input that the node has received asynchronously.
128
+ It does not blocks until the next event becomes available.
129
+ You can use timeout in seconds to return if no input is available.
130
+ It will return an Error if the timeout is reached.
131
+ It will return `None` when all senders has been dropped.
132
+
133
+ warning::
134
+ This feature is experimental as pyo3 async (rust-python FFI) is still in development.
135
+
136
+ ```python
137
+ event = await node.recv_async()
138
+ ```
139
+
140
+ You can also iterate over the event stream with a loop"""
141
+
142
+ def send_output(
143
+ self, output_id: str, data: pyarrow.Array, metadata: dict = None
144
+ ) -> None:
145
+ """`send_output` send data from the node.
146
+
147
+ ```python
148
+ Args:
149
+ output_id: str,
150
+ data: pyarrow.Array,
151
+ metadata: Option[Dict],
152
+ ```
153
+
154
+ ex:
155
+
156
+ ```python
157
+ node.send_output("string", b"string", {"open_telemetry_context": "7632e76"})
158
+ ```"""
159
+
160
+ def __iter__(self) -> typing.Any:
161
+ """Implement iter(self)."""
162
+
163
+ def __next__(self) -> typing.Any:
164
+ """Implement next(self)."""
165
+
166
+ def __repr__(self) -> str:
167
+ """Return repr(self)."""
168
+
169
+ def __str__(self) -> str:
170
+ """Return str(self)."""
171
+
172
+ @typing.final
173
+ class Ros2Context:
174
+ """ROS2 Context holding all messages definition for receiving and sending messages to ROS2.
175
+
176
+ By default, Ros2Context will use env `AMENT_PREFIX_PATH` to search for message definition.
177
+
178
+ AMENT_PREFIX_PATH folder structure should be the following:
179
+
180
+ - For messages: <namespace>/msg/<name>.msg
181
+ - For services: <namespace>/srv/<name>.srv
182
+
183
+ You can also use `ros_paths` if you don't want to use env variable.
184
+
185
+ warning::
186
+ dora Ros2 bridge functionality is considered **unstable**. It may be changed
187
+ at any point without it being considered a breaking change.
188
+
189
+ ```python
190
+ context = Ros2Context()
191
+ ```"""
192
+
193
+ def __init__(self, ros_paths: typing.List[str] = None) -> None:
194
+ """ROS2 Context holding all messages definition for receiving and sending messages to ROS2.
195
+
196
+ By default, Ros2Context will use env `AMENT_PREFIX_PATH` to search for message definition.
197
+
198
+ AMENT_PREFIX_PATH folder structure should be the following:
199
+
200
+ - For messages: <namespace>/msg/<name>.msg
201
+ - For services: <namespace>/srv/<name>.srv
202
+
203
+ You can also use `ros_paths` if you don't want to use env variable.
204
+
205
+ warning::
206
+ dora Ros2 bridge functionality is considered **unstable**. It may be changed
207
+ at any point without it being considered a breaking change.
208
+
209
+ ```python
210
+ context = Ros2Context()
211
+ ```"""
212
+
213
+ def new_node(
214
+ self, name: str, namespace: str, options: dora.Ros2NodeOptions
215
+ ) -> dora.Ros2Node:
216
+ """Create a new ROS2 node
217
+
218
+ ```python
219
+ ros2_node = ros2_context.new_node(
220
+ "turtle_teleop",
221
+ "/ros2_demo",
222
+ Ros2NodeOptions(rosout=True),
223
+ )
224
+ ```
225
+
226
+ warning::
227
+ dora Ros2 bridge functionality is considered **unstable**. It may be changed
228
+ at any point without it being considered a breaking change."""
229
+
230
+ def __repr__(self) -> str:
231
+ """Return repr(self)."""
232
+
233
+ def __str__(self) -> str:
234
+ """Return str(self)."""
235
+
236
+ @typing.final
237
+ class Ros2Durability:
238
+ """DDS 2.2.3.4 DURABILITY"""
239
+
240
+ def __eq__(self, value: typing.Any) -> bool:
241
+ """Return self==value."""
242
+
243
+ def __ge__(self, value: typing.Any) -> bool:
244
+ """Return self>=value."""
245
+
246
+ def __gt__(self, value: typing.Any) -> bool:
247
+ """Return self>value."""
248
+
249
+ def __int__(self) -> None:
250
+ """int(self)"""
251
+
252
+ def __le__(self, value: typing.Any) -> bool:
253
+ """Return self<=value."""
254
+
255
+ def __lt__(self, value: typing.Any) -> bool:
256
+ """Return self<value."""
257
+
258
+ def __ne__(self, value: typing.Any) -> bool:
259
+ """Return self!=value."""
260
+
261
+ def __repr__(self) -> str:
262
+ """Return repr(self)."""
263
+
264
+ def __str__(self) -> str:
265
+ """Return str(self)."""
266
+
267
+ @typing.final
268
+ class Ros2Liveliness:
269
+ """DDS 2.2.3.11 LIVELINESS"""
270
+
271
+ def __eq__(self, value: typing.Any) -> bool:
272
+ """Return self==value."""
273
+
274
+ def __ge__(self, value: typing.Any) -> bool:
275
+ """Return self>=value."""
276
+
277
+ def __gt__(self, value: typing.Any) -> bool:
278
+ """Return self>value."""
279
+
280
+ def __int__(self) -> None:
281
+ """int(self)"""
282
+
283
+ def __le__(self, value: typing.Any) -> bool:
284
+ """Return self<=value."""
285
+
286
+ def __lt__(self, value: typing.Any) -> bool:
287
+ """Return self<value."""
288
+
289
+ def __ne__(self, value: typing.Any) -> bool:
290
+ """Return self!=value."""
291
+
292
+ def __repr__(self) -> str:
293
+ """Return repr(self)."""
294
+
295
+ def __str__(self) -> str:
296
+ """Return str(self)."""
297
+
298
+ @typing.final
299
+ class Ros2Node:
300
+ """ROS2 Node
301
+
302
+ warnings::
303
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
304
+ at any point without it being considered a breaking change.
305
+ - There's a known issue about ROS2 nodes not being discoverable by ROS2
306
+ See: https://github.com/jhelovuo/ros2-client/issues/4"""
307
+
308
+ def create_publisher(
309
+ self, topic: dora.Ros2Topic, qos: dora.Ros2QosPolicies = None
310
+ ) -> dora.Ros2Publisher:
311
+ """Create a ROS2 publisher
312
+
313
+ ```python
314
+ pose_publisher = ros2_node.create_publisher(turtle_pose_topic)
315
+ ```
316
+ warnings:
317
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
318
+ at any point without it being considered a breaking change."""
319
+
320
+ def create_subscription(
321
+ self, topic: dora.Ros2Topic, qos: dora.Ros2QosPolicies = None
322
+ ) -> dora.Ros2Subscription:
323
+ """Create a ROS2 subscription
324
+
325
+ ```python
326
+ pose_reader = ros2_node.create_subscription(turtle_pose_topic)
327
+ ```
328
+
329
+ warnings:
330
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
331
+ at any point without it being considered a breaking change."""
332
+
333
+ def create_topic(
334
+ self, name: str, message_type: str, qos: dora.Ros2QosPolicies
335
+ ) -> dora.Ros2Topic:
336
+ """Create a ROS2 topic to connect to.
337
+
338
+ ```python
339
+ turtle_twist_topic = ros2_node.create_topic(
340
+ "/turtle1/cmd_vel", "geometry_msgs/Twist", topic_qos
341
+ )
342
+ ```"""
343
+
344
+ def __repr__(self) -> str:
345
+ """Return repr(self)."""
346
+
347
+ def __str__(self) -> str:
348
+ """Return str(self)."""
349
+
350
+ @typing.final
351
+ class Ros2NodeOptions:
352
+ """ROS2 Node Options"""
353
+
354
+ def __init__(self, rosout: bool = None) -> None:
355
+ """ROS2 Node Options"""
356
+
357
+ def __repr__(self) -> str:
358
+ """Return repr(self)."""
359
+
360
+ def __str__(self) -> str:
361
+ """Return str(self)."""
362
+
363
+ @typing.final
364
+ class Ros2Publisher:
365
+ """ROS2 Publisher
366
+
367
+ warnings:
368
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
369
+ at any point without it being considered a breaking change."""
370
+
371
+ def publish(self, data: pyarrow.Array) -> None:
372
+ """Publish a message into ROS2 topic.
373
+
374
+ Remember that the data format should respect the structure of the ROS2 message using an arrow Structure.
375
+
376
+ ex:
377
+ ```python
378
+ gripper_command.publish(
379
+ pa.array(
380
+ [
381
+ {
382
+ "name": "gripper",
383
+ "cmd": np.float32(5),
384
+ }
385
+ ]
386
+ ),
387
+ )
388
+ ```"""
389
+
390
+ def __repr__(self) -> str:
391
+ """Return repr(self)."""
392
+
393
+ def __str__(self) -> str:
394
+ """Return str(self)."""
395
+
396
+ @typing.final
397
+ class Ros2QosPolicies:
398
+ """ROS2 QoS Policy"""
399
+
400
+ def __init__(
401
+ self,
402
+ durability: dora.Ros2Durability = None,
403
+ liveliness: dora.Ros2Liveliness = None,
404
+ reliable: bool = None,
405
+ keep_all: bool = None,
406
+ lease_duration: float = None,
407
+ max_blocking_time: float = None,
408
+ keep_last: int = None,
409
+ ) -> dora.Ros2QosPolicies:
410
+ """ROS2 QoS Policy"""
411
+
412
+ def __repr__(self) -> str:
413
+ """Return repr(self)."""
414
+
415
+ def __str__(self) -> str:
416
+ """Return str(self)."""
417
+
418
+ @typing.final
419
+ class Ros2Subscription:
420
+ """ROS2 Subscription
421
+
422
+
423
+ warnings:
424
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
425
+ at any point without it being considered a breaking change."""
426
+
427
+ def next(self): ...
428
+ def __repr__(self) -> str:
429
+ """Return repr(self)."""
430
+
431
+ def __str__(self) -> str:
432
+ """Return str(self)."""
433
+
434
+ @typing.final
435
+ class Ros2Topic:
436
+ """ROS2 Topic
437
+
438
+ warnings:
439
+ - dora Ros2 bridge functionality is considered **unstable**. It may be changed
440
+ at any point without it being considered a breaking change."""
441
+
442
+ def __repr__(self) -> str:
443
+ """Return repr(self)."""
444
+
445
+ def __str__(self) -> str:
446
+ """Return str(self)."""
447
+
448
+ def build(
449
+ dataflow_path: str,
450
+ uv: bool = None,
451
+ coordinator_addr: str = None,
452
+ coordinator_port: int = None,
453
+ force_local: bool = False,
454
+ ) -> None:
455
+ """Build a Dataflow, exactly the same way as `dora build` command line tool."""
456
+
457
+ def run(dataflow_path: str, uv: bool = None) -> None:
458
+ """Run a Dataflow, exactly the same way as `dora run` command line tool."""
459
+
460
+ def start_runtime() -> None:
461
+ """Start a runtime for Operators"""
dora/builder.py ADDED
@@ -0,0 +1,166 @@
1
+ from __future__ import annotations
2
+
3
+ import yaml
4
+
5
+
6
+ class DataflowBuilder:
7
+ """A dora dataflow."""
8
+
9
+ def __init__(self, name: str = "dora-dataflow"):
10
+ self.name = name
11
+ self.nodes = []
12
+
13
+ def add_node(self, id: str, **kwargs) -> Node:
14
+ """Adds a new node to the dataflow."""
15
+ node = Node(id, **kwargs)
16
+ self.nodes.append(node)
17
+ return node
18
+
19
+ def to_yaml(self, path: str = None) -> str | None:
20
+ """Generates the YAML representation of the dataflow."""
21
+ dataflow_spec = {"nodes": [node.to_dict() for node in self.nodes]}
22
+ if path:
23
+ with open(path, "w") as f:
24
+ yaml.dump(dataflow_spec, f)
25
+ return None
26
+ else:
27
+ return yaml.dump(dataflow_spec)
28
+
29
+ def __enter__(self):
30
+ return self
31
+
32
+ def __exit__(self, exc_type, exc_val, exc_tb):
33
+ pass
34
+
35
+
36
+ class Output:
37
+ """Represents an output from a node."""
38
+
39
+ def __init__(self, node: Node, output_id: str):
40
+ self.node = node
41
+ self.output_id = output_id
42
+
43
+ def __str__(self) -> str:
44
+ return f"{self.node.id}/{self.output_id}"
45
+
46
+
47
+ class Node:
48
+ """A node in a dora dataflow."""
49
+
50
+ def __init__(self, id: str, **kwargs):
51
+ self.id = id
52
+ self.config = kwargs
53
+ self.config["id"] = id
54
+ self.operators = []
55
+
56
+ def path(self, path: str) -> Node:
57
+ """Sets the path to the executable or script."""
58
+ self.config["path"] = path
59
+ return self
60
+
61
+ def args(self, args: str) -> Node:
62
+ """Sets the command-line arguments for the node."""
63
+ self.config["args"] = args
64
+ return self
65
+
66
+ def env(self, env: dict) -> Node:
67
+ """Sets the environment variables for the node."""
68
+ self.config["env"] = env
69
+ return self
70
+
71
+ def build(self, build_command: str) -> Node:
72
+ """Sets the build command for the node."""
73
+ self.config["build"] = build_command
74
+ return self
75
+
76
+ def git(
77
+ self, url: str, branch: str = None, tag: str = None, rev: str = None
78
+ ) -> Node:
79
+ """Sets the Git repository for the node."""
80
+ self.config["git"] = url
81
+ if branch:
82
+ self.config["branch"] = branch
83
+ if tag:
84
+ self.config["tag"] = tag
85
+ if rev:
86
+ self.config["rev"] = rev
87
+ return self
88
+
89
+ def add_operator(self, operator: Operator) -> Node:
90
+ """Adds an operator to this node."""
91
+ self.operators.append(operator)
92
+ return self
93
+
94
+ def add_output(self, output_id: str) -> Output:
95
+ """Adds an output to the node and returns an Output object."""
96
+ if "outputs" not in self.config:
97
+ self.config["outputs"] = []
98
+ if output_id not in self.config["outputs"]:
99
+ self.config["outputs"].append(output_id)
100
+ return Output(self, output_id)
101
+
102
+ def add_input(
103
+ self, input_id: str, source: str | Output, queue_size: int = None
104
+ ) -> Node:
105
+ """Adds a user-defined input to the node. Source can be a string or an Output object."""
106
+ if "inputs" not in self.config:
107
+ self.config["inputs"] = {}
108
+
109
+ if isinstance(source, Output):
110
+ source_str = str(source)
111
+ if queue_size is not None:
112
+ self.config["inputs"][input_id] = {
113
+ "source": source_str,
114
+ "queue_size": queue_size,
115
+ }
116
+ else:
117
+ self.config["inputs"][input_id] = source_str
118
+ else:
119
+ if queue_size is not None:
120
+ self.config["inputs"][input_id] = {
121
+ "source": source,
122
+ "queue_size": queue_size,
123
+ }
124
+ else:
125
+ self.config["inputs"][input_id] = source
126
+ return self
127
+
128
+ def to_dict(self) -> dict:
129
+ """Returns the dictionary representation of the node."""
130
+ config = self.config.copy()
131
+ if self.operators:
132
+ config["operators"] = [op.to_dict() for op in self.operators]
133
+ return config
134
+
135
+
136
+ class Operator:
137
+ """An operator in a dora dataflow."""
138
+
139
+ def __init__(
140
+ self,
141
+ id: str,
142
+ name: str = None,
143
+ description: str = None,
144
+ build: str = None,
145
+ python: str = None,
146
+ shared_library: str = None,
147
+ send_stdout_as: str = None,
148
+ ):
149
+ self.id = id
150
+ self.config = {"id": id}
151
+ if name:
152
+ self.config["name"] = name
153
+ if description:
154
+ self.config["description"] = description
155
+ if build:
156
+ self.config["build"] = build
157
+ if python:
158
+ self.config["python"] = python
159
+ if shared_library:
160
+ self.config["shared-library"] = shared_library
161
+ if send_stdout_as:
162
+ self.config["send_stdout_as"] = send_stdout_as
163
+
164
+ def to_dict(self) -> dict:
165
+ """Returns the dictionary representation of the operator."""
166
+ return self.config
dora/cuda.py ADDED
@@ -0,0 +1,94 @@
1
+ """TODO: Add docstring."""
2
+
3
+ import pyarrow as pa
4
+
5
+ # Make sure to install torch with cuda
6
+ import torch
7
+ from numba.cuda import to_device
8
+
9
+ # Make sure to install numba with cuda
10
+ from numba.cuda.cudadrv.devicearray import DeviceNDArray
11
+ from numba.cuda.cudadrv.devices import get_context
12
+ from numba.cuda.cudadrv.driver import IpcHandle
13
+
14
+
15
+ import json
16
+
17
+ from contextlib import contextmanager
18
+ from typing import ContextManager
19
+
20
+
21
+ def torch_to_ipc_buffer(tensor: torch.TensorType) -> tuple[pa.array, dict]:
22
+ """Convert a Pytorch tensor into a pyarrow buffer containing the IPC handle
23
+ and its metadata.
24
+
25
+ Example Use:
26
+ ```python
27
+ torch_tensor = torch.tensor(random_data, dtype=torch.int64, device="cuda")
28
+ ipc_buffer, metadata = torch_to_ipc_buffer(torch_tensor)
29
+ node.send_output("latency", ipc_buffer, metadata)
30
+ ```
31
+ """
32
+ device_arr = to_device(tensor)
33
+ ipch = get_context().get_ipc_handle(device_arr.gpu_data)
34
+ _, handle, size, source_info, offset = ipch.__reduce__()[1]
35
+ metadata = {
36
+ "shape": device_arr.shape,
37
+ "strides": device_arr.strides,
38
+ "dtype": device_arr.dtype.str,
39
+ "size": size,
40
+ "offset": offset,
41
+ "source_info": json.dumps(source_info),
42
+ }
43
+ return pa.array(handle, pa.int8()), metadata
44
+
45
+
46
+ def ipc_buffer_to_ipc_handle(handle_buffer: pa.array, metadata: dict) -> IpcHandle:
47
+ """Convert a buffer containing a serialized handler into cuda IPC Handle.
48
+
49
+ example use:
50
+ ```python
51
+ from dora.cuda import ipc_buffer_to_ipc_handle, open_ipc_handle
52
+
53
+ event = node.next()
54
+
55
+ ipc_handle = ipc_buffer_to_ipc_handle(event["value"], event["metadata"])
56
+ with open_ipc_handle(ipc_handle, event["metadata"]) as tensor:
57
+ pass
58
+ ```
59
+ """
60
+ handle = handle_buffer.to_pylist()
61
+ return IpcHandle._rebuild(
62
+ handle,
63
+ metadata["size"],
64
+ json.loads(metadata["source_info"]),
65
+ metadata["offset"],
66
+ )
67
+
68
+
69
+ @contextmanager
70
+ def open_ipc_handle(
71
+ ipc_handle: IpcHandle, metadata: dict
72
+ ) -> ContextManager[torch.TensorType]:
73
+ """Open a CUDA IPC handle and return a Pytorch tensor.
74
+
75
+ example use:
76
+ ```python
77
+ from dora.cuda import ipc_buffer_to_ipc_handle, open_ipc_handle
78
+
79
+ event = node.next()
80
+
81
+ ipc_handle = ipc_buffer_to_ipc_handle(event["value"], event["metadata"])
82
+ with open_ipc_handle(ipc_handle, event["metadata"]) as tensor:
83
+ pass
84
+ ```
85
+ """
86
+ shape = metadata["shape"]
87
+ strides = metadata["strides"]
88
+ dtype = metadata["dtype"]
89
+ try:
90
+ buffer = ipc_handle.open(get_context())
91
+ device_arr = DeviceNDArray(shape, strides, dtype, gpu_data=buffer)
92
+ yield torch.as_tensor(device_arr, device="cuda")
93
+ finally:
94
+ ipc_handle.close()
dora/dora.abi3.so ADDED
Binary file
dora/py.typed ADDED
File without changes
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: dora-rs
3
+ Version: 0.3.14rc0
4
+ Requires-Dist: pyarrow
5
+ Requires-Dist: pyyaml>=6.0
6
+ License: MIT
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
9
+
10
+ This crate corresponds to the Node API for Dora.
11
+
12
+ ## Building
13
+
14
+ To build the Python module for development:
15
+
16
+ ```bash
17
+ uv venv --seed -p 3.11
18
+ uv pip install -e .
19
+ ```
20
+
21
+ ## Type hinting
22
+
23
+ Type hinting requires to run a second step
24
+
25
+ ```bash
26
+ python generate_stubs.py dora dora/__init__.pyi
27
+ maturin develop
28
+ ```
29
+
@@ -0,0 +1,9 @@
1
+ dora/__init__.py,sha256=mogA09uYFBIwnBnnMfeQtD52ZJbVbWmWo1h70GZj2aU,709
2
+ dora/__init__.pyi,sha256=mWpvxM1zQ5Ewvwmy-PRRGxyPvXHtpWKlo5U958Sxrkw,12469
3
+ dora/builder.py,sha256=WqYuhtm8tCOlxEbGvsRiTfW0Ji84P1MmA4FIRfpbWQo,4956
4
+ dora/cuda.py,sha256=tsp76SLAeR1gOXoQTTMv4oVHFoSzkXeevEQG41U9xFU,2736
5
+ dora/dora.abi3.so,sha256=NtA4MxKVty2Df_qnCuAyhmW5uHF32PgAGbjizVuSsEM,44810632
6
+ dora/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ dora_rs-0.3.14rc0.dist-info/METADATA,sha256=sOEcV2em-UqTryZBeGJkSsq_TZtBOTcoYgF89irD7os,512
8
+ dora_rs-0.3.14rc0.dist-info/WHEEL,sha256=4Z4Wh-oqVxwrJfLhZsSx6Sb2NPMEZBoDWAurZQhih_g,107
9
+ dora_rs-0.3.14rc0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp37-abi3-manylinux_2_28_x86_64