code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def comp(
string: str,
in_artifact: Input[Artifact],
out_artifact: Output[Artifact],
) -> str:
"""Return Component Returns description.
Args:
string: Component Return input string.
in_artifact: Component Returns input a... | Return Component Returns description.
Args:
string: Component Return input string.
in_artifact: Component Returns input artifact.
Returns:
Output: Component output string.
out_artifact: Component output artifact.
| comp | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def my_pipeline(
string: str,
in_artifact: Input[Artifact],
) -> Outputs:
"""Pipeline description. Returns
Args:
string: Return Pipeline input string. Returns
in_artifact: Pipeline input Return artifact.
Returns:
... | Pipeline description. Returns
Args:
string: Return Pipeline input string. Returns
in_artifact: Pipeline input Return artifact.
Returns:
out_str: Pipeline output string.
out_artifact: Pipeline output artifact.
| my_pipeline | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_if_else_returned(self):
"""Uses If and Else branches, parameters passed to dsl.OneOf, dsl.OneOf returned from a pipeline, and different output keys on dsl.OneOf channels."""
@dsl.pipeline
def roll_die_pipeline() -> str:
flip_coin_task = flip_coin()
with dsl.If(f... | Uses If and Else branches, parameters passed to dsl.OneOf, dsl.OneOf returned from a pipeline, and different output keys on dsl.OneOf channels. | test_if_else_returned | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_if_elif_else_returned(self):
"""Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, dsl.OneOf returned from a pipeline, and different output keys on dsl.OneOf channels."""
@dsl.pipeline
def roll_die_pipeline() -> str:
flip_coin_task = roll_three_sided_die()
... | Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, dsl.OneOf returned from a pipeline, and different output keys on dsl.OneOf channels. | test_if_elif_else_returned | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_if_elif_else_consumed(self):
"""Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, dsl.OneOf passed to a consumer task, and different output keys on dsl.OneOf channels."""
@dsl.pipeline
def roll_die_pipeline():
flip_coin_task = roll_three_sided_die()
... | Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, dsl.OneOf passed to a consumer task, and different output keys on dsl.OneOf channels. | test_if_elif_else_consumed | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_if_else_consumed_and_returned(self):
"""Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, and dsl.OneOf passed to a consumer task and returned from the pipeline."""
@dsl.pipeline
def flip_coin_pipeline() -> str:
flip_coin_task = flip_coin()
with ... | Uses If, Elif, and Else branches, parameters passed to dsl.OneOf, and dsl.OneOf passed to a consumer task and returned from the pipeline. | test_if_else_consumed_and_returned | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_if_else_consumed_and_returned_artifacts(self):
"""Uses If, Elif, and Else branches, artifacts passed to dsl.OneOf, and dsl.OneOf passed to a consumer task and returned from the pipeline."""
@dsl.pipeline
def flip_coin_pipeline() -> Artifact:
flip_coin_task = flip_coin()
... | Uses If, Elif, and Else branches, artifacts passed to dsl.OneOf, and dsl.OneOf passed to a consumer task and returned from the pipeline. | test_if_else_consumed_and_returned_artifacts | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_nested_under_condition_consumed(self):
"""Uses If, Else, and OneOf nested under a parent If."""
@dsl.pipeline
def flip_coin_pipeline(execute_pipeline: bool):
with dsl.If(execute_pipeline == True):
flip_coin_task = flip_coin()
with dsl.If(flip... | Uses If, Else, and OneOf nested under a parent If. | test_nested_under_condition_consumed | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_deeply_nested_consumed(self):
"""Uses If, Elif, Else, and OneOf deeply nested within multiple dub-DAGs."""
@dsl.pipeline
def flip_coin_pipeline(execute_pipeline: bool):
with dsl.ExitHandler(cleanup()):
with dsl.ParallelFor([1, 2, 3]):
wit... | Uses If, Elif, Else, and OneOf deeply nested within multiple dub-DAGs. | test_deeply_nested_consumed | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_oneof_in_condition(self):
"""Tests that dsl.OneOf's channel can be consumed in a downstream group nested one level"""
@dsl.pipeline
def roll_die_pipeline(repeat_on: str = 'Got heads!'):
flip_coin_task = roll_three_sided_die()
with dsl.If(flip_coin_task.output ==... | Tests that dsl.OneOf's channel can be consumed in a downstream group nested one level | test_oneof_in_condition | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def test_consumed_in_nested_groups(self):
"""Tests that dsl.OneOf's channel can be consumed in a downstream group nested multiple levels"""
@dsl.pipeline
def roll_die_pipeline(
repeat: bool = True,
rounds: List[str] = ['a', 'b', 'c'],
):
flip_coin_tas... | Tests that dsl.OneOf's channel can be consumed in a downstream group nested multiple levels | test_consumed_in_nested_groups | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_test.py | Apache-2.0 |
def additional_input_name_for_pipeline_channel(
channel_or_name: Union[pipeline_channel.PipelineChannel, str]) -> str:
"""Gets the name for an additional (compiler-injected) input."""
# Adding a prefix to avoid (reduce chance of) name collision between the
# original component inputs and the inject... | Gets the name for an additional (compiler-injected) input. | additional_input_name_for_pipeline_channel | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_all_groups(
root_group: tasks_group.TasksGroup,) -> List[tasks_group.TasksGroup]:
"""Gets all groups (not including tasks) in a pipeline.
Args:
root_group: The root group of a pipeline.
Returns:
A list of all groups in topological order (parent first).
"""
all_groups = ... | Gets all groups (not including tasks) in a pipeline.
Args:
root_group: The root group of a pipeline.
Returns:
A list of all groups in topological order (parent first).
| get_all_groups | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_parent_groups(
root_group: tasks_group.TasksGroup,
) -> Tuple[Mapping[str, List[str]], Mapping[str, List[str]]]:
"""Get parent groups that contain the specified tasks.
Each pipeline has a root group. Each group has a list of tasks (leaf)
and groups.
This function traverse the tree and get a... | Get parent groups that contain the specified tasks.
Each pipeline has a root group. Each group has a list of tasks (leaf)
and groups.
This function traverse the tree and get ancestor groups for all tasks.
Args:
root_group: The root group of a pipeline.
Returns:
A tuple. The first ... | get_parent_groups | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_channels_from_condition(
operations: List[pipeline_channel.ConditionOperation],
collected_channels: list,
) -> None:
"""Appends to collected_channels each pipeline channels used in each
operand of each operation in operations."""
for operation in operations:
for operand in [operation... | Appends to collected_channels each pipeline channels used in each
operand of each operation in operations. | get_channels_from_condition | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_condition_channels_for_tasks(
root_group: tasks_group.TasksGroup,
) -> Mapping[str, Set[pipeline_channel.PipelineChannel]]:
"""Gets channels referenced in conditions of tasks' parents.
Args:
root_group: The root group of a pipeline.
Returns:
A mapping of task name to a set of p... | Gets channels referenced in conditions of tasks' parents.
Args:
root_group: The root group of a pipeline.
Returns:
A mapping of task name to a set of pipeline channels appeared in its
parent dsl.Condition groups.
| get_condition_channels_for_tasks | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_inputs_for_all_groups(
pipeline: pipeline_context.Pipeline,
task_name_to_parent_groups: Mapping[str, List[str]],
group_name_to_parent_groups: Mapping[str, List[str]],
condition_channels: Mapping[str,
Set[pipeline_channel.PipelineParameterChannel]],
name_to_for... | Get inputs and outputs of each group and op.
Args:
pipeline: The instantiated pipeline object.
task_name_to_parent_groups: The dict of task name to list of parent
groups.
group_name_to_parent_groups: The dict of group name to list of
parent groups.
condition_... | get_inputs_for_all_groups | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def validate_parallel_for_fan_in_consumption_legal(
consumer_task_name: str,
upstream_groups: List[str],
group_name_to_group: Dict[str, tasks_group.TasksGroup],
) -> None:
"""Checks that a dsl.Collected object is being used results in an
unambiguous pipeline topology and is therefore legal.
Arg... | Checks that a dsl.Collected object is being used results in an
unambiguous pipeline topology and is therefore legal.
Args:
consumer_task_name: The name of the consumer task.
upstream_groups: The names of the producer task's upstream groups, ordered from outermost group at beginning to producer ... | validate_parallel_for_fan_in_consumption_legal | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def make_new_channel_for_collected_outputs(
channel_name: str,
starting_channel: pipeline_channel.PipelineChannel,
task_name: str,
) -> pipeline_channel.PipelineChannel:
"""Creates a new PipelineParameterChannel/PipelineArtifactChannel list for
a dsl.Collected channel from the original task output."... | Creates a new PipelineParameterChannel/PipelineArtifactChannel list for
a dsl.Collected channel from the original task output. | make_new_channel_for_collected_outputs | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_outputs_for_all_groups(
pipeline: pipeline_context.Pipeline,
task_name_to_parent_groups: Mapping[str, List[str]],
group_name_to_parent_groups: Mapping[str, List[str]],
all_groups: List[tasks_group.TasksGroup],
pipeline_outputs_dict: Dict[str, pipeline_channel.PipelineChannel]
) -> Tuple[Defa... | Gets a dictionary of all TasksGroup names to an inner dictionary. The
inner dictionary is TasksGroup output keys to channels corresponding to
those keys.
It constructs this dictionary from both data passing within the pipeline body, as well as the outputs returned from the pipeline (e.g., return dsl.Collec... | get_outputs_for_all_groups | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def _get_uncommon_ancestors(
task_name_to_parent_groups: Mapping[str, List[str]],
group_name_to_parent_groups: Mapping[str, List[str]],
task1: GroupOrTaskType,
task2: GroupOrTaskType,
) -> Tuple[List[str], List[str]]:
"""Gets the unique ancestors between two tasks.
For example, task1's ancestor... | Gets the unique ancestors between two tasks.
For example, task1's ancestor groups are [root, G1, G2, G3, task1],
task2's ancestor groups are [root, G1, G4, task2], then it returns a
tuple ([G2, G3, task1], [G4, task2]).
Args:
task_name_to_parent_groups: The dict of task name to list of parent
... | _get_uncommon_ancestors | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def get_dependencies(
pipeline: pipeline_context.Pipeline,
task_name_to_parent_groups: Mapping[str, List[str]],
group_name_to_parent_groups: Mapping[str, List[str]],
group_name_to_group: Mapping[str, tasks_group.TasksGroup],
condition_channels: Dict[str, pipeline_channel.PipelineChannel],
) -> Mappi... | Gets dependent groups and tasks for all tasks and groups.
Args:
pipeline: The instantiated pipeline object.
task_name_to_parent_groups: The dict of task name to list of parent
groups.
group_name_to_parent_groups: The dict of group name to list of
parent groups.
... | get_dependencies | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def recursive_replace_placeholders(data: Union[Dict, List], old_value: str,
new_value: str) -> Union[Dict, List]:
"""Recursively replaces values in a nested dict/list object.
This method is used to replace PipelineChannel objects with input parameter
placeholders in a nes... | Recursively replaces values in a nested dict/list object.
This method is used to replace PipelineChannel objects with input parameter
placeholders in a nested object like worker_pool_specs for custom jobs.
Args:
data: A nested object that can contain dictionaries and/or lists.
old_value: T... | recursive_replace_placeholders | python | kubeflow/pipelines | sdk/python/kfp/compiler/compiler_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/compiler_utils.py | Apache-2.0 |
def to_protobuf_value(value: type_utils.PARAMETER_TYPES) -> struct_pb2.Value:
"""Creates a google.protobuf.struct_pb2.Value message out of a provide
value.
Args:
value: The value to be converted to Value message.
Returns:
A google.protobuf.struct_pb2.Value message.
Raises:
... | Creates a google.protobuf.struct_pb2.Value message out of a provide
value.
Args:
value: The value to be converted to Value message.
Returns:
A google.protobuf.struct_pb2.Value message.
Raises:
ValueError if the given value is not one of the parameter types.
| to_protobuf_value | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_task_spec_for_task(
task: pipeline_task.PipelineTask,
parent_component_inputs: pipeline_spec_pb2.ComponentInputsSpec,
tasks_in_current_dag: List[str],
) -> pipeline_spec_pb2.PipelineTaskSpec:
"""Builds PipelineTaskSpec for a pipeline task.
A task input may reference an output outside its ... | Builds PipelineTaskSpec for a pipeline task.
A task input may reference an output outside its immediate DAG.
For instance::
random_num = random_num_op(...)
with dsl.Condition(random_num.output > 5):
print_op('%s > 5' % random_num.output)
In this example, `dsl.Condition` forms ... | build_task_spec_for_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_component_spec_for_exit_task(
task: pipeline_task.PipelineTask,) -> pipeline_spec_pb2.ComponentSpec:
"""Builds ComponentSpec for an exit task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A ComponentSpec object for the exit task.
"""
return build_compon... | Builds ComponentSpec for an exit task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A ComponentSpec object for the exit task.
| build_component_spec_for_exit_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_component_spec_for_task(
task: pipeline_task.PipelineTask,
is_compiled_component: bool,
is_exit_task: bool = False,
) -> pipeline_spec_pb2.ComponentSpec:
"""Builds ComponentSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
is_exit_task: Whether t... | Builds ComponentSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
is_exit_task: Whether the task is used as exit task in Exit Handler.
Returns:
A ComponentSpec object for the task.
| build_component_spec_for_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _build_component_spec_from_component_spec_structure(
component_spec_struct: structures.ComponentSpec
) -> pipeline_spec_pb2.ComponentSpec:
"""Builds ComponentSpec proto from ComponentSpec structure."""
component_spec = pipeline_spec_pb2.ComponentSpec()
for input_name, input_spec in (component_spec_... | Builds ComponentSpec proto from ComponentSpec structure. | _build_component_spec_from_component_spec_structure | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def connect_single_dag_output(
component_spec: pipeline_spec_pb2.ComponentSpec,
output_name: str,
output_channel: pipeline_channel.PipelineChannel,
) -> None:
"""Connects a DAG output to a subtask output when the subtask output
contains only one channel (i.e., not OneOfMixin).
Args:
com... | Connects a DAG output to a subtask output when the subtask output
contains only one channel (i.e., not OneOfMixin).
Args:
component_spec: The component spec to modify its dag outputs.
output_name: The name of the dag output.
output_channel: The pipeline channel selected for the dag outp... | connect_single_dag_output | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def connect_oneof_dag_output(
component_spec: pipeline_spec_pb2.ComponentSpec,
output_name: str,
oneof_output: pipeline_channel.OneOfMixin,
) -> None:
"""Connects a output to the OneOf output returned by the DAG's internal
condition-branches group.
Args:
component_spec: The component sp... | Connects a output to the OneOf output returned by the DAG's internal
condition-branches group.
Args:
component_spec: The component spec to modify its DAG outputs.
output_name: The name of the DAG output.
oneof_output: The OneOfMixin object returned by the pipeline (OneOf in user code).
... | connect_oneof_dag_output | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _build_dag_outputs(
component_spec: pipeline_spec_pb2.ComponentSpec,
dag_outputs: Dict[str, pipeline_channel.PipelineChannel],
) -> None:
"""Connects the DAG's outputs to a TaskGroup's ComponentSpec and validates
it is present in the component interface.
Args:
component_spec: The Compon... | Connects the DAG's outputs to a TaskGroup's ComponentSpec and validates
it is present in the component interface.
Args:
component_spec: The ComponentSpec.
dag_outputs: Dictionary of output key to output channel.
| _build_dag_outputs | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def validate_dag_outputs(
component_spec: pipeline_spec_pb2.ComponentSpec) -> None:
"""Validates the DAG's ComponentSpec specifies the source task for all of
its ComponentSpec inputs (input_definitions) and outputs
(output_definitions)."""
for output_name in component_spec.output_definitions.art... | Validates the DAG's ComponentSpec specifies the source task for all of
its ComponentSpec inputs (input_definitions) and outputs
(output_definitions). | validate_dag_outputs | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_oneof_dag_outputs(
component_spec: pipeline_spec_pb2.ComponentSpec,
oneof_outputs: Dict[str, pipeline_channel.OneOfMixin],
) -> None:
"""Connects the DAG's OneOf outputs to a TaskGroup's ComponentSpec and
validates it is present in the component interface.
Args:
component_spec: Th... | Connects the DAG's OneOf outputs to a TaskGroup's ComponentSpec and
validates it is present in the component interface.
Args:
component_spec: The ComponentSpec.
oneof_outputs: Dictionary of output key to OneOf output channel.
| build_oneof_dag_outputs | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_importer_spec_for_task(
task: pipeline_task.PipelineTask
) -> pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec:
"""Builds ImporterSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A ImporterSpec object for the task.
"""
type_... | Builds ImporterSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A ImporterSpec object for the task.
| build_importer_spec_for_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_container_spec_for_task(
task: pipeline_task.PipelineTask
) -> pipeline_spec_pb2.PipelineDeploymentConfig.PipelineContainerSpec:
"""Builds PipelineContainerSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A PipelineContainerSpec object for... | Builds PipelineContainerSpec for a pipeline task.
Args:
task: The task to build a ComponentSpec for.
Returns:
A PipelineContainerSpec object for the task.
| build_container_spec_for_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def convert_to_placeholder(input_value: str) -> str:
"""Checks if input is a pipeline channel and if so, converts to
compiler injected input name."""
pipeline_channels = (
pipeline_channel.extract_pipeline_channels_from_any(input_value))
if pipeline_channels:
asse... | Checks if input is a pipeline channel and if so, converts to
compiler injected input name. | convert_to_placeholder | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _fill_in_component_input_default_value(
component_spec: pipeline_spec_pb2.ComponentSpec,
input_name: str,
default_value: Optional[type_utils.PARAMETER_TYPES],
) -> None:
"""Fills in the default of component input parameter.
Args:
component_spec: The ComponentSpec to update in place.
... | Fills in the default of component input parameter.
Args:
component_spec: The ComponentSpec to update in place.
input_name: The name of the input parameter.
default_value: The default value of the input parameter.
| _fill_in_component_input_default_value | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_component_spec_for_group(
input_pipeline_channels: List[pipeline_channel.PipelineChannel],
output_pipeline_channels: Dict[str, pipeline_channel.PipelineChannel],
) -> pipeline_spec_pb2.ComponentSpec:
"""Builds ComponentSpec for a TasksGroup.
Args:
group: The group to build a Component... | Builds ComponentSpec for a TasksGroup.
Args:
group: The group to build a ComponentSpec for.
pipeline_channels: The list of pipeline channels referenced by the group.
Returns:
A PipelineTaskSpec object representing the loop group.
| build_component_spec_for_group | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _pop_input_from_task_spec(
task_spec: pipeline_spec_pb2.PipelineTaskSpec,
input_name: str,
) -> None:
"""Removes an input from task spec inputs.
Args:
task_spec: The pipeline task spec to update in place.
input_name: The name of the input, which could be an artifact or paremeter.
""... | Removes an input from task spec inputs.
Args:
task_spec: The pipeline task spec to update in place.
input_name: The name of the input, which could be an artifact or paremeter.
| _pop_input_from_task_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _update_task_spec_for_loop_group(
group: tasks_group.ParallelFor,
pipeline_task_spec: pipeline_spec_pb2.PipelineTaskSpec,
) -> None:
"""Updates PipelineTaskSpec for loop group.
Args:
group: The loop group to update task spec for.
pipeline_task_spec: The pipeline task spec to update ... | Updates PipelineTaskSpec for loop group.
Args:
group: The loop group to update task spec for.
pipeline_task_spec: The pipeline task spec to update in place.
| _update_task_spec_for_loop_group | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _binary_operations_to_cel_conjunctive(
operations: List[pipeline_channel.ConditionOperation]) -> str:
"""Converts a list of ConditionOperation to a CEL string with placeholders.
Each ConditionOperation will be joined the others via the conjunctive (&&).
Args:
operations: The binary oper... | Converts a list of ConditionOperation to a CEL string with placeholders.
Each ConditionOperation will be joined the others via the conjunctive (&&).
Args:
operations: The binary operations to convert to convert and join.
Returns:
The binary operations as a CEL string.
| _binary_operations_to_cel_conjunctive | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _single_binary_operation_to_cel_condition(
operation: pipeline_channel.ConditionOperation) -> str:
"""Converts a ConditionOperation to a CEL string with placeholders.
Args:
operation: The binary operation to convert to a string.
Returns:
The binary operation as a CEL string.
... | Converts a ConditionOperation to a CEL string with placeholders.
Args:
operation: The binary operation to convert to a string.
Returns:
The binary operation as a CEL string.
| _single_binary_operation_to_cel_condition | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _update_task_spec_for_condition_group(
group: tasks_group._ConditionBase,
pipeline_task_spec: pipeline_spec_pb2.PipelineTaskSpec,
) -> None:
"""Updates PipelineTaskSpec for condition group.
Args:
group: The condition group to update task spec for.
pipeline_task_spec: The pipeline ta... | Updates PipelineTaskSpec for condition group.
Args:
group: The condition group to update task spec for.
pipeline_task_spec: The pipeline task spec to update in place.
| _update_task_spec_for_condition_group | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_task_spec_for_exit_task(
task: pipeline_task.PipelineTask,
dependent_task: str,
pipeline_inputs: pipeline_spec_pb2.ComponentInputsSpec,
) -> pipeline_spec_pb2.PipelineTaskSpec:
"""Builds PipelineTaskSpec for an exit handler's exit task.
Args:
tasks: The exit handler's exit task to... | Builds PipelineTaskSpec for an exit handler's exit task.
Args:
tasks: The exit handler's exit task to build task spec for.
dependent_task: The dependent task name for the exit task, i.e. the name
of the exit handler group.
pipeline_inputs: The pipeline level input definitions.
... | build_task_spec_for_exit_task | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_task_spec_for_group(
group: tasks_group.TasksGroup,
pipeline_channels: List[pipeline_channel.PipelineChannel],
tasks_in_current_dag: List[str],
is_parent_component_root: bool,
) -> pipeline_spec_pb2.PipelineTaskSpec:
"""Builds PipelineTaskSpec for a group.
Args:
group: The gro... | Builds PipelineTaskSpec for a group.
Args:
group: The group to build PipelineTaskSpec for.
pipeline_channels: The list of pipeline channels referenced by the group.
tasks_in_current_dag: The list of tasks names for tasks in the same dag.
is_parent_component_root: Whether the parent ... | build_task_spec_for_group | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def modify_pipeline_spec_with_override(
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
pipeline_name: Optional[str],
pipeline_parameters: Optional[Mapping[str, Any]],
) -> pipeline_spec_pb2.PipelineSpec:
"""Modifies the PipelineSpec using arguments passed to the Compiler.compile
method.
Args:
... | Modifies the PipelineSpec using arguments passed to the Compiler.compile
method.
Args:
pipeline_spec (pipeline_spec_pb2.PipelineSpec): PipelineSpec to modify.
pipeline_name (Optional[str]): Name of the pipeline. Overrides component name.
pipeline_parameters (Optional[Mapping[str, Any]])... | modify_pipeline_spec_with_override | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def build_spec_by_group(
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
deployment_config: pipeline_spec_pb2.PipelineDeploymentConfig,
group: tasks_group.TasksGroup,
inputs: Mapping[str, List[Tuple[pipeline_channel.PipelineChannel, str]]],
outputs: DefaultDict[str, Dict[str, pipeline_channel.Pipelin... | Generates IR spec given a TasksGroup.
Args:
pipeline_spec: The pipeline_spec to update in place.
deployment_config: The deployment_config to hold all executors. The
spec is updated in place.
group: The TasksGroup to generate spec for.
inputs: The inputs dictionary. The k... | build_spec_by_group | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def platform_config_to_platform_spec(
platform_config: dict,
executor_label: str,
) -> pipeline_spec_pb2.PlatformSpec:
"""Converts a single task's pipeline_task.platform_config dictionary to a
PlatformSpec message using the executor_label for the task."""
platform_spec_msg = pipeline_spec_pb2.Platfo... | Converts a single task's pipeline_task.platform_config dictionary to a
PlatformSpec message using the executor_label for the task. | platform_config_to_platform_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def merge_platform_specs(
main_msg: pipeline_spec_pb2.PlatformSpec,
sub_msg: pipeline_spec_pb2.PlatformSpec,
) -> None:
"""Merges a sub_msg PlatformSpec into the main_msg PlatformSpec, leaving
the sub_msg unchanged."""
for platform_key, single_platform_spec in sub_msg.platforms.items():
merg... | Merges a sub_msg PlatformSpec into the main_msg PlatformSpec, leaving
the sub_msg unchanged. | merge_platform_specs | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def merge_platform_deployment_config(
main_msg: pipeline_spec_pb2.PlatformDeploymentConfig,
sub_msg: pipeline_spec_pb2.PlatformDeploymentConfig,
) -> None:
"""Merges a sub_msg PlatformDeploymentConfig into the main_msg
PlatformDeploymentConfig, leaving the sub_msg unchanged."""
for executor_label, a... | Merges a sub_msg PlatformDeploymentConfig into the main_msg
PlatformDeploymentConfig, leaving the sub_msg unchanged. | merge_platform_deployment_config | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def merge_deployment_spec_and_component_spec(
main_pipeline_spec: pipeline_spec_pb2.PipelineSpec,
main_deployment_config: pipeline_spec_pb2.PipelineDeploymentConfig,
sub_pipeline_spec: pipeline_spec_pb2.PipelineSpec,
main_platform_spec: pipeline_spec_pb2.PlatformSpec,
sub_platform_spec: pipeline_spe... | Merges deployment spec and component spec from a sub pipeline spec into
the main spec.
Also merges sub_platform_spec into main_platform_spec, with updated executor labels.
We need to make sure that we keep the original sub PipelineSpec and PlatformSpec
unchanged--in case the pipeline is reused (instan... | merge_deployment_spec_and_component_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _merge_deployment_spec(
main_deployment_config: pipeline_spec_pb2.PipelineDeploymentConfig,
sub_pipeline_spec: pipeline_spec_pb2.PipelineSpec,
main_platform_spec: pipeline_spec_pb2.PlatformSpec,
sub_platform_spec: pipeline_spec_pb2.PlatformSpec,
) -> None:
"""Merges deployment config from a sub ... | Merges deployment config from a sub pipeline spec into the main config.
During the merge we need to ensure all executor specs have unique executor
labels, that means we might need to update the `executor_label` referenced
from component specs in sub_pipeline_spec.
Args:
main_deployment_config:... | _merge_deployment_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _rename_executor_labels(
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
old_executor_label: str,
new_executor_label: str,
) -> None:
"""Renames the old executor_label to the new one in component spec."""
for _, component_spec in pipeline_spec.components.items():
... | Renames the old executor_label to the new one in component spec. | _rename_executor_labels | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _merge_component_spec(
main_pipeline_spec: pipeline_spec_pb2.PipelineSpec,
sub_pipeline_spec: pipeline_spec_pb2.PipelineSpec,
) -> None:
"""Merges component spec from a sub pipeline spec into the main config.
During the merge we need to ensure all component specs have a unique component
name, t... | Merges component spec from a sub pipeline spec into the main config.
During the merge we need to ensure all component specs have a unique component
name, that means we might need to update the `component_ref` referenced from
task specs in sub_pipeline_spec.
Uniqueness is determined by existing compone... | _merge_component_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def _rename_component_refs(
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
old_component_ref: str,
new_component_ref: str,
) -> None:
"""Renames the old component_ref to the new one in task spec."""
for _, component_spec in pipeline_spec.components.items():
if not... | Renames the old component_ref to the new one in task spec. | _rename_component_refs | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def create_pipeline_spec(
pipeline: pipeline_context.Pipeline,
component_spec: structures.ComponentSpec,
pipeline_outputs: Optional[Any] = None,
pipeline_config: pipeline_config.PipelineConfig = None,
) -> Tuple[pipeline_spec_pb2.PipelineSpec, pipeline_spec_pb2.PlatformSpec]:
"""Creates a pipeline s... | Creates a pipeline spec object.
Args:
pipeline: The instantiated pipeline object.
component_spec: The component spec structures.
pipeline_outputs: The pipeline outputs via return.
pipeline_config: The pipeline config object.
Returns:
A PipelineSpec proto representing th... | create_pipeline_spec | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def convert_pipeline_outputs_to_dict(
pipeline_outputs: Union[pipeline_channel.PipelineChannel, typing.NamedTuple,
None]
) -> Dict[str, pipeline_channel.PipelineChannel]:
"""Converts the outputs from a pipeline function into a dictionary of
output name to PipelineChannel."""
... | Converts the outputs from a pipeline function into a dictionary of
output name to PipelineChannel. | convert_pipeline_outputs_to_dict | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def write_pipeline_spec_to_file(
pipeline_spec: pipeline_spec_pb2.PipelineSpec,
pipeline_description: Union[str, None],
platform_spec: pipeline_spec_pb2.PlatformSpec,
package_path: str,
) -> None:
"""Writes PipelineSpec into a YAML or JSON (deprecated) file.
Args:
pipeline_spec: The Pip... | Writes PipelineSpec into a YAML or JSON (deprecated) file.
Args:
pipeline_spec: The PipelineSpec.
pipeline_description: Description from pipeline docstring.
package_path: The path to which to write the PipelineSpec.
platform_spec: The PlatformSpec.
| write_pipeline_spec_to_file | python | kubeflow/pipelines | sdk/python/kfp/compiler/pipeline_spec_builder.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/pipeline_spec_builder.py | Apache-2.0 |
def test(
self,
name: str,
test_case: str,
test_data_dir: str,
function: str,
read: bool,
write: bool,
):
"""Tests serialization and deserialization consistency and correctness.
Args:
name: '{test_group_name}-{test_case_name}'. Use... | Tests serialization and deserialization consistency and correctness.
Args:
name: '{test_group_name}-{test_case_name}'. Useful for print statements/debugging.
test_case: Test case name (without file extension).
test_data_dir: The directory containing the test case files.
... | test | python | kubeflow/pipelines | sdk/python/kfp/compiler/read_write_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/compiler/read_write_test.py | Apache-2.0 |
def load_component_from_url(
url: str,
auth: Optional[Tuple[str, str]] = None) -> yaml_component.YamlComponent:
"""Loads a component from a URL.
Args:
url (str): URL to a YAML component.
auth (Tuple[str, str], optional): A ``('<username>', '<password>')`` tuple of authentication... | Loads a component from a URL.
Args:
url (str): URL to a YAML component.
auth (Tuple[str, str], optional): A ``('<username>', '<password>')`` tuple of authentication credentials necessary for URL access. See `Requests Authorization <https://requests.readthedocs.io/en/latest/user/authentication/#auth... | load_component_from_url | python | kubeflow/pipelines | sdk/python/kfp/components/load_yaml_utilities.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/components/load_yaml_utilities.py | Apache-2.0 |
def __init__(self, component_spec: structures.ComponentSpec):
"""Init function for BaseComponent.
Args:
component_spec: The component definition.
"""
self.component_spec = component_spec
self.name = component_spec.name
self.description = component_spec.descript... | Init function for BaseComponent.
Args:
component_spec: The component definition.
| __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/base_component.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/base_component.py | Apache-2.0 |
def _prevent_using_output_lists_of_artifacts(self):
"""This method should be called at the end of __init__ for
PythonComponent and ContainerComponent subclasses to temporarily block
outputting lists of artifacts from a component."""
# TODO: remove when output lists of artifacts from prim... | This method should be called at the end of __init__ for
PythonComponent and ContainerComponent subclasses to temporarily block
outputting lists of artifacts from a component. | _prevent_using_output_lists_of_artifacts | python | kubeflow/pipelines | sdk/python/kfp/dsl/base_component.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/base_component.py | Apache-2.0 |
def __call__(self, *args, **kwargs) -> pipeline_task.PipelineTask:
"""Creates a PipelineTask object.
The arguments are generated on the fly based on component input
definitions.
"""
task_inputs = {}
if args:
raise TypeError(
'Components must ... | Creates a PipelineTask object.
The arguments are generated on the fly based on component input
definitions.
| __call__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/base_component.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/base_component.py | Apache-2.0 |
def component(func: Optional[Callable] = None,
*,
base_image: Optional[str] = None,
target_image: Optional[str] = None,
packages_to_install: List[str] = None,
pip_index_urls: Optional[List[str]] = None,
output_component_file: Optional[s... | Decorator for Python-function based components.
A KFP component can either be a lightweight component or a containerized
component.
If ``target_image`` is not specified, this function creates a lightweight
component. A lightweight component is a self-contained Python function that
includes all nec... | component | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_decorator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_decorator.py | Apache-2.0 |
def make_index_url_options(pip_index_urls: Optional[List[str]],
pip_trusted_hosts: Optional[List[str]]) -> str:
"""Generates index URL options for the pip install command based on the
provided pip_index_urls and pip_trusted_hosts.
Args:
pip_index_urls (Optional[List[str]]... | Generates index URL options for the pip install command based on the
provided pip_index_urls and pip_trusted_hosts.
Args:
pip_index_urls (Optional[List[str]]): Optional list of pip index URLs.
pip_trusted_hosts (Optional[List[str]]): Optional list of pip trusted hosts.
Returns:
str... | make_index_url_options | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def get_name_to_specs(
signature: inspect.Signature,
containerized: bool = False,
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""Returns two dictionaries.
The first is a mapping of input name to input annotation. The second
is a mapping of output name to output annotation.
"""
func_params =... | Returns two dictionaries.
The first is a mapping of input name to input annotation. The second
is a mapping of output name to output annotation.
| get_name_to_specs | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def canonicalize_annotation(annotation: Any):
"""Does cleaning on annotations that are common between input and output
annotations."""
if type_annotations.is_Input_Output_artifact_annotation(annotation):
annotation = type_annotations.strip_Input_or_Output_marker(annotation)
if isinstance(annotat... | Does cleaning on annotations that are common between input and output
annotations. | canonicalize_annotation | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def make_input_output_spec_args(annotation: Any) -> Dict[str, Any]:
"""Gets a dict of kwargs shared between InputSpec and OutputSpec."""
is_artifact_list = type_annotations.is_list_of_artifacts(annotation)
if is_artifact_list:
annotation = type_annotations.get_inner_type(annotation)
if type_ann... | Gets a dict of kwargs shared between InputSpec and OutputSpec. | make_input_output_spec_args | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def make_input_spec(annotation: Any,
inspect_param: inspect.Parameter) -> structures.InputSpec:
"""Makes an InputSpec from a cleaned output annotation."""
annotation = canonicalize_annotation(annotation)
input_output_spec_args = make_input_output_spec_args(annotation)
if (type_annot... | Makes an InputSpec from a cleaned output annotation. | make_input_spec | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def assign_descriptions(
inputs_or_outputs: Mapping[str, Union[structures.InputSpec,
structures.OutputSpec]],
docstring_params: List[docstring_parser.DocstringParam],
) -> None:
"""Assigns descriptions to InputSpec or OutputSpec for each componen... | Assigns descriptions to InputSpec or OutputSpec for each component
input/output found in the parsed docstring parameters. | assign_descriptions | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def parse_docstring_with_return_as_args(
docstring: Union[str,
None]) -> Optional[docstring_parser.Docstring]:
"""Modifies docstring so that a return section can be treated as an
args section, then parses the docstring."""
if docstring is None:
... | Modifies docstring so that a return section can be treated as an
args section, then parses the docstring. | parse_docstring_with_return_as_args | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def create_component_from_func(
func: Callable,
base_image: Optional[str] = None,
target_image: Optional[str] = None,
packages_to_install: List[str] = None,
pip_index_urls: Optional[List[str]] = None,
output_component_file: Optional[str] = None,
install_kfp_package: bool = True,
kfp_pack... | Implementation for the @component decorator.
The decorator is defined under component_decorator.py. See the
decorator for the canonical documentation for this function.
| create_component_from_func | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def create_container_component_from_func(
func: Callable) -> container_component_class.ContainerComponent:
"""Implementation for the @container_component decorator.
The decorator is defined under container_component_decorator.py. See
the decorator for the canonical documentation for this function.
... | Implementation for the @container_component decorator.
The decorator is defined under container_component_decorator.py. See
the decorator for the canonical documentation for this function.
| create_container_component_from_func | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def create_graph_component_from_func(
func: Callable,
name: Optional[str] = None,
description: Optional[str] = None,
display_name: Optional[str] = None,
pipeline_config: pipeline_config.PipelineConfig = None,
) -> graph_component.GraphComponent:
"""Implementation for the @pipeline decorator.
... | Implementation for the @pipeline decorator.
The decorator is defined under pipeline_context.py. See the
decorator for the canonical documentation for this function.
| create_graph_component_from_func | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def get_pipeline_description(
decorator_description: Union[str, None],
docstring: docstring_parser.Docstring,
) -> Optional[str]:
"""Obtains the correct pipeline description from the pipeline decorator's
description argument and the parsed docstring.
Gives precedence to the decorator argument.
... | Obtains the correct pipeline description from the pipeline decorator's
description argument and the parsed docstring.
Gives precedence to the decorator argument.
| get_pipeline_description | python | kubeflow/pipelines | sdk/python/kfp/dsl/component_factory.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/component_factory.py | Apache-2.0 |
def container_component(
func: Callable) -> container_component_class.ContainerComponent:
"""Decorator for container-based components in KFP v2.
Args:
func: The python function to create a component from. The function
should have type annotations for all its arguments, indicating ho... | Decorator for container-based components in KFP v2.
Args:
func: The python function to create a component from. The function
should have type annotations for all its arguments, indicating how
it is intended to be used (e.g. as an input/output Artifact object,
a plain par... | container_component | python | kubeflow/pipelines | sdk/python/kfp/dsl/container_component_decorator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/container_component_decorator.py | Apache-2.0 |
def hello_world_io(
text: str,
text_output_path: dsl.OutputPath(str)) -> dsl.ContainerSpec:
"""Hello world component with input and output."""
return dsl.ContainerSpec(
image='python:3.9',
command=['echo'],
args=['--text', t... | Hello world component with input and output. | hello_world_io | python | kubeflow/pipelines | sdk/python/kfp/dsl/container_component_decorator_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/container_component_decorator_test.py | Apache-2.0 |
def write_executor_output(self,
func_output: Optional[Any] = None
) -> Optional[str]:
"""Writes executor output containing the Python function output. The
executor output file will not be written if this code is executed from
a non-chief... | Writes executor output containing the Python function output. The
executor output file will not be written if this code is executed from
a non-chief node in a mirrored execution strategy.
Args:
func_output: The object returned by the function.
Returns:
Optional[... | write_executor_output | python | kubeflow/pipelines | sdk/python/kfp/dsl/executor.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/executor.py | Apache-2.0 |
def execute(self) -> Optional[str]:
"""Executes the function and writes the executor output file. The
executor output file will not be written if this code is executed from
a non-chief node in a mirrored execution strategy.
Returns:
Optional[str]: Returns the location of the... | Executes the function and writes the executor output file. The
executor output file will not be written if this code is executed from
a non-chief node in a mirrored execution strategy.
Returns:
Optional[str]: Returns the location of the executor_output file as a string if the file i... | execute | python | kubeflow/pipelines | sdk/python/kfp/dsl/executor.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/executor.py | Apache-2.0 |
def create_artifact_instance(
runtime_artifact: Dict,
fallback_artifact_cls=dsl.Artifact,
) -> type:
"""Creates an artifact class instances from a runtime artifact
dictionary."""
schema_title = runtime_artifact.get('type', {}).get('schemaTitle', '')
artifact_cls = artifact_types._SCHEMA_TITLE_TO... | Creates an artifact class instances from a runtime artifact
dictionary. | create_artifact_instance | python | kubeflow/pipelines | sdk/python/kfp/dsl/executor.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/executor.py | Apache-2.0 |
def get_short_type_name(type_name: str) -> str:
"""Extracts the short form type name.
This method is used for looking up serializer for a given type.
For example:
typing.List -> List
typing.List[int] -> List
typing.Dict[str, str] -> Dict
List -> List
str -> str
Args:
... | Extracts the short form type name.
This method is used for looking up serializer for a given type.
For example:
typing.List -> List
typing.List[int] -> List
typing.Dict[str, str] -> Dict
List -> List
str -> str
Args:
type_name: The original type name.
Returns:
... | get_short_type_name | python | kubeflow/pipelines | sdk/python/kfp/dsl/executor.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/executor.py | Apache-2.0 |
def _get_loop_item_type(type_name: str) -> Optional[str]:
"""Extracts the loop item type.
This method is used for extract the item type from a collection type.
For example:
List[str] -> str
typing.List[int] -> int
typing.Sequence[str] -> str
List -> None
str -> None... | Extracts the loop item type.
This method is used for extract the item type from a collection type.
For example:
List[str] -> str
typing.List[int] -> int
typing.Sequence[str] -> str
List -> None
str -> None
Args:
type_name: The collection type name, like `Li... | _get_loop_item_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def _get_subvar_type(type_name: str) -> Optional[str]:
"""Extracts the subvar type.
This method is used for extract the value type from a dictionary type.
For example:
Dict[str, int] -> int
typing.Mapping[str, float] -> float
Args:
type_name: The dictionary type.
Returns:... | Extracts the subvar type.
This method is used for extract the value type from a dictionary type.
For example:
Dict[str, int] -> int
typing.Mapping[str, float] -> float
Args:
type_name: The dictionary type.
Returns:
The dictionary value type or None if no match found.
... | _get_subvar_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def _get_first_element_type(item_list: ItemList) -> str:
"""Returns the type of the first element of ItemList.
Args:
item_list: List of items to loop over. If a list of dicts then, all dicts must have the same keys.
Returns:
A string representing the type of the first element (e.g., "int", ... | Returns the type of the first element of ItemList.
Args:
item_list: List of items to loop over. If a list of dicts then, all dicts must have the same keys.
Returns:
A string representing the type of the first element (e.g., "int", "Dict[str, int]").
| _get_first_element_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def __init__(
self,
items: Union[ItemList, pipeline_channel.PipelineParameterChannel],
name_code: Optional[str] = None,
name_override: Optional[str] = None,
**kwargs,
):
"""Initializes a LoopParameterArgument object.
Args:
items: List of items to ... | Initializes a LoopParameterArgument object.
Args:
items: List of items to loop over. If a list of dicts then, all
dicts must have the same keys and every key must be a legal
Python variable name.
name_code: A unique code used to identify these loop argum... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def from_pipeline_channel(
cls,
channel: pipeline_channel.PipelineParameterChannel,
) -> 'LoopParameterArgument':
"""Creates a LoopParameterArgument object from a
PipelineParameterChannel object.
Provide a flexible default channel_type ('String') if extraction
from P... | Creates a LoopParameterArgument object from a
PipelineParameterChannel object.
Provide a flexible default channel_type ('String') if extraction
from PipelineParameterChannel is unsuccessful. This maintains
compilation progress in cases of unknown or missing type
information.
... | from_pipeline_channel | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def from_raw_items(
cls,
raw_items: ItemList,
name_code: str,
) -> 'LoopParameterArgument':
"""Creates a LoopParameterArgument object from raw item list."""
if len(raw_items) == 0:
raise ValueError('Got an empty item list for loop argument.')
return LoopP... | Creates a LoopParameterArgument object from raw item list. | from_raw_items | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def __init__(
self,
items: pipeline_channel.PipelineArtifactChannel,
name_code: Optional[str] = None,
name_override: Optional[str] = None,
**kwargs,
):
"""Initializes a LoopArtifactArgument object.
Args:
items: The PipelineArtifactChannel object t... | Initializes a LoopArtifactArgument object.
Args:
items: The PipelineArtifactChannel object this LoopArtifactArgument is
associated to.
name_code: A unique code used to identify these loop arguments.
Should match the code for the ParallelFor ops_group whic... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def from_pipeline_channel(
cls,
channel: pipeline_channel.PipelineArtifactChannel,
) -> 'LoopArtifactArgument':
"""Creates a LoopArtifactArgument object from a PipelineArtifactChannel
object."""
if not channel.is_artifact_list:
raise ValueError(
'C... | Creates a LoopArtifactArgument object from a PipelineArtifactChannel
object. | from_pipeline_channel | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def __init__(
self,
loop_argument: LoopParameterArgument,
subvar_name: str,
):
"""Initializes a LoopArgumentVariable instance.
Args:
loop_argument: The LoopParameterArgument object this subvariable is based on
a subvariable to.
subvar_... | Initializes a LoopArgumentVariable instance.
Args:
loop_argument: The LoopParameterArgument object this subvariable is based on
a subvariable to.
subvar_name: The name of this subvariable, which is the name of the
dict key that spawned this subvariable.
... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def _subvar_name_is_legal(self, proposed_variable_name: str) -> bool:
"""Returns True if the subvar name is legal."""
return re.match(self.LEGAL_SUBVAR_NAME_REGEX,
proposed_variable_name) is not None | Returns True if the subvar name is legal. | _subvar_name_is_legal | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop.py | Apache-2.0 |
def name_is_loop_argument(name: str) -> bool:
"""Returns True if the given channel name looks like a loop argument.
Either it came from a withItems loop item or withParams loop item.
"""
return ('-' + for_loop.LOOP_ITEM_NAME_BASE) in name \
or (for_loop.LOOP_ITEM_PARAM_NAME_BASE + '-') in name | Returns True if the given channel name looks like a loop argument.
Either it came from a withItems loop item or withParams loop item.
| name_is_loop_argument | python | kubeflow/pipelines | sdk/python/kfp/dsl/for_loop_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/for_loop_test.py | Apache-2.0 |
def importer(
artifact_uri: Union[pipeline_channel.PipelineParameterChannel, str],
artifact_class: Type[artifact_types.Artifact],
reimport: bool = False,
metadata: Optional[Mapping[str, Any]] = None,
) -> pipeline_task.PipelineTask:
"""Imports an existing artifact for use in a downstream component.
... | Imports an existing artifact for use in a downstream component.
Args:
artifact_uri: The URI of the artifact to import.
artifact_class: The artifact class being imported.
reimport: Whether to reimport the artifact.
metadata: Properties of the artifact.
Returns:
A task with the art... | importer | python | kubeflow/pipelines | sdk/python/kfp/dsl/importer_node.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/importer_node.py | Apache-2.0 |
def __init__(self, config_directory: Optional[pathlib.Path] = None):
"""Creates a KFPConfig object.
Loads the config from an existing `kfp_config.ini` file if found.
Args:
config_directory: Looks for a file named `kfp_config.ini` in this
directory. Defaults to the c... | Creates a KFPConfig object.
Loads the config from an existing `kfp_config.ini` file if found.
Args:
config_directory: Looks for a file named `kfp_config.ini` in this
directory. Defaults to the current directory.
| __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/kfp_config.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/kfp_config.py | Apache-2.0 |
def get_components(self) -> Dict[str, pathlib.Path]:
"""Returns a list of known KFP components.
Returns:
A dictionary from component name (function name) to a pathlib.Path
pointing to the Python file with this component's definition.
"""
return {
func... | Returns a list of known KFP components.
Returns:
A dictionary from component name (function name) to a pathlib.Path
pointing to the Python file with this component's definition.
| get_components | python | kubeflow/pipelines | sdk/python/kfp/dsl/kfp_config.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/kfp_config.py | Apache-2.0 |
def __init__(
self,
name: str,
channel_type: Union[str, Dict],
task_name: Optional[str] = None,
):
"""Initializes a PipelineChannel instance.
Args:
name: The name of the pipeline channel. The name will be sanitized
to be k8s compatible.
... | Initializes a PipelineChannel instance.
Args:
name: The name of the pipeline channel. The name will be sanitized
to be k8s compatible.
channel_type: The type of the pipeline channel.
task_name: Optional; The name of the task that produces the pipeline
... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_channel.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_channel.py | Apache-2.0 |
def __str__(self) -> str:
"""String representation of the PipelineChannel.
The string representation is a string identifier so we can mix
the PipelineChannel inline with other strings such as arguments.
For example, we can support: ['echo %s' % param] as the
container command an... | String representation of the PipelineChannel.
The string representation is a string identifier so we can mix
the PipelineChannel inline with other strings such as arguments.
For example, we can support: ['echo %s' % param] as the
container command and later a compiler can replace the
... | __str__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_channel.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_channel.py | Apache-2.0 |
def __init__(
self,
name: str,
channel_type: Union[str, Dict],
task_name: Optional[str] = None,
value: Optional[type_utils.PARAMETER_TYPES] = None,
):
"""Initializes a PipelineArtifactChannel instance.
Args:
name: The name of the pipeline channel.
... | Initializes a PipelineArtifactChannel instance.
Args:
name: The name of the pipeline channel.
channel_type: The type of the pipeline channel.
task_name: Optional; The name of the task that produces the pipeline
channel.
value: Optional; The actual value of th... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_channel.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_channel.py | Apache-2.0 |
def __init__(
self,
name: str,
channel_type: Union[str, Dict],
task_name: Optional[str],
is_artifact_list: bool,
):
"""Initializes a PipelineArtifactChannel instance.
Args:
name: The name of the pipeline channel.
channel_type: The type... | Initializes a PipelineArtifactChannel instance.
Args:
name: The name of the pipeline channel.
channel_type: The type of the pipeline channel.
task_name: Optional; the name of the task that produces the pipeline
channel.
is_artifact_list: True if `... | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_channel.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_channel.py | Apache-2.0 |
def create_pipeline_channel(
name: str,
channel_type: Union[str, Dict],
task_name: Optional[str] = None,
value: Optional[type_utils.PARAMETER_TYPES] = None,
is_artifact_list: bool = False,
) -> PipelineChannel:
"""Creates a PipelineChannel object.
Args:
name: The name of the channel... | Creates a PipelineChannel object.
Args:
name: The name of the channel.
channel_type: The type of the channel, which decides whether it is an
PipelineParameterChannel or PipelineArtifactChannel
task_name: Optional; the task that produced the channel.
value: Optional; the ... | create_pipeline_channel | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_channel.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_channel.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.