Engine¶
Engine: A collection of fundamental functions for initializing and running calculations.
-
openquake.engine.engine.
check_hazard_risk_consistency
(haz_job, risk_mode)[source]¶ Make sure that the provided hazard job is the right one for the current risk calculator.
Parameters: - job – an OqJob instance referring to the previous hazard calculation
- risk_mode – the calculation_mode string of the current risk calculation
-
openquake.engine.engine.
cleanup_after_job
(job, terminate)[source]¶ Release the resources used by an openquake job. In particular revoke the running tasks (if any).
Parameters: - job_id (int) – the job id
- terminate (bool) – the celery revoke command terminate flag
-
openquake.engine.engine.
create_job
(user_name='openquake', log_level='progress', hc_id=None)[source]¶ Create job for the given user, return it.
Parameters: - username (str) – Username of the user who owns/started this job. If the username doesn’t exist, a user record for this name will be created.
- log_level (str) – Defaults to ‘progress’. Specify a logging level for this job. This level can be passed, for example, from the command line interface using the –log-level directive.
- hc_id – If not None, then the created job is a risk job
Returns: openquake.engine.db.models.OqJob
instance.
-
openquake.engine.engine.
del_calc
(job_id)[source]¶ Delete a calculation and all associated outputs.
Parameters: job_id – ID of a OqJob
.
-
openquake.engine.engine.
expose_outputs
(dstore, job)[source]¶ Build a correspondence between the outputs in the datastore and the ones in the database.
Parameters: - dstore – a datastore instance
- job – an OqJob instance
-
openquake.engine.engine.
get_calc_id
(job_id=None)[source]¶ Return the latest calc_id by looking both at the datastore and the database.
-
openquake.engine.engine.
get_outputs
(job_id)[source]¶ Parameters: job_id – ID of a calculation. Returns: A sequence of openquake.engine.db.models.Output
objects
-
openquake.engine.engine.
job_from_file
(*args, **kwargs)[source]¶ Create a full job profile from a job config file.
Parameters: - cfg_file_path (str) – Path to the job.ini.
- username (str) – The user who will own this job profile and all results.
- log_level (str) – Desired log level.
- exports – Comma-separated sting of desired export types.
- hazard_output_id (int) – ID of a hazard output to use as input to this calculation. Specify
this xor
hazard_calculation_id
. - hazard_calculation_id (int) – ID of a complete hazard job to use as input to this
calculation. Specify this xor
hazard_output_id
.
Params extras: Extra parameters (used only in the tests to override the params)
Returns: Raises: RuntimeError if the input job configuration is not valid
-
openquake.engine.engine.
job_from_file_lite
(*args, **kwargs)[source]¶ Create a full job profile from a job config file.
Parameters: - cfg_file (str) – Path to the job.ini files.
- username (str) – The user who will own this job profile and all results.
- log_level (str) – Desired log level.
- exports – Comma-separated sting of desired export types.
Params extras: Extra parameters (used only in the tests to override the params)
Returns: Raises: RuntimeError if the input job configuration is not valid
-
openquake.engine.engine.
job_stats
(*args, **kwds)[source]¶ A context manager saving information such as the number of sites and the disk space occupation in the job_stats table. The information is saved at the end of the job, even if the job fails.
-
openquake.engine.engine.
list_outputs
(job_id, full=True)[source]¶ List the outputs for a given
OqJob
.Parameters: - job_id – ID of a calculation.
- full (bool) – If True produce a full listing, otherwise a short version
-
openquake.engine.engine.
log_status
(job, status)[source]¶ Switch to a particular phase of execution.
Parameters: - job – An
OqJob
instance. - job_type (str) – calculation type (hazard|risk)
- status (str) – one of the following: pre_executing, executing, post_executing, post_processing, export, clean_up, complete
- job – An
-
openquake.engine.engine.
print_outputs_summary
(outputs, full=True)[source]¶ List of
openquake.engine.db.models.Output
objects.
-
openquake.engine.engine.
run_calc
(job, log_level, log_file, exports, lite=False)[source]¶ Run a calculation.
Parameters: - job –
openquake.engine.db.model.OqJob
instance - log_level (str) – The desired logging level. Valid choices are ‘debug’, ‘info’, ‘progress’, ‘warn’, ‘error’, and ‘critical’.
- log_file (str) – Complete path (including file name) to file where logs will be written. If None, logging will just be printed to standard output.
- exports – A comma-separated string of export types.
- lite – Flag set when the oq-lite calculators are used
- job –
-
openquake.engine.engine.
run_job
(cfg_file, log_level, log_file, exports='', hazard_output_id=None, hazard_calculation_id=None)[source]¶ Run a job using the specified config file and other options.
Parameters: - cfg_file (str) – Path to calculation config (INI-style) file.
- log_level (str) – ‘debug’, ‘info’, ‘warn’, ‘error’, or ‘critical’
- log_file (str) – Path to log file.
- exports – A comma-separated string of export types requested by the user. Currently only ‘xml’ is supported.
- hazard_ouput_id (str) – The Hazard Output ID used by the risk calculation (can be None)
- hazard_calculation_id (str) – The Hazard Job ID used by the risk calculation (can be None)
-
openquake.engine.engine.
run_job_lite
(cfg_file, log_level, log_file, exports='', hazard_output_id=None, hazard_calculation_id=None)[source]¶ Run a job using the specified config file and other options.
Parameters: - cfg_file (str) – Path to calculation config (INI-style) files.
- log_level (str) – ‘debug’, ‘info’, ‘warn’, ‘error’, or ‘critical’
- log_file (str) – Path to log file.
- exports – A comma-separated string of export types requested by the user. Currently only ‘xml’ is supported.