def build_report(job_ini, output_dir=None):
    """
    Write a `report.csv` file with information about the calculation
    without running it

    :param job_ini:
        full pathname of the job.ini file
    :param output_dir:
        the directory where the report is written (default the input directory)
    """
    calc_id = logs.init()
    oq = readinput.get_oqparam(job_ini)
    if oq.calculation_mode == 'classical':
        oq.calculation_mode = 'preclassical'
    oq.ground_motion_fields = False
    output_dir = output_dir or os.path.dirname(job_ini)
    from openquake.calculators import base  # ugly
    calc = base.calculators(oq, calc_id)
    calc.save_params()  # needed to save oqparam

    # some taken is care so that the real calculation is not run:
    # the goal is to extract information about the source management only
    calc.pre_execute()
    if oq.calculation_mode == 'preclassical':
        calc.execute()
    rw = ReportWriter(calc.datastore)
    rw.make_report()
    report = (os.path.join(output_dir, 'report.rst') if output_dir
              else calc.datastore.export_path('report.rst'))
    try:
        rw.save(report)
    except IOError as exc:  # permission error
        sys.stderr.write(str(exc) + '\n')
    readinput.exposure = None  # ugly hack
    return report
def build_report ( job_ini , output_dir = None ) : calc_id = logs . init ( ) oq = readinput . get_oqparam ( job_ini ) if oq . calculation_mode == 'classical' : oq . calculation_mode = 'preclassical' oq . ground_motion_fields = False output_dir = output_dir or os . path . dirname ( job_ini ) from openquake . calculators import base calc = base . calculators ( oq , calc_id ) calc . save_params ( ) calc . pre_execute ( ) if oq . calculation_mode == 'preclassical' : calc . execute ( ) rw = ReportWriter ( calc . datastore ) rw . make_report ( ) report = ( os . path . join ( output_dir , 'report.rst' ) if output_dir else calc . datastore . export_path ( 'report.rst' ) ) try : rw . save ( report ) except IOError as exc : sys . stderr . write ( str ( exc ) + '\n' ) readinput . exposure = None return report
Write a `report.csv` file with information about the calculation
    without running it

    :param job_ini:
        full pathname of the job.ini file
    :param output_dir:
        the directory where the report is written (default the input directory)