Example #1
0
def from_config(ctx, config_file, cancel, monitor, background, verbose):
    """Run reV pipeline from a config file."""
    verbose = any([verbose, ctx.obj['VERBOSE']])

    if cancel:
        Pipeline.cancel_all(config_file)
    elif monitor and background:
        pipeline_monitor_background(config_file, verbose=verbose)
    else:
        Pipeline.run(config_file, monitor=monitor, verbose=verbose)
Example #2
0
    def _run_pipelines(self, monitor_background=False, verbose=False):
        """Run the reV pipeline modules for each batch job.

        Parameters
        ----------
        monitor_background : bool
            Flag to monitor all batch pipelines continuously
            in the background using the nohup command. Note that the
            stdout/stderr will not be captured, but you can set a
            pipeline "log_file" to capture logs.
        verbose : bool
            Flag to turn on debug logging for the pipelines.
        """

        for d in self.sub_dirs:
            pipeline_config = os.path.join(
                d, os.path.basename(self._config.pipeline_config))
            if not os.path.isfile(pipeline_config):
                raise PipelineError('Could not find pipeline config to run: '
                                    '"{}"'.format(pipeline_config))
            elif monitor_background:
                pipeline_monitor_background(pipeline_config, verbose=verbose)
            else:
                Pipeline.run(pipeline_config, monitor=False, verbose=verbose)
Example #3
0
def test_pipeline_local():
    """Test the reV pipeline execution on a local machine."""

    pipeline_dir = os.path.join(TESTDATADIR, 'pipeline/')
    log_dir = os.path.join(pipeline_dir, 'logs/')
    out_dir = os.path.join(pipeline_dir, 'outputs/')
    fpipeline = os.path.join(pipeline_dir, 'config_pipeline.json')
    fbaseline = os.path.join(pipeline_dir, 'baseline_pipeline_multi-year.h5')

    Pipeline.run(fpipeline, monitor=True)

    fpath_out = Pipeline.parse_previous(out_dir, 'multi-year',
                                        target_module='multi-year')[0]

    dsets = ['generation/cf_mean-means', 'econ/lcoe_fcr-means']
    with h5py.File(fpath_out, 'r') as f_new:
        with h5py.File(fbaseline, 'r') as f_base:
            for dset in dsets:
                msg = 'Local pipeline failed for "{}"'.format(dset)
                assert np.allclose(f_new[dset][...], f_base[dset][...]), msg

    if PURGE_OUT:
        shutil.rmtree(log_dir)
        shutil.rmtree(out_dir)