예제 #1
0
파일: resubmit_jobs.py 프로젝트: jgu2/jade
def _get_jobs_to_resubmit(cluster, output, failed, missing):
    results = ResultsSummary(output)
    jobs_to_resubmit = []
    if failed:
        res = results.get_results_by_type()
        jobs_to_resubmit += res["canceled"]
        jobs_to_resubmit += res["failed"]
    if missing:
        jobs_to_resubmit += results.get_missing_jobs(cluster.iter_jobs())

    return {x.name for x in jobs_to_resubmit}
예제 #2
0
def create_config_from_previous_run(config_file,
                                    output,
                                    result_type="successful",
                                    **kwargs):
    """Create instance of a JobConfiguration from a previous config file,
    returning only those of the type given

    Parameters
    ----------
    config_file : str
        location of config
    output : str
        location of previous results
    result_type : string
        type of results

    Returns
    -------
    JobConfiguration

    Raises
    ------
    InvalidParameter
            Raised if result_type is not successful or failed

    """
    allowed_types = ["successful", "failed", "missing"]
    if result_type not in allowed_types:
        raise InvalidParameter(f"given result type invalid: {result_type}")

    config = deserialize_config(load_data(config_file))
    summary = ResultsSummary(output)
    results_of_type = []

    if result_type == "successful":
        results_of_type = summary.get_successful_results()
    elif result_type == "failed":
        results_of_type = summary.get_failed_results()
    elif result_type == "missing":
        results_of_type = summary.get_missing_jobs(config.iter_jobs())

    parameters = []
    # Note that both jobs and results have `.name`.
    for result in results_of_type:
        job_parameters = config.get_job(result.name)
        parameters.append(job_parameters)

    config.reconfigure_jobs(parameters)
    return deserialize_config(config.serialize(), **kwargs)