docs: def expose_outputs(dstore, owner=getpass.getuser(), status='complete'):
      """
      Build a correspondence between the outputs in the datastore and the
      ones in the database.
  
      :param dstore: datastore
      """
      oq = dstore['oqparam']
      exportable = set(ekey[0] for ekey in export.export)
      calcmode = oq.calculation_mode
      dskeys = set(dstore) & exportable  # exportable datastore keys
      dskeys.add('fullreport')
      rlzs = dstore['csm_info'].rlzs
      if len(rlzs) > 1:
          dskeys.add('realizations')
      if len(dstore['csm_info/sg_data']) > 1:  # export sourcegroups.csv
          dskeys.add('sourcegroups')
      hdf5 = dstore.hdf5
      if 'hcurves-stats' in hdf5 or 'hcurves-rlzs' in hdf5:
          if oq.hazard_stats() or oq.individual_curves or len(rlzs) == 1:
              dskeys.add('hcurves')
          if oq.uniform_hazard_spectra:
              dskeys.add('uhs')  # export them
          if oq.hazard_maps:
              dskeys.add('hmaps')  # export them
      if 'avg_losses-stats' in dstore or (
              'avg_losses-rlzs' in dstore and len(rlzs)):
          dskeys.add('avg_losses-stats')
      if 'curves-rlzs' in dstore and len(rlzs) == 1:
          dskeys.add('loss_curves-rlzs')
      if 'curves-stats' in dstore and len(rlzs) > 1:
          dskeys.add('loss_curves-stats')
      if oq.conditional_loss_poes:  # expose loss_maps outputs
          if 'loss_curves-stats' in dstore:
              dskeys.add('loss_maps-stats')
      if 'all_loss_ratios' in dskeys:
          dskeys.remove('all_loss_ratios')  # export only specific IDs
      if 'ruptures' in dskeys and 'scenario' in calcmode:
          exportable.remove('ruptures')  # do not export, as requested by Vitor
      if 'rup_loss_table' in dskeys:  # keep it hidden for the moment
          dskeys.remove('rup_loss_table')
      if 'hmaps' in dskeys and not oq.hazard_maps:
          dskeys.remove('hmaps')  # do not export the hazard maps
      if logs.dbcmd('get_job', dstore.calc_id) is None:
          # the calculation has not been imported in the db yet
          logs.dbcmd('import_job', dstore.calc_id, oq.calculation_mode,
                     oq.description + ' [parent]', owner, status,
                     oq.hazard_calculation_id, dstore.datadir)
      keysize = []
      for key in sorted(dskeys & exportable):
          try:
              size_mb = dstore.get_attr(key, 'nbytes') / MB
          except (KeyError, AttributeError):
              size_mb = None
          keysize.append((key, size_mb))
      ds_size = os.path.getsize(dstore.filename) / MB
      logs.dbcmd('create_outputs', dstore.calc_id, keysize, ds_size)