Example #1
0
def risk_task(task):
    @wraps(task)
    def fn(job_id, units, *args):
        task(job_id, units, *args)
        num_items = get_num_items(units)
        base.signal_task_complete(job_id=job_id, num_items=num_items)
    fn.ignore_result = False

    return tasks.oqtask(count_progress_risk('r')(fn))
Example #2
0
def risk_task(task):
    @wraps(task)
    def fn(job_id, units, *args):
        task(job_id, units, *args)
        num_items = get_num_items(units)
        base.signal_task_complete(job_id=job_id, num_items=num_items)

    fn.ignore_result = False

    return tasks.oqtask(count_progress_risk('r')(fn))
Example #3
0
 def test_error_in_celery(self):
     # the error here is inside the celery task
     p = mock.patch(
         'openquake.engine.calculators.hazard.event_based.core.'
         'EventBasedHazardCalculator.core_calc_task',
         oqtask(lambda *args: 1 / 0))
     with p:
         self.run_job('job.ini')
     args, kw = tasks.update_calculation.call_args
     self.assertEqual(kw['status'], 'failed')
     self.assertIn("ZeroDivisionError", kw['einfo'])
Example #4
0
        models.HazardMap.objects.create(
            output=output,
            lt_realization=hc.lt_realization,
            investigation_time=hc.investigation_time,
            imt=hc.imt,
            statistics=hc.statistics,
            quantile=hc.quantile,
            sa_period=hc.sa_period,
            sa_damping=hc.sa_damping,
            poe=poe,
            lons=lons,
            lats=lats,
            imls=map_values,
        )

hazard_curves_to_hazard_map_task = tasks.oqtask(hazard_curves_to_hazard_map)
hazard_curves_to_hazard_map_task.ignore_result = False  # this is essential


def hazard_curves_to_hazard_map_task_arg_gen(job):
    """
    Yield task arguments for processing hazard curves into hazard maps.

    :param job:
        A :class:`openquake.engine.db.models.OqJob` which has some hazard
        curves associated with it.
    """
    poes = job.hazard_calculation.poes

    hazard_curve_ids = models.HazardCurve.objects.filter(
        output__oq_job=job, imt__isnull=False).values_list('id', flat=True)
Example #5
0
            output=output,
            lt_realization=hc.lt_realization,
            investigation_time=hc.investigation_time,
            imt=hc.imt,
            statistics=hc.statistics,
            quantile=hc.quantile,
            sa_period=hc.sa_period,
            sa_damping=hc.sa_damping,
            poe=poe,
            lons=lons,
            lats=lats,
            imls=map_values,
        )


hazard_curves_to_hazard_map_task = tasks.oqtask(hazard_curves_to_hazard_map)
hazard_curves_to_hazard_map_task.ignore_result = False  # this is essential


def hazard_curves_to_hazard_map_task_arg_gen(job):
    """
    Yield task arguments for processing hazard curves into hazard maps.

    :param job:
        A :class:`openquake.engine.db.models.OqJob` which has some hazard
        curves associated with it.
    """
    poes = job.hazard_calculation.poes

    hazard_curve_ids = models.HazardCurve.objects.filter(
        output__oq_job=job, imt__isnull=False).values_list('id', flat=True)