def __init__( self, name, image, command, source, env=None, secret=None, resources=None, image_pull_policy=None, retry=None, timeout=None, pool=None, daemon=False, ): Template.__init__( self, name=name, timeout=timeout, retry=retry, pool=pool, daemon=daemon, ) self.image = image self.command = "python" if command is None else command self.source = source self.env = env self.secret = secret self.resources = resources self.image_pull_policy = image_pull_policy
def __init__( self, name, args, action, manifest, set_owner_reference, success_condition, failure_condition, timeout=None, retry=None, pool=None, cache=None, ): Template.__init__( self, name=name, timeout=timeout, retry=retry, pool=pool, cache=cache, ) self.args = args self.action = action self.manifest = manifest self.set_owner_reference = utils.bool_to_str(set_owner_reference) self.success_condition = success_condition self.failure_condition = failure_condition
def __init__( self, name, image, command, args=None, env=None, env_from=None, secret=None, resources=None, image_pull_policy=None, retry=None, timeout=None, pool=None, output=None, input=None, enable_ulogfs=True, daemon=False, volume_mounts=None, working_dir=None, node_selector=None, volumes=None, cache=None, parallelism=None, ): Template.__init__( self, name=name, output=utils.make_list_if_not(output), input=utils.make_list_if_not(input), timeout=timeout, retry=retry, pool=pool, enable_ulogfs=enable_ulogfs, daemon=daemon, cache=cache, parallelism=parallelism, ) self.image = image self.command = utils.make_list_if_not(command) self.args = args self.env = env self.env_from = env_from self.secret = secret self.resources = resources self.image_pull_policy = image_pull_policy self.volume_mounts = volume_mounts self.working_dir = working_dir self.node_selector = node_selector self.volumes = volumes
def to_dict(self): template = Template.to_dict(self) if utils.non_empty(self.args): template["inputs"] = {"parameters": self.args} template["resource"] = self.resource_dict() # Append outputs to this template # return the resource job name, job ID, and job object by default job_outputs = [ OrderedDict({ "name": "job-name", "valueFrom": { "jsonPath": '"{.metadata.name}"' }, }), OrderedDict({ "name": "job-id", "valueFrom": { "jsonPath": '"{.metadata.uid}"' }, }), OrderedDict({ "name": "job-obj", "valueFrom": { "jqFilter": '"."' } }), ] template["outputs"] = {"parameters": job_outputs} return template
def to_dict(self): template = Template.to_dict(self) if not utils.gpu_requested(self.resources): if self.env is None: self.env = {} self.env.update(OVERWRITE_GPU_ENVS) template["script"] = self.script_dict() return template
def to_dict(self): template = Template.to_dict(self) if (not utils.gpu_requested(self.resources) and states._overwrite_nvidia_gpu_envs): if self.env is None: self.env = {} self.env.update(OVERWRITE_GPU_ENVS) template["script"] = self.script_dict() return template
def __init__( self, name, image, command, args=None, env=None, secret=None, resources=None, image_pull_policy=None, retry=None, timeout=None, pool=None, output=None, input=None, enable_ulogfs=True, daemon=False, volume_mounts=None, ): Template.__init__( self, name=name, output=utils.make_list_if_not(output), input=utils.make_list_if_not(input), timeout=timeout, retry=retry, pool=pool, enable_ulogfs=enable_ulogfs, daemon=daemon, ) self.image = image self.command = utils.make_list_if_not(command) self.args = args self.env = env self.secret = secret self.resources = resources self.image_pull_policy = image_pull_policy self.volume_mounts = volume_mounts
def __init__( self, name, args, action, manifest, set_owner_reference, success_condition, failure_condition, timeout=None, retry=None, pool=None, ): Template.__init__(self, name=name, timeout=timeout, retry=retry, pool=pool) self.args = args self.action = action self.manifest = manifest self.set_owner_reference = "true" if set_owner_reference else "false" self.success_condition = success_condition self.failure_condition = failure_condition
def to_dict(self): template = Template.to_dict(self) template["steps"] = self.steps return template
def __init__(self, name, steps=None): Template.__init__(self, name=name) self.steps = steps
def to_dict(self): template = Template.to_dict(self) # Inputs parameters = [] if self.args is not None: i = 0 for arg in self.args: if not isinstance(self.args[i], OutputArtifact): if isinstance(arg, OutputJob): for _ in range(3): parameters.append({ "name": utils.input_parameter_name(self.name, i) }) i += 1 else: para_name = utils.input_parameter_name(self.name, i) parameters.append({"name": para_name}) i += 1 # Input # Case 1: add the input parameter if len(parameters) > 0: template["inputs"] = OrderedDict() template["inputs"]["parameters"] = parameters # Case 2: add the input artifact if self.input is not None: _input_list = [] for o in self.input: if isinstance(o, TypedArtifact): _input_list.append(o.to_yaml()) if isinstance(o, OutputArtifact): name = o.artifact["name"] if not any(name == x["name"] for x in _input_list): _input_list.append(o.artifact) if len(_input_list) > 0: if "inputs" not in template: template["inputs"] = OrderedDict() template["inputs"]["artifacts"] = _input_list # Node selector if self.node_selector is not None: # TODO: Support inferring node selector values from Argo parameters template["nodeSelector"] = self.node_selector # Container if (not utils.gpu_requested(self.resources) and states._overwrite_nvidia_gpu_envs): if self.env is None: self.env = {} self.env.update(OVERWRITE_GPU_ENVS) template["container"] = self.container_dict() # Output if self.output is not None: _output_list = [] for o in self.output: _output_list.append(o.to_yaml()) if isinstance(o, TypedArtifact): # Require only one kind of output type template["outputs"] = {"artifacts": _output_list} else: template["outputs"] = {"parameters": _output_list} # Volume if self.volume_mounts is not None: if self.volumes is None: template["volumes"] = [] for volume_mount in self.volume_mounts: template["volumes"].append({ "name": volume_mount.name, "emptyDir": {} }) return template
def to_dict(self): template = Template.to_dict(self) # Inputs parameters = [] if self.args is not None: i = 0 for arg in self.args: if not isinstance(self.args[i], OutputArtifact): if isinstance(arg, OutputJob): for _ in range(3): parameters.append({ "name": utils.input_parameter_name(self.name, i) }) i += 1 else: para_name = utils.input_parameter_name(self.name, i) parameters.append({"name": para_name}) i += 1 # Input # Case 1: add the input parameter if len(parameters) > 0: template["inputs"] = OrderedDict() template["inputs"]["parameters"] = parameters # Case 2: add the input artifact if self.input is not None: _input_list = [] for o in self.input: if isinstance(o, TypedArtifact): _input_list.append(o.to_yaml()) if isinstance(o, OutputArtifact): _input_list.append(o.artifact) if len(_input_list) > 0: if "inputs" not in template: template["inputs"] = OrderedDict() template["inputs"]["artifacts"] = _input_list # Container if not utils.gpu_requested(self.resources): if self.env is None: self.env = {} self.env.update(OVERWRITE_GPU_ENVS) template["container"] = self.container_dict() # Output if self.output is not None: _output_list = [] for o in self.output: _output_list.append(o.to_yaml()) if isinstance(o, TypedArtifact): # Require only one kind of output type template["outputs"] = {"artifacts": _output_list} else: template["outputs"] = {"parameters": _output_list} return template