def export(self, exports=None): """ Export all the outputs in the datastore in the given export formats. :returns: dictionary output_key -> sorted list of exported paths """ # avoid circular imports from openquake.commonlib.export import export as exp exported = {} individual_curves = self.oqparam.individual_curves if exports and isinstance(exports, tuple): fmts = exports elif exports: # is a string fmts = exports.split(',') else: # use passed values fmts = self.oqparam.exports for fmt in fmts: if not fmt: continue for key in self.datastore: # top level keys if 'rlzs' in key and not individual_curves: continue # skip individual curves ekey = (key, fmt) if ekey not in exp: # non-exportable output continue with self.monitor('export'): exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) # special case for uhs which is a view if (self.oqparam.uniform_hazard_spectra and 'hmaps' in self.datastore): ekey = ('uhs', fmt) exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) return exported
def export(self, exports=None): """ Export all the outputs in the datastore in the given export formats. :returns: dictionary output_key -> sorted list of exported paths """ # avoid circular imports from openquake.commonlib.export import export as exp exported = {} individual_curves = self.oqparam.individual_curves if isinstance(exports, tuple): fmts = exports elif exports: # is a string fmts = exports.split(',') elif isinstance(self.oqparam.exports, tuple): fmts = self.oqparam.exports else: # is a string fmts = self.oqparam.exports.split(',') for fmt in fmts: if not fmt: continue keys = set(self.datastore) if (self.oqparam.uniform_hazard_spectra and not self.oqparam.hazard_maps and 'hmaps' in keys): # do not export the hazard maps, even if they are there keys.remove('hmaps') for key in sorted(keys): # top level keys if 'rlzs' in key and not individual_curves: continue # skip individual curves ekey = (key, fmt) if ekey not in exp: # non-exportable output continue with self.monitor('export'): exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) # special case for uhs which is a view if (self.oqparam.uniform_hazard_spectra and 'hmaps' in self.datastore): ekey = ('uhs', fmt) exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) if self.close: # in the engine we close later try: self.datastore.close() except (RuntimeError, ValueError): # sometimes produces errors but they are difficult to # reproduce logging.warn('', exc_info=True) return exported
def export(self, exports=None): """ Export all the outputs in the datastore in the given export formats. :returns: dictionary output_key -> sorted list of exported paths """ # avoid circular imports from openquake.commonlib.export import export as exp exported = {} individual_curves = self.oqparam.individual_curves if exports and isinstance(exports, tuple): fmts = exports elif exports: # is a string fmts = exports.split(',') else: # use passed values fmts = self.oqparam.exports for fmt in fmts: if not fmt: continue keys = set(self.datastore) if (self.oqparam.uniform_hazard_spectra and not self.oqparam.hazard_maps): # do not export the hazard maps, even if they are there keys.remove('hmaps') for key in sorted(keys): # top level keys if 'rlzs' in key and not individual_curves: continue # skip individual curves ekey = (key, fmt) if ekey not in exp: # non-exportable output continue with self.monitor('export'): exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) # special case for uhs which is a view if (self.oqparam.uniform_hazard_spectra and 'hmaps' in self.datastore): ekey = ('uhs', fmt) exported[ekey] = exp(ekey, self.datastore) logging.info('exported %s: %s', key, exported[ekey]) return exported