oq-engine
oq-engine copied to clipboard
Improve error handling
For example, if by mistake the user assigns the wrong calculation_mode
in the configuration file of the demos/hazard/ScenarioCase1, and indicates, for example, scenario_damage
, the following error appears:
(openquake) ➜ ScenarioCase1: ✗ oq engine --run job.ini
[2024-06-05 18:40:13 #5 INFO] [email protected] running ~/oq-engine/demos/hazard/ScenarioCase1/job.ini [--hc=None]
[2024-06-05 18:40:13 #5 INFO] Using engine version 3.21.0-gitbca2bf6ad0
[2024-06-05 18:40:14 #5 WARNING] Using 8 processpool workers
[2024-06-05 18:40:14 #5 INFO] Checksum of the inputs: 2365574846 (total size 1.39 KB)
[2024-06-05 18:40:14 #5 INFO] Running EventBasedCalculator with concurrent_tasks = 16
[2024-06-05 18:40:14 #5 INFO] Inferring the hazard grid
[2024-06-05 18:40:14 #5 INFO] Read N=168 hazard sites and L=2 hazard levels
Traceback (most recent call last):
File "/Users/cye/openquake/bin/oq", line 8, in <module>
sys.exit(oq())
^^^^
File "/Users/cye/oq-engine/openquake/commands/__main__.py", line 48, in oq
sap.run(commands, prog='oq')
File "/Users/cye/oq-engine/openquake/baselib/sap.py", line 212, in run
return _run(parser(funcdict, **parserkw), argv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cye/oq-engine/openquake/baselib/sap.py", line 203, in _run
return func(**dic)
^^^^^^^^^^^
File "/Users/cye/oq-engine/openquake/commands/engine.py", line 181, in main
run_jobs(jobs)
File "/Users/cye/oq-engine/openquake/engine/engine.py", line 418, in run_jobs
run_calc(jobctx)
File "/Users/cye/oq-engine/openquake/engine/engine.py", line 281, in run_calc
calc.run(shutdown=True)
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 256, in run
raise exc from None
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 244, in run
self.pre_execute()
File "/Users/cye/oq-engine/openquake/calculators/event_based_risk.py", line 345, in pre_execute
super().pre_execute()
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 619, in pre_execute
calc.run(remove=False)
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 256, in run
raise exc from None
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 244, in run
self.pre_execute()
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 629, in pre_execute
self.read_inputs()
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 504, in read_inputs
self._read_risk2()
File "/Users/cye/oq-engine/openquake/calculators/base.py", line 911, in _read_risk2
taxonomies = python3compat.decode(self.assetcol.tagcol.taxonomy[1:])
^^^^^^^^^^^^^
AttributeError: 'EventBasedCalculator' object has no attribute 'assetcol'
A clear error message should appear staying:
A scenario_damage calculation requires as input file the exposure model, which is missing in the configuration file
And something similar for other parameters and calculation modes.