def test_set_total(self): """ The total value is set for the given key """ kvs = self.connect() # Specify a 'totals' counter type. key = stats.key_name(33, "h", "a/b/c", "t") stats.set_total(33, "h", "a/b/c", 123) self.assertEqual("123", kvs.get(key))
def execute(self, kvs_keys_purged=None): """ Trigger the calculation and serialization of hazard curves, mean hazard curves/maps and quantile curves. :param kvs_keys_purged: a list only passed by tests who check the kvs keys used/purged in the course of the calculation. :returns: the keys used in the course of the calculation (for the sake of testability). """ sites = self.sites_to_compute() realizations = self["NUMBER_OF_LOGIC_TREE_SAMPLES"] LOG.info("Going to run classical PSHA hazard for %s realizations " "and %s sites" % (realizations, len(sites))) stats.set_total(self.job_id, "classical:execute:sites", len(sites)) stats.set_total(self.job_id, "classical:execute:realizations", realizations) block_size = config.hazard_block_size() for start in xrange(0, len(sites), block_size): end = start + block_size data = sites[start:end] self.do_curves(data, realizations, serializer=self.serialize_hazard_curve_of_realization) # mean curves self.do_means( data, realizations, curve_serializer=self.serialize_mean_hazard_curves, map_func=classical_psha.compute_mean_hazard_maps, map_serializer=self.serialize_mean_hazard_map, ) # quantile curves quantiles = self.quantile_levels self.do_quantiles( data, realizations, quantiles, curve_serializer=self.serialize_quantile_hazard_curves, map_func=classical_psha.compute_quantile_hazard_maps, map_serializer=self.serialize_quantile_hazard_map, ) # Done with this chunk, purge intermediate results from kvs. release_data_from_kvs(self.job_id, data, realizations, quantiles, self.poes_hazard_maps, kvs_keys_purged)
def analyze(self): """Set the task total counter.""" task_total = (self.calc_proxy.oq_job_profile.realizations * len(self.calc_proxy.sites_to_compute())) stats.set_total(self.calc_proxy.job_id, 'h', 'uhs:tasks', task_total)
def initialize(self): """Set the task total counter.""" super(UHSCalculator, self).initialize() task_total = (self.job_ctxt.oq_job_profile.realizations * len(self.job_ctxt.sites_to_compute())) stats.set_total(self.job_ctxt.job_id, 'h', 'uhs:tasks', task_total)
def initialize(self): """Set the task total counter.""" task_total = self.job_ctxt.oq_job_profile.realizations * len(self.job_ctxt.sites_to_compute()) stats.set_total(self.job_ctxt.job_id, "h", "uhs:tasks", task_total)