gem/oq-engine — pull request #880 by larsbutler (2012-09-18 15:43:01+00:00)
Title: Classical Hazard post-processing crashes when there are no post-processing tasks

Fixed bug where post_process would crash. To reproduce this, simply run a classical hazard job with `mean_hazard_curves = False` and `quantile_hazard_curves = `. The expected error looks something like this:

Traceback (most recent call last):
File "bin/openquake", line 349, in
args.force_inputs, args.exports)
File "bin/openquake", line 201, in run_hazard
completed_job = engine2.run_hazard(job, log_level, log_file, exports)
File "/Users/larsbutler/proj/oq-engine/openquake/engine2.py", line 305, in run_hazard
_do_run_hazard(job, exports)
File "/Users/larsbutler/proj/oq-engine/openquake/engine2.py", line 385, in _do_run_hazard
calc.post_process()
File "/Users/larsbutler/proj/oq-engine/openquake/calculators/hazard/classical/core.py", line 369, in post_process
tf_args=dict(job_id=self.job.id))
File "/Users/larsbutler/proj/oq-engine/openquake/utils/tasks.py", line 86, in distribute
results = result.join_native()
File "/Users/larsbutler/.virtualenvs/openquake/lib/python2.7/site-packages/celery/result.py", line 424, in join_native
interval=interval):
File "/Users/larsbutler/.virtualenvs/openquake/lib/python2.7/site-packages/celery/result.py", line 405, in iter_native
backend = self.results[0].backend
IndexError: list index out of range

If a job is run without any post-processing tasks (such as means
or quantiles), the classical calculator will still attempt to
create and distribute tasks... even when there's no work to be done.

So, I just added a short circuit to skip all of that code if no
post-processing is actually needed.

*Please note:* I didn't add a test directly for this, but the patch I'm going to submit soon (adding stats results to qa tests) includes at least 1 case where this is exercised.