-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathexample_multiprocessing_lucian.py
More file actions
43 lines (32 loc) · 1000 Bytes
/
example_multiprocessing_lucian.py
File metadata and controls
43 lines (32 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import ray
import roadrunner
# start ray
ray.init(ignore_reinit_error=True)
modelstr = """<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model metaid="__main" id="__main">
<listOfParameters>
<parameter id="a" value="3" constant="true"/>
</listOfParameters>
</model>
</sbml>
"""
@ray.remote
class SimulatorActorPath(object):
"""Ray actor to execute simulations."""
def __init__(self):
self.r = roadrunner.RoadRunner(modelstr)
def simulate(self):
"""Simulate."""
print("Just read the value of 'a'")
print(self.r.getValue("a"), "\n")
def ray_example():
"""Ray example."""
actor_count: int = 1 # cores to run this on
simulators = [SimulatorActorPath.remote() for _ in range(actor_count)]
# run simulations
# tc_ids = []
for simulator in simulators:
simulator.simulate.remote()
if __name__ == "__main__":
ray_example()