process-bigraph 1.4.0__tar.gz → 1.4.2__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.
- {process_bigraph-1.4.0/process_bigraph.egg-info → process_bigraph-1.4.2}/PKG-INFO +1 -1
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/protocols/ray.py +36 -7
- {process_bigraph-1.4.0 → process_bigraph-1.4.2/process_bigraph.egg-info}/PKG-INFO +1 -1
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/pyproject.toml +1 -1
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/AUTHORS.md +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/LICENSE +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/README.md +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/bundle.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/composite.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/emitter.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/experiments/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/experiments/minimal_gillespie.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/nextflow.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/plumbing.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/dynamic_structure.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/examples.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/growth_division.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/math_expression.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/parameter_scan.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/reaction.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/protocols/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/protocols/parallel.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/protocols/rest.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/protocols/socket.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/run.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/run_step.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/server/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/server/rest.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/server/start.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/types/__init__.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/types/process.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/units.py +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph.egg-info/SOURCES.txt +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph.egg-info/dependency_links.txt +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph.egg-info/requires.txt +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph.egg-info/top_level.txt +0 -0
- {process_bigraph-1.4.0 → process_bigraph-1.4.2}/setup.cfg +0 -0
|
@@ -70,13 +70,25 @@ import json
|
|
|
70
70
|
import hashlib
|
|
71
71
|
from typing import Any, Dict, List, Type, Optional
|
|
72
72
|
|
|
73
|
+
# Ray is optional. We let the module import even when ray isn't installed
|
|
74
|
+
# (so package scanners like discover_packages don't trip), and only raise
|
|
75
|
+
# a helpful error when something tries to actually use it.
|
|
73
76
|
try:
|
|
74
77
|
import ray
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
_RAY_IMPORT_ERROR: Optional[ImportError] = None
|
|
79
|
+
except ImportError as _e: # pragma: no cover
|
|
80
|
+
ray = None # type: ignore[assignment]
|
|
81
|
+
_RAY_IMPORT_ERROR = _e
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _require_ray() -> None:
|
|
85
|
+
"""Guard for code paths that need ray. Raises a clear install hint."""
|
|
86
|
+
if ray is None:
|
|
87
|
+
raise ImportError(
|
|
88
|
+
"process_bigraph.protocols.ray requires the optional `ray` "
|
|
89
|
+
"dependency. Install with: pip install process-bigraph[ray]"
|
|
90
|
+
) from _RAY_IMPORT_ERROR
|
|
91
|
+
|
|
80
92
|
|
|
81
93
|
from process_bigraph import Process
|
|
82
94
|
|
|
@@ -100,8 +112,11 @@ def get_registry() -> Dict[str, Type[Process]]:
|
|
|
100
112
|
|
|
101
113
|
# ---------------------------------------------------------------------------
|
|
102
114
|
# Ray actor — one per pool slot. Holds a single Process instance.
|
|
115
|
+
#
|
|
116
|
+
# Declared as a plain class at module load time so this file imports cleanly
|
|
117
|
+
# without ray installed. ``ray.remote(...)`` is applied lazily on first use
|
|
118
|
+
# (cached) inside ``_remote_actor_class()``.
|
|
103
119
|
# ---------------------------------------------------------------------------
|
|
104
|
-
@ray.remote
|
|
105
120
|
class _ProcessActor:
|
|
106
121
|
def __init__(self, registry: Dict[str, Type[Process]],
|
|
107
122
|
class_name: str, config: dict):
|
|
@@ -121,6 +136,18 @@ class _ProcessActor:
|
|
|
121
136
|
return self.instance.update(state, interval)
|
|
122
137
|
|
|
123
138
|
|
|
139
|
+
_REMOTE_ACTOR_CLASS = None # cached ray.remote(_ProcessActor)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _remote_actor_class():
|
|
143
|
+
"""Return the ray-remote-wrapped _ProcessActor, building it on first call."""
|
|
144
|
+
global _REMOTE_ACTOR_CLASS
|
|
145
|
+
if _REMOTE_ACTOR_CLASS is None:
|
|
146
|
+
_require_ray()
|
|
147
|
+
_REMOTE_ACTOR_CLASS = ray.remote(_ProcessActor)
|
|
148
|
+
return _REMOTE_ACTOR_CLASS
|
|
149
|
+
|
|
150
|
+
|
|
124
151
|
# ---------------------------------------------------------------------------
|
|
125
152
|
# Actor pool. One pool per (process_class, process_config). Persistent across
|
|
126
153
|
# RayProcess instances and across simulation runs.
|
|
@@ -128,11 +155,12 @@ class _ProcessActor:
|
|
|
128
155
|
class _ActorPool:
|
|
129
156
|
def __init__(self, class_name: str, config: dict, n_workers: int):
|
|
130
157
|
registry = get_registry()
|
|
158
|
+
actor_cls = _remote_actor_class()
|
|
131
159
|
# Spawn all actors concurrently — actor.remote() returns immediately;
|
|
132
160
|
# we don't ray.get on the constructor. The first .inputs.remote() call
|
|
133
161
|
# implicitly waits for the actor to be ready.
|
|
134
162
|
self.actors = [
|
|
135
|
-
|
|
163
|
+
actor_cls.remote(registry, class_name, config)
|
|
136
164
|
for _ in range(n_workers)
|
|
137
165
|
]
|
|
138
166
|
self._next = 0
|
|
@@ -220,6 +248,7 @@ class RayProcess(Process):
|
|
|
220
248
|
}
|
|
221
249
|
|
|
222
250
|
def initialize(self, config):
|
|
251
|
+
_require_ray()
|
|
223
252
|
if not ray.is_initialized():
|
|
224
253
|
ray.init(ignore_reinit_error=True, log_to_driver=False)
|
|
225
254
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/experiments/minimal_gillespie.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/dynamic_structure.py
RENAMED
|
File without changes
|
|
File without changes
|
{process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/growth_division.py
RENAMED
|
File without changes
|
{process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph/processes/math_expression.py
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{process_bigraph-1.4.0 → process_bigraph-1.4.2}/process_bigraph.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|