Ejemplo n.º 1
0
def show_results(failed, output, successful, post_process,
                 job_name, verbose):
    """Shows the results of a batch of jobs."""
    level = logging.DEBUG if verbose else logging.WARNING
    setup_logging("show_results", None, console_level=level)

    if post_process:
        JobPostProcess.show_results(output, job_name)
        sys.exit(0)

    results = ResultsSummary(output)
    results.show_results(only_failed=failed, only_successful=successful)
Ejemplo n.º 2
0
class JobAnalysis:
    """Provides functionality to analyze job results."""
    def __init__(self, output_dir, config):
        self._output_dir = output_dir
        self._config = config
        self._results = ResultsSummary(output_dir)

    def get_job(self, job_name):
        """Return the job from the config file with job_name.

        Parameters
        ----------
        job_name : str

        Returns
        -------
        namedtuple

        """
        return self._config.get_job(job_name)

    def get_successful_result(self, job_name):
        """Return the job result from the results file.
        Refer to :func:`~jade.result.ResultSummary.get_successful_result`.

        """
        return self._results.get_successful_result(job_name)

    def get_simulation(self, job_name):
        """Return a simulation object for the job_name.

        Parameters
        ----------
        job_name : str

        Returns
        -------
        JobExecutionInterface

        """
        # Make sure it was successful, otherwise it will raise.
        self.get_successful_result(job_name)

        job = self.get_job(job_name)
        simulation = self._config.create_from_result(
            job, os.path.join(self._output_dir, JOBS_OUTPUT_DIR))
        return simulation

    def list_results(self):
        """Return a list of Result objects."""
        return self._results.list_results()

    @property
    def output_dir(self):
        return self._output_dir

    def show_results(self, only_failed=False, only_successful=False):
        """Show the results in terminal."""
        return self._results.show_results(only_failed=only_failed,
                                          only_successful=only_successful)
Ejemplo n.º 3
0
def show_results(failed, output, successful, post_process, job_name, verbose):
    """Shows the results of a batch of jobs."""
    if not Path(output).exists():
        print(f"{output} does not exist", file=sys.stderr)
        sys.exit(1)

    level = logging.DEBUG if verbose else logging.WARNING
    setup_logging("show_results", None, console_level=level)

    if post_process:
        JobPostProcess.show_results(output, job_name)
        sys.exit(0)

    try:
        results = ResultsSummary(output)
    except InvalidConfiguration:
        print(
            f"No results are available in {output}. To check status of in-progress jobs run "
            f"'jade show-status -o {output}'",
            file=sys.stderr,
        )
        sys.exit(1)

    results.show_results(only_failed=failed, only_successful=successful)