Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk): Update sdk comments #1128

Merged
merged 2 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions sdk/python/kfp_tekton/compiler/_tekton_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,24 @@ def process_inline_cr_field(field_name):


def find_ancestors(nested_custom_tasks: list, father_ct_name, ancestors: list, root_ct):
""" Finds the ancestors of a nested custom task.

Parameters
----------
nested_custom_tasks : list
A list of dictionaries, each dictionary containing the name of a nested custom task and the name of its father custom task.
father_ct_name : str
The name of the father custom task.
ancestors : list
A list of the ancestors of the nested custom task.
root_ct : str
The name of the root custom task.

Returns
-------
relationship : dict
A dictionary containing the ancestors of the nested custom task and the name of the root custom task.
"""
relationship = {'ancestors': ancestors, 'root_ct': root_ct}
for custom_task in nested_custom_tasks:
if father_ct_name == custom_task['nested_custom_task']:
Expand Down
19 changes: 18 additions & 1 deletion sdk/python/kfp_tekton/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ def input_helper(custom_task, sub_group, param_list):
})

def process_pipelineparam(s):
"""
This function takes a string and replaces all instances of {{pipelineparam:op=<op_name>;name=<param_name>}}
with the appropriate value.

If op_name is empty, then the value of the parameter is taken from the pipeline parameters.
If op_name is not empty, then the value of the parameter is taken from the results of the operation.

The parameter name is sanitized to be a valid Kubernetes name.
"""
if "{{pipelineparam" in s:
pipe_params = re.findall(r"{{pipelineparam:op=([^ \t\n,]*);name=([^ \t\n,]*)}}", s)
for pipe_param in pipe_params:
Expand Down Expand Up @@ -880,7 +889,15 @@ def _get_inputs_outputs_recursive_opsgroup(group):
return inputs, outputs

def _process_resourceOp(self, task_refs, pipeline):
""" handle resourceOp cases in pipeline """
"""
This function is used to handle resourceOp cases in pipeline.
It will add the action, merge_strategy, success_condition, failure_condition, set_owner_reference, output to the task params.
Args:
task_refs: the task_refs in pipeline.
pipeline: the pipeline object
Returns:
None
"""
for task in task_refs:
op = pipeline.ops.get(task['name'])
if isinstance(op, dsl.ResourceOp):
Expand Down
16 changes: 16 additions & 0 deletions sdk/python/kfp_tekton/k8s_client_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@


def env_from_secret(env_name, secret_name, secret_key):
""" Creates a V1EnvVar object from a secret.

Parameters
----------
env_name : str
The name of the environment variable.
secret_name : str
The name of the secret.
secret_key : str
The key of the secret.

Returns
-------
V1EnvVar
A V1EnvVar object.
"""
return k8s_client.V1EnvVar(
name=env_name,
value_from=k8s_client.V1EnvVarSource(
Expand Down