def test_classical_psha_based_job_mixes_in_properly(self): with Mixin(self.job, RiskJobMixin, key="risk"): self.assertTrue(RiskJobMixin in self.job.__class__.__bases__) with Mixin(self.job, ClassicalPSHABasedMixin): self.assertTrue( ClassicalPSHABasedMixin in self.job.__class__.__bases__)
def test_job_mixes_in_properly(self): with Mixin(self.job, RiskJobMixin, key="risk"): self.assertTrue(RiskJobMixin in self.job.__class__.__bases__) self.assertTrue( ProbabilisticEventMixin in self.job.__class__.__bases__) with Mixin(self.job, ProbabilisticEventMixin): self.assertTrue( ProbabilisticEventMixin in self.job.__class__.__bases__)
def launch(self): """ Based on the behaviour specified in the configuration, mix in the correct behaviour for the tasks and then execute them. """ output_dir = os.path.join(self.base_path, self['OUTPUT_DIR']) if not os.path.exists(output_dir): os.makedirs(output_dir) results = [] self._partition() for (key, mixin) in Mixin.ordered_mixins(): if key.upper() not in self.sections: continue with Mixin(self, mixin, key=key): # The mixin defines a preload decorator to handle the needed # data for the tasks and decorates _execute(). the mixin's # _execute() method calls the expected tasks. LOG.debug("Job %s Launching %s for %s" % (self.id, mixin, key)) results.extend(self.execute()) return results
def launch(self): """ Based on the behaviour specified in the configuration, mix in the correct behaviour for the tasks and then execute them. """ output_dir = os.path.join(self.base_path, self['OUTPUT_DIR']) if not os.path.exists(output_dir): os.makedirs(output_dir) for (key, mixin) in Mixin.ordered_mixins(): if key.upper() not in self.sections: continue with Mixin(self, mixin): # The mixin defines a preload decorator to handle the needed # data for the tasks and decorates _execute(). the mixin's # _execute() method calls the expected tasks. LOG.debug( "Job %s Launching %s for %s" % (self.job_id, mixin, key)) self.execute()
""" The hazard job mixin proxy. """ from openquake.job.mixins import Mixin class HazJobMixin(Mixin): """ Proxy mixin for mixing in hazard job behaviour """ mixins = {} Mixin.register("Hazard", HazJobMixin, order=1)
# Copyright (c) 2010-2011, GEM Foundation. # # OpenQuake is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License version 3 # only, as published by the Free Software Foundation. # # 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 Lesser General Public License version 3 for more details # (a copy is included in the LICENSE file that accompanied this code). # # You should have received a copy of the GNU Lesser General Public License # version 3 along with OpenQuake. If not, see # <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License. """ The hazard job mixin proxy. """ from openquake.job.mixins import Mixin class HazJobMixin(Mixin): """ Proxy mixin for mixing in hazard job behaviour """ mixins = {} Mixin.register("Hazard", HazJobMixin, order=1)