Skip to content

Commit 1ef2a89

Browse files
runmodels + pyvirtualdisplay (#15)
* runmodels + pyvirtualdisplay * add --virtual option to launch everything in a virtual display * back-end required (Xvfb) * CI: use `--virtual` option for `runmodels` * update docs
1 parent 4c8965f commit 1ef2a89

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

.github/workflows/nrn-modeldb-ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
# Install NEURON V1
8181
python -m pip install $NEURON_V1
8282
nrn_ver=`python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)"`
83-
runmodels $nrn_ver $MODELS_TO_RUN
83+
runmodels --virtual $nrn_ver $MODELS_TO_RUN
8484
report2html ${nrn_ver}.json
8585
python -m pip uninstall --yes $NEURON_V1
8686
echo "nrn1_ver=$nrn_ver" >> $GITHUB_ENV
@@ -91,7 +91,7 @@ jobs:
9191
# Install NEURON V2
9292
python -m pip install $NEURON_V2
9393
nrn_ver=`python -c "from neuron import __version__ as nrn_ver; print(nrn_ver)"`
94-
runmodels $nrn_ver $MODELS_TO_RUN
94+
runmodels --virtual $nrn_ver $MODELS_TO_RUN
9595
report2html ${nrn_ver}.json
9696
python -m pip uninstall --yes $NEURON_V2
9797
echo "nrn2_ver=$nrn_ver" >> $GITHUB_ENV

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ The following commands are now available:
2525
runmodels -h
2626
```
2727
Note that models have to be downloaded beforehand with `getmodels`.
28-
28+
You can specify `--virtual` so that NEURON GUI is run in headless mode. It requires a backend (n.r. `Xvfb`)
29+
2930

3031
* `report2html` -> create an interactive HTML report for a given json report (obtained with `runmodels`)
3132
```

modeldb/commands.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def runmodels(args=None):
3131
3232
Options:
3333
--gout Include gout into the report. Note that gout data can be very big, so disabled by default.
34+
--virtual Run in headless mode. You need a back-end like Xvfb.
3435
3536
Examples
3637
runmodels /path/to/workdir
@@ -40,8 +41,17 @@ def runmodels(args=None):
4041
working_dir = options.pop("<WorkingDirectory>")
4142
model_ids = [int(model_id) for model_id in options.pop("<model_id>")]
4243
gout = options.pop("--gout", False)
44+
virtual = options.pop("--virtual", False)
4345

44-
ModelRunManager(working_dir, gout=gout).run_models(model_list=model_ids if model_ids else None)
46+
mrm = ModelRunManager(working_dir, gout=gout)
47+
model_list = model_ids if model_ids else None
48+
49+
if virtual:
50+
from pyvirtualdisplay import Display
51+
with Display() as _:
52+
mrm.run_models(model_list)
53+
else:
54+
mrm.run_models(model_list)
4555

4656

4757
def getmodels(args=None):

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ requests
33
pyyaml
44
docopt
55
jinja2
6+
pyvirtualdisplay
67

78
# for running models
89
pyqt5

0 commit comments

Comments
 (0)