def adjust_job_start_end(job):
""" Set the job node start and end times based on the presence of the special
job-X-begin and job-X-end archives. Do nothing if these archives are absent
"""
startarchive = "job-{0}-begin".format(job.job_id)
endarchive = "job-{0}-end".format(job.job_id)
for nodename, filepaths in job.rawarchives():
begin = None
end = None
for fname in filepaths:
filename = os.path.basename(fname)
if filename.startswith(startarchive):
context = pmapi.pmContext(c_pmapi.PM_CONTEXT_ARCHIVE, fname)
mdata = context.pmGetArchiveLabel()
begin = datetime.datetime.utcfromtimestamp(math.floor(mdata.start))
if filename.startswith(endarchive):
context = pmapi.pmContext(c_pmapi.PM_CONTEXT_ARCHIVE, fname)
end = datetime.datetime.utcfromtimestamp(math.ceil(context.pmGetArchiveEnd()))
job.setnodebeginend(nodename, begin, end)
评论列表
文章目录