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"