Beispiel #1
0
 def test_scaling_definitions(self):
     from openquake.db.models import OqJobProfile
     from openquake.job.params import ENUM_MAP
     from openquake.calculators.hazard.general import IML_SCALING
     enum_map_reversed = dict((val, key) for (key, val) in ENUM_MAP.items())
     imt_config_names = [enum_map_reversed[imt]
                         for (imt, imt_verbose) in OqJobProfile.IMT_CHOICES
                         if imt in enum_map_reversed]
     self.assertEqual(set(IML_SCALING) - set(imt_config_names), set())
     self.assertEqual(set(imt_config_names), set(IML_SCALING))
     for imt in imt_config_names:
         self.assertTrue(callable(IML_SCALING[imt]))
         self.assertTrue(hasattr(self, 'test_imt_%s' % imt),
                         'please test imt %s' % imt)
Beispiel #2
0
 def test_scaling_definitions(self):
     from openquake.db.models import OqJobProfile
     from openquake.job.params import ENUM_MAP
     from openquake.calculators.hazard.general import IML_SCALING
     enum_map_reversed = dict((val, key) for (key, val) in ENUM_MAP.items())
     imt_config_names = [
         enum_map_reversed[imt]
         for (imt, imt_verbose) in OqJobProfile.IMT_CHOICES
         if imt in enum_map_reversed
     ]
     self.assertEqual(set(IML_SCALING) - set(imt_config_names), set())
     self.assertEqual(set(imt_config_names), set(IML_SCALING))
     for imt in imt_config_names:
         self.assertTrue(callable(IML_SCALING[imt]))
         self.assertTrue(hasattr(self, 'test_imt_%s' % imt),
                         'please test imt %s' % imt)
Beispiel #3
0
from openquake.job.handlers import resolve_handler
from openquake.job import config as conf
from openquake.job import params as job_params
from openquake.job.mixins import Mixin
from openquake.job.params import (
    PARAMS, CALCULATION_MODE, ENUM_MAP, PATH_PARAMS, INPUT_FILE_TYPES,
    ARRAY_RE)
from openquake.kvs import mark_job_as_current
from openquake.logs import LOG
from openquake.utils import stats

RE_INCLUDE = re.compile(r'^(.*)_INCLUDE')

FLAGS = flags.FLAGS

REVERSE_ENUM_MAP = dict((v, k) for k, v in ENUM_MAP.iteritems())


def run_job(job_file, output_type):
    """
    Given a job_file, run the job.

    :param job_file: the path of the configuration file for the job
    :type job_file: string
    :param output_type: the desired format for the results, one of 'db', 'xml'
    :type output_type: string
    """
    a_job = Job.from_file(job_file, output_type)
    a_job.set_status('running')

    # closing all db connections to make sure they're not shared between