openquake.engine package

Submodules

openquake.engine.engine module

Engine: A collection of fundamental functions for initializing and running calculations.

exception openquake.engine.engine.MasterKilled[source]

Bases: exceptions.KeyboardInterrupt

Exception raised when a job is killed manually

openquake.engine.engine.expose_outputs(dstore)[source]

Build a correspondence between the outputs in the datastore and the ones in the database.

Parameters:dstore – datastore
openquake.engine.engine.job_from_file(cfg_file, username, hazard_calculation_id=None)[source]

Create a full job profile from a job config file.

Parameters:
  • cfg_file (str) – Path to a job.ini file.
  • username (str) – The user who will own this job profile and all results
  • datadir (str) – Data directory of the user
  • hazard_calculation_id – ID of a previous calculation or None
Returns:

a pair (job_id, oqparam)

openquake.engine.engine.raiseMasterKilled(signum, _stack)[source]

When a SIGTERM is received, raise the MasterKilled exception with an appropriate error message.

Parameters:
  • signum (int) – the number of the received signal
  • _stack – the current frame object, ignored
openquake.engine.engine.run_calc(job_id, oqparam, log_level, log_file, exports, hazard_calculation_id=None)[source]

Run a calculation.

Parameters:
  • job_id – ID of the current job
  • oqparamopenquake.commonlib.oqvalidation.OqParam 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.

openquake.engine.logs module

Set up some system-wide loggers

class openquake.engine.logs.LogDatabaseHandler(job_id)[source]

Bases: logging.Handler

Log stream handler

emit(record)[source]
class openquake.engine.logs.LogFileHandler(job_id, log_file)[source]

Bases: logging.FileHandler

Log file handler

emit(record)[source]
class openquake.engine.logs.LogStreamHandler(job_id)[source]

Bases: logging.StreamHandler

Log stream handler

emit(record)[source]
openquake.engine.logs.dbcmd(action, *args)[source]

A dispatcher to the database server.

Parameters:
  • action – database action to perform
  • args – arguments
openquake.engine.logs.handle(*args, **kwds)[source]

Context manager adding and removing log handlers.

Parameters:
  • job_id – ID of the current job
  • log_level – one of debug, info, warn, error, critical
  • log_file – log file path (if None, logs on stdout only)
openquake.engine.logs.set_level(level)[source]

Initialize logs to write records with level level or above.

openquake.engine.logs.touch_log_file(log_file)[source]

If a log file destination is specified, attempt to open the file in ‘append’ mode (‘a’). If the specified file is not writable, an IOError will be raised.

Module contents

OpenQuake is an open-source platform for the calculation of hazard and risk impact. It is a project of the Global Earthquake Model, and may be extended by other organizations to address additional classes of peril.

For more information, please see the website at http://www.globalquakemodel.org This software may be downloaded at http://github.com/gem/openquake

The continuous integration server is at
https://ci.openquake.org
Up-to-date sphinx documentation is at
http://docs.openquake.org

This software is licensed under the AGPL license, for more details please see the LICENSE file.

Copyright (C) 2010-2017 GEM Foundation

OpenQuake is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

OpenQuake is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.