本文整理汇总了Python中JobManager.create方法的典型用法代码示例。如果您正苦于以下问题:Python JobManager.create方法的具体用法?Python JobManager.create怎么用?Python JobManager.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobManager
的用法示例。
在下文中一共展示了JobManager.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import create [as 别名]
def run(self):
interrupted = False
corrupted_job_regex = re.compile("Output files for job (\d+) seems corrupted")
email = Config.get().get()["email"]
try:
while True:
if not Utils.is_proxy_valid():
Utils.delegate_proxy(self.verbose)
self.status()
get_id = []
kill_id = []
submit_id = []
resubmit_id = []
force_resubmit_id = []
corrupted_id = []
n_waiting = 0
n_running = 0
for (id, job) in self.jobs.items():
status = JobManager.create(job)
if status.gettable():
get_id.append(str(id))
if status.killable():
kill_id.append(str(id))
if status.submittable():
submit_id.append(str(id))
if status.failed():
resubmit_id.append(str(id))
if status.running():
n_running = n_running + 1
if status.waiting():
n_waiting = n_waiting + 1
job._status = status
if self.verbose:
if len(get_id) > 0:
print("I'll get jobs " + ",".join(get_id))
else:
print("No job to get output for")
if len(kill_id) > 0:
print("I'll kill jobs " + ",".join(kill_id))
else:
print("No job to kill")
if len(resubmit_id) > 0:
print("I'll resubmit jobs " + ",".join(resubmit_id))
else:
print("No job to resubmit")
print("")
self.dump()
log = ""
if not self.dry_run:
if len(get_id) > 0:
if self.verbose:
print("Retrieving jobs...")
(output, returncode) = Utils.runCrab("get", ",".join(get_id), self.folder)
log += "crab -get output:\n"
log += "".join(output)
log += "\n"
# Detect corrupted jobs
lines = output
for line in lines:
matches = re.search(corrupted_job_regex, line)
if matches is not None:
corrupted_id.append(str(matches.group(1)))
if len(corrupted_id) > 0:
if self.verbose:
print("Some jobs are corrupted: " + ",".join(corrupted_id))
kill_id.extend(corrupted_id)
kill_id.sort()
force_resubmit_id.extend(corrupted_id)
force_resubmit_id.sort()
if len(kill_id) > 0:
if self.verbose:
print("Killing jobs...")
(output, returncode) = Utils.runCrab("kill", ",".join(kill_id), self.folder)
log += "crab -kill output:\n"
log += "".join(output)
log += "\n"
if len(submit_id) > 0:
# Crab only accept a maximum of 500 jobs on submit.
splitted_submit_ids = chunks(submit_id, 500)
#.........这里部分代码省略.........