parallelazy 0.0.2__tar.gz → 0.0.5__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.
- {parallelazy-0.0.2 → parallelazy-0.0.5}/PKG-INFO +9 -3
- {parallelazy-0.0.2 → parallelazy-0.0.5}/README.md +7 -2
- parallelazy-0.0.5/parallelazy/__init__.py +122 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin_data.py +0 -1
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin_manager.py +5 -1
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin_rpc.py +10 -3
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin_worker.py +5 -2
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy.egg-info/PKG-INFO +9 -3
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy.egg-info/requires.txt +1 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/pyproject.toml +3 -2
- parallelazy-0.0.2/parallelazy/__init__.py +0 -43
- {parallelazy-0.0.2 → parallelazy-0.0.5}/LICENSE +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/environment_manager.py +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin.py +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/plugin_transport.py +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy/utils.py +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy.egg-info/SOURCES.txt +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy.egg-info/dependency_links.txt +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/parallelazy.egg-info/top_level.txt +0 -0
- {parallelazy-0.0.2 → parallelazy-0.0.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: parallelazy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A lightweight multiprocess worker-plugin framework. Topic-based pub/sub, global enviroment, using process spawn and pipes, pytorch and CUDA ready.
|
|
5
5
|
Author: Cesare Montresor
|
|
6
6
|
Project-URL: Homepage, https://github.com/cesare-montresor/parallelazy
|
|
@@ -11,6 +11,7 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: debugpy
|
|
13
13
|
Requires-Dist: torch
|
|
14
|
+
Requires-Dist: numpy
|
|
14
15
|
Dynamic: license-file
|
|
15
16
|
|
|
16
17
|
# parallelazy
|
|
@@ -29,13 +30,18 @@ A lightweight Python plugin/worker framework with:
|
|
|
29
30
|
python -m pip install .
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
## Debug in VSCode
|
|
34
|
+
|
|
35
|
+
Due to a known issue with debugpy and spawn ( as opposite to fork ) processes, a small companion vscode extension has been developed in order to enable debugging.
|
|
36
|
+
|
|
37
|
+
https://marketplace.visualstudio.com/items?itemName=CesareMontresor.parallelazy-vscode
|
|
38
|
+
|
|
32
39
|
## Quick start
|
|
33
40
|
|
|
34
41
|
```python
|
|
35
42
|
import time
|
|
36
43
|
|
|
37
|
-
from parallelazy
|
|
38
|
-
from parallelazy.plugin_manager import PluginManager
|
|
44
|
+
from parallelazy import Plugin, PluginManager
|
|
39
45
|
|
|
40
46
|
|
|
41
47
|
class Worker(Plugin):
|
|
@@ -14,13 +14,18 @@ A lightweight Python plugin/worker framework with:
|
|
|
14
14
|
python -m pip install .
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Debug in VSCode
|
|
18
|
+
|
|
19
|
+
Due to a known issue with debugpy and spawn ( as opposite to fork ) processes, a small companion vscode extension has been developed in order to enable debugging.
|
|
20
|
+
|
|
21
|
+
https://marketplace.visualstudio.com/items?itemName=CesareMontresor.parallelazy-vscode
|
|
22
|
+
|
|
17
23
|
## Quick start
|
|
18
24
|
|
|
19
25
|
```python
|
|
20
26
|
import time
|
|
21
27
|
|
|
22
|
-
from parallelazy
|
|
23
|
-
from parallelazy.plugin_manager import PluginManager
|
|
28
|
+
from parallelazy import Plugin, PluginManager
|
|
24
29
|
|
|
25
30
|
|
|
26
31
|
class Worker(Plugin):
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ModularNet Plugin System: Lightweight multiprocessing-based plugin architecture.
|
|
3
|
+
|
|
4
|
+
Provides modular plugin execution with pub/sub messaging, environment variables,
|
|
5
|
+
and service invocation.
|
|
6
|
+
|
|
7
|
+
Main Components:
|
|
8
|
+
- PluginDescriptor: Serializable plugin metadata
|
|
9
|
+
- Plugin: Abstract base class for plugins
|
|
10
|
+
- PluginManager: Plugin orchestration and management
|
|
11
|
+
- PluginWorker: Plugin subprocess worker
|
|
12
|
+
- PluginMessages: Unified IPC message protocol (Request, Response)
|
|
13
|
+
- DataExchange: Unified subscription model (topics + env vars)
|
|
14
|
+
- ManagerProxy: Client-side proxy for direct manager access from plugins
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from parallelazy.environment_manager import EnvironmentManager
|
|
18
|
+
from parallelazy.plugin import Plugin, PluginDescriptor, PluginState
|
|
19
|
+
from parallelazy.plugin_data import (
|
|
20
|
+
Channel,
|
|
21
|
+
CommandType,
|
|
22
|
+
Message,
|
|
23
|
+
PendingRequest,
|
|
24
|
+
PluginStatus,
|
|
25
|
+
ProcessStatus,
|
|
26
|
+
Queue,
|
|
27
|
+
QueueDescriptor,
|
|
28
|
+
QueueRecive,
|
|
29
|
+
QueueSend,
|
|
30
|
+
Request,
|
|
31
|
+
RequestCallback,
|
|
32
|
+
RequestEnvGet,
|
|
33
|
+
RequestEnvGetAll,
|
|
34
|
+
RequestEnvSet,
|
|
35
|
+
RequestEnvSubscribe,
|
|
36
|
+
RequestEnvUnsubscribe,
|
|
37
|
+
RequestEnvUpdate,
|
|
38
|
+
RequestPluginCall,
|
|
39
|
+
RequestPluginErrors,
|
|
40
|
+
RequestPluginStart,
|
|
41
|
+
RequestPluginStatus,
|
|
42
|
+
RequestPluginStatusAll,
|
|
43
|
+
RequestPluginStop,
|
|
44
|
+
RequestTopicAnnounce,
|
|
45
|
+
RequestTopicList,
|
|
46
|
+
RequestTopicSubscribe,
|
|
47
|
+
RequestTopicUnsubscribe,
|
|
48
|
+
Response,
|
|
49
|
+
ResponseCallback,
|
|
50
|
+
Subscriber,
|
|
51
|
+
Subscription,
|
|
52
|
+
)
|
|
53
|
+
from parallelazy.plugin_manager import PluginInfo, PluginManager
|
|
54
|
+
from parallelazy.plugin_rpc import (
|
|
55
|
+
MessageUID,
|
|
56
|
+
PluginCoreRPC,
|
|
57
|
+
PluginEnvRPC,
|
|
58
|
+
PluginLifeCycleRPC,
|
|
59
|
+
PluginRPC,
|
|
60
|
+
PluginTopicRPC,
|
|
61
|
+
)
|
|
62
|
+
from parallelazy.plugin_transport import (
|
|
63
|
+
IpcEventCuda,
|
|
64
|
+
IpcEventPool,
|
|
65
|
+
IpcEventPoolManaged,
|
|
66
|
+
mark_graph_output,
|
|
67
|
+
sanitize_for_ipc,
|
|
68
|
+
)
|
|
69
|
+
from parallelazy.plugin_worker import PluginWorker
|
|
70
|
+
|
|
71
|
+
__all__ = [
|
|
72
|
+
"EnvironmentManager",
|
|
73
|
+
"Plugin",
|
|
74
|
+
"PluginDescriptor",
|
|
75
|
+
"PluginState",
|
|
76
|
+
"Channel",
|
|
77
|
+
"CommandType",
|
|
78
|
+
"Message",
|
|
79
|
+
"PendingRequest",
|
|
80
|
+
"PluginStatus",
|
|
81
|
+
"ProcessStatus",
|
|
82
|
+
"Queue",
|
|
83
|
+
"QueueDescriptor",
|
|
84
|
+
"QueueRecive",
|
|
85
|
+
"QueueSend",
|
|
86
|
+
"Request",
|
|
87
|
+
"RequestCallback",
|
|
88
|
+
"RequestEnvGet",
|
|
89
|
+
"RequestEnvGetAll",
|
|
90
|
+
"RequestEnvSet",
|
|
91
|
+
"RequestEnvSubscribe",
|
|
92
|
+
"RequestEnvUnsubscribe",
|
|
93
|
+
"RequestEnvUpdate",
|
|
94
|
+
"RequestPluginCall",
|
|
95
|
+
"RequestPluginErrors",
|
|
96
|
+
"RequestPluginStart",
|
|
97
|
+
"RequestPluginStatus",
|
|
98
|
+
"RequestPluginStatusAll",
|
|
99
|
+
"RequestPluginStop",
|
|
100
|
+
"RequestTopicAnnounce",
|
|
101
|
+
"RequestTopicList",
|
|
102
|
+
"RequestTopicSubscribe",
|
|
103
|
+
"RequestTopicUnsubscribe",
|
|
104
|
+
"Response",
|
|
105
|
+
"ResponseCallback",
|
|
106
|
+
"Subscriber",
|
|
107
|
+
"Subscription",
|
|
108
|
+
"PluginInfo",
|
|
109
|
+
"PluginManager",
|
|
110
|
+
"MessageUID",
|
|
111
|
+
"PluginCoreRPC",
|
|
112
|
+
"PluginEnvRPC",
|
|
113
|
+
"PluginLifeCycleRPC",
|
|
114
|
+
"PluginRPC",
|
|
115
|
+
"PluginTopicRPC",
|
|
116
|
+
"PluginWorker",
|
|
117
|
+
"IpcEventCuda",
|
|
118
|
+
"IpcEventPool",
|
|
119
|
+
"IpcEventPoolManaged",
|
|
120
|
+
"mark_graph_output",
|
|
121
|
+
"sanitize_for_ipc",
|
|
122
|
+
]
|
|
@@ -17,7 +17,6 @@ Message Flows:
|
|
|
17
17
|
No Commands/Responses wrappers, no double indirection. Just Request and Response.
|
|
18
18
|
"""
|
|
19
19
|
from typing import Any, Callable, Optional, TYPE_CHECKING
|
|
20
|
-
from enum import Enum
|
|
21
20
|
import logging
|
|
22
21
|
from concurrent.futures import Future
|
|
23
22
|
from torch import multiprocessing as mp
|
|
@@ -150,7 +150,11 @@ class PluginManager:
|
|
|
150
150
|
)
|
|
151
151
|
|
|
152
152
|
process.start()
|
|
153
|
-
initialized.wait(timeout=self.timeout_start)
|
|
153
|
+
is_ready = initialized.wait(timeout=self.timeout_start)
|
|
154
|
+
if not is_ready:
|
|
155
|
+
logger.error(f"Plugin {plugin_id} failed to initialize within {self.timeout_start} seconds")
|
|
156
|
+
process.terminate()
|
|
157
|
+
return False
|
|
154
158
|
|
|
155
159
|
logger.info(f"Plugin {plugin_id} loaded")
|
|
156
160
|
return True
|
|
@@ -52,7 +52,7 @@ class PluginCoreRPC:
|
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def __init__(self, plugin_id: str, channel: Channel=None, timeout: float = 5.0):
|
|
55
|
+
def __init__(self, plugin_id: str, channel: Channel=None, timeout: float = 5.0, start_listener: bool = True):
|
|
56
56
|
"""
|
|
57
57
|
Initialize manager proxy.
|
|
58
58
|
|
|
@@ -77,7 +77,7 @@ class PluginCoreRPC:
|
|
|
77
77
|
|
|
78
78
|
# Reader thread routes Responses to reply slots
|
|
79
79
|
self._reader = threading.Thread(target=self._channel_listener, daemon=False)
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
|
|
82
82
|
# Persistent pool for executing incoming requests — avoids spawning
|
|
83
83
|
# a fresh OS thread per RPC call (was the source of the stutter).
|
|
@@ -85,6 +85,13 @@ class PluginCoreRPC:
|
|
|
85
85
|
max_workers=8, thread_name_prefix=f"rpc-{plugin_id}"
|
|
86
86
|
)
|
|
87
87
|
|
|
88
|
+
if start_listener:
|
|
89
|
+
self.start_listener()
|
|
90
|
+
|
|
91
|
+
def start_listener(self):
|
|
92
|
+
if not self._reader.is_alive():
|
|
93
|
+
self._reader.start()
|
|
94
|
+
|
|
88
95
|
def shutdown(self):
|
|
89
96
|
"""Clean up resources."""
|
|
90
97
|
# Step 1: Signal reader to stop
|
|
@@ -220,7 +227,7 @@ class PluginCoreRPC:
|
|
|
220
227
|
|
|
221
228
|
self._executor.submit(self._execute_command, req)
|
|
222
229
|
except Exception as e:
|
|
223
|
-
logger.error(f"Request handler error: {e}", exc_info=True)
|
|
230
|
+
logger.error(f"Request handler error: {req} {e}", exc_info=True)
|
|
224
231
|
self.respond(req, error=e)
|
|
225
232
|
|
|
226
233
|
def _handle_response(self, resp: Response) -> bool:
|
|
@@ -128,11 +128,14 @@ class PluginWorker:
|
|
|
128
128
|
|
|
129
129
|
# Create manager proxy for direct manager access+
|
|
130
130
|
channel = Channel(queue_descriptor)
|
|
131
|
-
self.rpc = PluginRPC(self.plugin_id, channel)
|
|
131
|
+
self.rpc = PluginRPC(self.plugin_id, channel, start_listener=False)
|
|
132
132
|
|
|
133
|
-
self._init_plugin()
|
|
134
133
|
self._init_rpc()
|
|
135
134
|
|
|
135
|
+
self._init_plugin()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
self.rpc.start_listener() # Start the RPC listener after initialization
|
|
136
139
|
|
|
137
140
|
|
|
138
141
|
## ========================================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: parallelazy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A lightweight multiprocess worker-plugin framework. Topic-based pub/sub, global enviroment, using process spawn and pipes, pytorch and CUDA ready.
|
|
5
5
|
Author: Cesare Montresor
|
|
6
6
|
Project-URL: Homepage, https://github.com/cesare-montresor/parallelazy
|
|
@@ -11,6 +11,7 @@ Description-Content-Type: text/markdown
|
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: debugpy
|
|
13
13
|
Requires-Dist: torch
|
|
14
|
+
Requires-Dist: numpy
|
|
14
15
|
Dynamic: license-file
|
|
15
16
|
|
|
16
17
|
# parallelazy
|
|
@@ -29,13 +30,18 @@ A lightweight Python plugin/worker framework with:
|
|
|
29
30
|
python -m pip install .
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
## Debug in VSCode
|
|
34
|
+
|
|
35
|
+
Due to a known issue with debugpy and spawn ( as opposite to fork ) processes, a small companion vscode extension has been developed in order to enable debugging.
|
|
36
|
+
|
|
37
|
+
https://marketplace.visualstudio.com/items?itemName=CesareMontresor.parallelazy-vscode
|
|
38
|
+
|
|
32
39
|
## Quick start
|
|
33
40
|
|
|
34
41
|
```python
|
|
35
42
|
import time
|
|
36
43
|
|
|
37
|
-
from parallelazy
|
|
38
|
-
from parallelazy.plugin_manager import PluginManager
|
|
44
|
+
from parallelazy import Plugin, PluginManager
|
|
39
45
|
|
|
40
46
|
|
|
41
47
|
class Worker(Plugin):
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "parallelazy"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.5"
|
|
8
8
|
description = "A lightweight multiprocess worker-plugin framework. Topic-based pub/sub, global enviroment, using process spawn and pipes, pytorch and CUDA ready."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -14,7 +14,8 @@ authors = [
|
|
|
14
14
|
|
|
15
15
|
dependencies = [
|
|
16
16
|
"debugpy",
|
|
17
|
-
"torch"
|
|
17
|
+
"torch",
|
|
18
|
+
"numpy"
|
|
18
19
|
]
|
|
19
20
|
|
|
20
21
|
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
ModularNet Plugin System: Lightweight multiprocessing-based plugin architecture.
|
|
3
|
-
|
|
4
|
-
Provides modular plugin execution with pub/sub messaging, environment variables,
|
|
5
|
-
and service invocation.
|
|
6
|
-
|
|
7
|
-
Main Components:
|
|
8
|
-
- PluginDescriptor: Serializable plugin metadata
|
|
9
|
-
- Plugin: Abstract base class for plugins
|
|
10
|
-
- PluginManager: Plugin orchestration and management
|
|
11
|
-
- PluginWorker: Plugin subprocess worker
|
|
12
|
-
- PluginMessages: Unified IPC message protocol (Request, Response)
|
|
13
|
-
- DataExchange: Unified subscription model (topics + env vars)
|
|
14
|
-
- ManagerProxy: Client-side proxy for direct manager access from plugins
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
from parallelazy.plugin import Plugin, PluginState, PluginDescriptor
|
|
18
|
-
from parallelazy.environment_manager import EnvironmentManager
|
|
19
|
-
from parallelazy.plugin_manager import PluginManager
|
|
20
|
-
|
|
21
|
-
from parallelazy.plugin_data import (
|
|
22
|
-
Request, Response,
|
|
23
|
-
Subscription,
|
|
24
|
-
PluginStatus, ProcessStatus
|
|
25
|
-
)
|
|
26
|
-
from parallelazy.plugin_rpc import PluginRPC
|
|
27
|
-
|
|
28
|
-
__all__ = [
|
|
29
|
-
"PluginDescriptor",
|
|
30
|
-
"Plugin",
|
|
31
|
-
"PluginState",
|
|
32
|
-
"EnvironmentManager",
|
|
33
|
-
"EnvUpdate",
|
|
34
|
-
"PluginManager",
|
|
35
|
-
"Request",
|
|
36
|
-
"Response",
|
|
37
|
-
"Channel",
|
|
38
|
-
"Subscription",
|
|
39
|
-
"SubscriptionType",
|
|
40
|
-
"PluginStatus",
|
|
41
|
-
"ProcessStatus",
|
|
42
|
-
"PluginRPC",
|
|
43
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|