def create_job_groups(self, batch_jobs): # Subtle: in order to support dynamic batch jobs, we need to remove the # job_submission group and replace with job-based groups orig_group = self.get_child( "group", {"id": "job_submission"}, err_msg="Looks like job groups have already been created") orig_group_children = EnvBase.get_children(self, root=orig_group, no_validate=True) childnodes = [] for child in reversed(orig_group_children): childnodes.append(self.copy(child)) self.remove_child(orig_group) for name, jdict in batch_jobs: new_job_group = self.make_child("group", {"id": name}) for field in jdict.keys(): val = jdict[field] node = self.make_child("entry", { "id": field, "value": val }, root=new_job_group) self.make_child("type", root=node, text="char") for child in childnodes: self.add_child(child, root=new_job_group)
def get_children(self, name=None, attributes=None, root=None): if name in ("JOB_WALLCLOCK_TIME", "PROJECT", "CHARGE_ACCOUNT", "PROJECT_REQUIRED", "JOB_QUEUE", "BATCH_COMMAND_FLAGS"): nodes = EnvBase.get_children(self, "entry", attributes={"id":name}, root=root) else: nodes = EnvBase.scan_children(self, name, attributes=attributes, root=root) return nodes
def create_job_groups(self, batch_jobs): # Subtle: in order to support dynamic batch jobs, we need to remove the # job_submission group and replace with job-based groups orig_group = self.get_child("group", {"id":"job_submission"}, err_msg="Looks like job groups have already been created") orig_group_children = EnvBase.get_children(self, root=orig_group) childnodes = [] for child in reversed(orig_group_children): childnodes.append(child) self.remove_child(orig_group) for name, jdict in batch_jobs: new_job_group = self.make_child("group", {"id":name}) for field in jdict.keys(): val = jdict[field] node = self.make_child("entry", {"id":field,"value":val}, root=new_job_group) self.make_child("type", root=node, text="char") for child in childnodes: self.add_child(self.copy(child), root=new_job_group)