shutil.copyfile(def_file, task_file)
else:
// add server restriction on task file
with open(def_file, "rb") as task:
params = pickle.load(task)
task_vars = params.data[1]
task_vars["_runtime"]["max_mem"] = self.config.get("max_mem", None)
task_vars["_runtime"]["max_cores"] = self.config.get("max_cores", None)
task_vars["_runtime"]["max_walltime"] = self.config.get("max_walltime", None)
if task_vars["_runtime"]["max_walltime"] is not None:
task_vars["_runtime"]["max_walltime"] = format_HHMMSS(task_vars["_runtime"]["max_walltime"])
if self.config.get("max_mem", None) is not None and task_vars["_runtime"].get("mem", None) is not None \
and self.config["max_mem"] < task_vars["_runtime"]["mem"]:
raise ValueError("Task {} requested more mem ({}) than allowed max_mem ({})".format(
task_id, task_vars["_runtime"]["mem"], self.config["max_mem"]))
if self.config.get("max_cores", None) is not None and task_vars["_runtime"].get("cores", None) is not None \
and self.config["max_cores"] < task_vars["_runtime"]["cores"]:
raise ValueError("Task {} requested more cores ({}) than allowed max_cores ({})".format(
task_id, task_vars["_runtime"]["cores"], self.config["max_cores"]))
if self.config.get("max_walltime", None) is not None and task_vars["_runtime"].get("walltime", None) is not None \
and expand_time(self.config["max_walltime"]) < expand_time(task_vars["_runtime"]["walltime"]):
raise ValueError("Task {} requested more walltime ({}) than allowed max_walltime ({})".format(
task_id, task_vars["_runtime"]["walltime"], self.config["max_walltime"]))
new_param = TaskParams(
name = params.name,
data = (
params.data[0],
task_vars,
params.data[2],
)
)
with open(task_file, "wb") as jf:
After Change
shutil.copyfile(def_file, task_file)
else:
// add server restriction on task file
params = loadTask(def_file)
task_vars = params.sos_dict
task_vars["_runtime"]["max_mem"] = self.config.get("max_mem", None)
task_vars["_runtime"]["max_cores"] = self.config.get("max_cores", None)
task_vars["_runtime"]["max_walltime"] = self.config.get("max_walltime", None)
if task_vars["_runtime"]["max_walltime"] is not None:
task_vars["_runtime"]["max_walltime"] = format_HHMMSS(task_vars["_runtime"]["max_walltime"])
if self.config.get("max_mem", None) is not None and task_vars["_runtime"].get("mem", None) is not None \
and self.config["max_mem"] < task_vars["_runtime"]["mem"]:
raise ValueError("Task {} requested more mem ({}) than allowed max_mem ({})".format(
task_id, task_vars["_runtime"]["mem"], self.config["max_mem"]))
if self.config.get("max_cores", None) is not None and task_vars["_runtime"].get("cores", None) is not None \
and self.config["max_cores"] < task_vars["_runtime"]["cores"]:
raise ValueError("Task {} requested more cores ({}) than allowed max_cores ({})".format(
task_id, task_vars["_runtime"]["cores"], self.config["max_cores"]))
if self.config.get("max_walltime", None) is not None and task_vars["_runtime"].get("walltime", None) is not None \
and expand_time(self.config["max_walltime"]) < expand_time(task_vars["_runtime"]["walltime"]):
raise ValueError("Task {} requested more walltime ({}) than allowed max_walltime ({})".format(
task_id, task_vars["_runtime"]["walltime"], self.config["max_walltime"]))
new_param = TaskParams(
name = params.name,
task = params.task,
sos_dict = params.sos_dict,
sigil = params.sigil
)
new_param.save(task_file)
return True