Run isolated NEURON simulations in a single Python session.
Project description
NEURON subprocessing
Run multiple NEURON setups isolated from each other from a single Python script.
This package uses Python's subprocess
to run multiple NEURON instances that
are completely seperated from eachother, making it easier to executed repeated
and parametrized simulations without having to worry about cleaning up the state
of the previous run.
Installation
pip install nrn-subprocess
Usage
Write your entire NEURON setup that you'd like to isolate inside of a function,
then use the subprocess
or isolate
approach to execute it in isolation:
subprocess
import nrnsub
def my_sim(param1, opt1=None):
from neuron import h
s = h.Section(name="main")
# ...
return s.v
for i in range(10):
nrnsub.subprocess(my_sim, 15, opt1=i)
This will run the subprocesses in series, parallel coming Soon (tm).
isolate
There's also the isolate
decorator that will make sure every call to that function is
ran as an isolated subprocess:
import nrnsub
@nrnsub.isolate
def my_sim(param1, opt1=None):
from neuron import h
s = h.Section(name="main")
# ...
return s.v
for i in range(10):
my_sim(15, opt1=i)
Worker PATH
The worker might have trouble unpacking the serialized objects because it can't
find the module they came from on the main process. This might result in dill
raising "module not found" errors. To fix them you can pass the _worker_path
to
subprocess
or worker_path
to the isolate
decorator:
import nrnsub
sys.path.insert(0, "/home/me/my_modules_folder")
@nrnsub.isolate(worker_path=["/home/me/my_modules_folder"])
def f():
import something_in_my_modules_folder
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nrn-subprocess-1.3.4.tar.gz
.
File metadata
- Download URL: nrn-subprocess-1.3.4.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12c8778b3a8ba672875f723604c73708dad86a5cc9f6539f41be0212c254f046 |
|
MD5 | 62c920cd226ad49358586080a7e363c3 |
|
BLAKE2b-256 | a731bd2a6f552130e41a39318670e9d336d9a87ec9e9cd4a3a7032314bca1588 |
File details
Details for the file nrn_subprocess-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: nrn_subprocess-1.3.4-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f020d9fc999722534cad62fff6662c38dd6ab7c03e5e5ff17711d25df0742e |
|
MD5 | f456e625f7d4169fb826931f0195029e |
|
BLAKE2b-256 | ae74905d0d6dc2caf5063c5631cce3c86f39629a3e3bff86b45675ab5ba4d706 |