a1af2977c50399f58726182cd9481a6770c115ac,sos/sos_task.py,,check_task,#Any#,224

Before Change


                res = pickle.load(result)
            if res["succ"] == 0:
                if isinstance(res["output"], dict):
                    if all(FileTarget(x).exists() and FileTarget(x).signature() == y for x,y in res["output"].items()):
                        if new_res:
                            return "completed"
                        else:
                            return "completed-old"
                    else:
                        env.logger.debug("{} not found or signature mismatch".format(res["output"]))
                        if new_res:
                            return "failed-missing-output"
                        else:
                            return "failed-old-missing-output"
                else:
                    if new_res:
                        return "completed"
                    else:

After Change


        raise ValueError("Task does not exist: {}".format(task))
    status_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".status")
    res_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".res")
    job_file =  os.path.join(os.path.expanduser("~"), ".sos", "tasks", task + ".sh")

    if os.path.isfile(res_file):
        try:
            from .target import FileTarget
            new_res = os.path.getmtime(task_file) <= os.path.getmtime(res_file)
            with open(res_file, "rb") as result:
                res = pickle.load(result)
            if res["succ"] == 0:
                if isinstance(res["output"], dict):
                    for x,y in res["output"].items():
                        if not FileTarget(x).exists() or FileTarget(x).signature() != y:
                            env.logger.debug("{} not found or signature mismatch".format(x))
                            return "result-mismatch"
                    // this is called "completed" remotely but will be
                    // translated to either completed or result-ready locally
                    return "completed"
                else:
                    return "completed"
            else:
                return "failed"
        except Exception as e:
            // sometimes the resfile is changed while we are reading it
            // so we wait a bit and try again.
            env.logger.warning(e)
            time.sleep(1)
            return check_task(task)
    try:
        if not os.path.isfile(status_file) or os.path.getmtime(status_file) < os.path.getmtime(task_file):
            if os.path.isfile(job_file) and os.path.getmtime(job_file) >= os.path.getmtime(task_file):
                return "submitted"
            else:
                return "pending"
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: vatlab/SoS
Commit Name: a1af2977c50399f58726182cd9481a6770c115ac
Time: 2017-03-30
Author: ben.bog@gmail.com
File Name: sos/sos_task.py
Class Name:
Method Name: check_task


Project Name: vatlab/SoS
Commit Name: 93fba23a11389446dc28d02ad4303f0af0f49eff
Time: 2017-05-17
Author: ben.bog@gmail.com
File Name: sos/__main__.py
Class Name:
Method Name: cmd_resume


Project Name: vatlab/SoS
Commit Name: a1af2977c50399f58726182cd9481a6770c115ac
Time: 2017-03-30
Author: ben.bog@gmail.com
File Name: sos/sos_task.py
Class Name:
Method Name: check_task


Project Name: vatlab/SoS
Commit Name: f336f31c56fd8cfe0847240786abe6f6607dcd25
Time: 2017-02-26
Author: ben.bog@gmail.com
File Name: sos/sos_task.py
Class Name:
Method Name: check_task