Skip to content

Commit

Permalink
Restored subprocess.Popen [skip hazardlib] [demos]
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 7, 2017
1 parent c602afc commit 2e9b21f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
24 changes: 12 additions & 12 deletions bin/run-demos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e
# run demos with job_hazard.ini and job_risk.ini
for demo_dir in $(find "$1" -type d | sort); do
if [ -f $demo_dir/job_hazard.ini ]; then
python -m openquake.commands engine --run $demo_dir/job_hazard.ini
python -m openquake.commands engine --run $demo_dir/job_risk.ini --hc -1
oq engine --run $demo_dir/job_hazard.ini
oq engine --run $demo_dir/job_risk.ini --hc -1
fi
done
# run the other demos
Expand All @@ -14,23 +14,23 @@ if [ ! -d "$1" ]; then
fi

for ini in $(find $1 -name job.ini | sort); do
python -m openquake.commands engine --run $ini
oq engine --run $ini
done

# do something with the generated data; -2 is LogicTreeCase3ClassicalPSHA
python -m openquake.commands extract -2 hazard/rlzs
python -m openquake.commands engine --lhc
MPLBACKEND=Agg python -m openquake.commands plot -2
MPLBACKEND=Agg python -m openquake.commands plot_uhs -2
MPLBACKEND=Agg python -m openquake.commands plot_sites -2
oq extract -2 hazard/rlzs
oq engine --lhc
MPLBACKEND=Agg oq plot -2
MPLBACKEND=Agg oq plot_uhs -2
MPLBACKEND=Agg oq plot_sites -2

# fake a wrong calculation still in executing status (AreaSource)
python -m openquake.commands db set_status 26 executing
oq db set_status 26 executing
# repeat the failed/executing calculation, which is useful for QGIS
python -m openquake.commands engine --run $1/hazard/AreaSourceClassicalPSHA/job.ini
oq engine --run $1/hazard/AreaSourceClassicalPSHA/job.ini

# display the calculations
python -m openquake.commands db find %
oq db find %

# build an HTML report
python -m openquake.commands engine --make-html-report today
oq engine --make-html-report today
10 changes: 7 additions & 3 deletions openquake/server/dbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sqlite3
import logging
import threading
import multiprocessing
import subprocess

from openquake.baselib import config, sap, zeromq as z, workerpool as w
from openquake.baselib.general import socket_ready
Expand Down Expand Up @@ -159,8 +159,12 @@ def ensure_on():
if config.dbserver.multi_user:
sys.exit('Please start the DbServer: '
'see the documentation for details')
# otherwise start the DbServer automatically
multiprocessing.Process(target=run_server).start()
# otherwise start the DbServer automatically; NB: I tried to use
# multiprocessing.Process(target=run_server).start() and apparently
# it works, but then run-demos.sh hangs after the end of the first
# calculation, but only if the DbServer is started by oq engine (!?)
subprocess.Popen([sys.executable, '-m', 'openquake.server.dbserver',
'-l', 'INFO'])

# wait for the dbserver to start
waiting_seconds = 10
Expand Down

0 comments on commit 2e9b21f

Please sign in to comment.