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 extract_pipeline_channels_from_string(
payload: str) -> List[PipelineChannel]:
"""Extracts a list of PipelineChannel instances from the payload string.
Note: this function removes all duplicate matches.
Args:
payload: A string that may contain serialized PipelineChannels.
Returns:
... | Extracts a list of PipelineChannel instances from the payload string.
Note: this function removes all duplicate matches.
Args:
payload: A string that may contain serialized PipelineChannels.
Returns:
A list of PipelineChannels found from the payload.
| extract_pipeline_channels_from_string | 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 extract_pipeline_channels_from_any(
payload: Union[PipelineChannel, str, int, float, bool, list, tuple, dict]
) -> List[PipelineChannel]:
"""Recursively extract PipelineChannels from any object or list of objects.
Args:
payload: An object that contains serialized PipelineChannels or k8
de... | Recursively extract PipelineChannels from any object or list of objects.
Args:
payload: An object that contains serialized PipelineChannels or k8
definition objects.
Returns:
A list of PipelineChannels found from the payload.
| extract_pipeline_channels_from_any | 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 pipeline(
func: Optional[Callable] = None,
*,
name: Optional[str] = None,
description: Optional[str] = None,
pipeline_root: Optional[str] = None,
display_name: Optional[str] = None,
pipeline_config: pipeline_config.PipelineConfig = None) -> Callable:
"""De... | Decorator used to construct a pipeline.
Example
::
@pipeline(
name='my-pipeline',
description='My ML Pipeline.'
pipeline_root='gs://my-bucket/my-output-path'
)
def my_pipeline(a: str, b: int):
...
Args:
func: The Python function th... | pipeline | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_context.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_context.py | Apache-2.0 |
def __init__(self, name: str):
"""Creates a new instance of Pipeline.
Args:
name: The name of the pipeline.
"""
self.name = name
self.tasks = {}
# Add the root group.
self.groups = [
tasks_group.TasksGroup(
group_type=tasks... | Creates a new instance of Pipeline.
Args:
name: The name of the pipeline.
| __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_context.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_context.py | Apache-2.0 |
def add_task(
self,
task: pipeline_task.PipelineTask,
add_to_group: bool,
) -> str:
"""Adds a new task.
Args:
task: A PipelineTask instance.
add_to_group: Whether add the task into the current group. Expect
True for all tasks expect fo... | Adds a new task.
Args:
task: A PipelineTask instance.
add_to_group: Whether add the task into the current group. Expect
True for all tasks expect for exit handler.
Returns:
A unique task name.
| add_task | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_context.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_context.py | Apache-2.0 |
def get_last_tasks_group(self) -> Optional['tasks_group.TasksGroup']:
"""Gets the last TasksGroup added to the pipeline at the current level
of the pipeline definition."""
groups = self.groups[-1].groups
return groups[-1] if groups else None | Gets the last TasksGroup added to the pipeline at the current level
of the pipeline definition. | get_last_tasks_group | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_context.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_context.py | Apache-2.0 |
def _execute_locally(self, args: Dict[str, Any]) -> None:
"""Execute the pipeline task locally.
Set the task state to FINAL and update the outputs.
"""
from kfp.local import task_dispatcher
if self.pipeline_spec is not None:
self._outputs = pipeline_orchestrator.run... | Execute the pipeline task locally.
Set the task state to FINAL and update the outputs.
| _execute_locally | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def platform_spec(self) -> pipeline_spec_pb2.PlatformSpec:
"""PlatformSpec for all tasks in the pipeline as task.
Only for use on tasks created from GraphComponents.
"""
if self.pipeline_spec:
return self.component_spec.platform_spec
# can only create primitive task... | PlatformSpec for all tasks in the pipeline as task.
Only for use on tasks created from GraphComponents.
| platform_spec | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def inputs(
self
) -> Dict[str, Union[type_utils.PARAMETER_TYPES,
pipeline_channel.PipelineChannel]]:
"""The inputs passed to the task."""
return self._inputs | The inputs passed to the task. | inputs | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def output(self) -> pipeline_channel.PipelineChannel:
"""The single output of the task.
Used when a task has exactly one output parameter.
"""
if len(self._outputs) != 1:
raise AttributeError(
'The task has multiple outputs. Please reference the output by its... | The single output of the task.
Used when a task has exactly one output parameter.
| output | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def _extract_container_spec_and_convert_placeholders(
self, component_spec: structures.ComponentSpec
) -> structures.ContainerSpecImplementation:
"""Extracts a ContainerSpec from a ComponentSpec and converts
placeholder objects to strings.
Args:
component_spec: The compo... | Extracts a ContainerSpec from a ComponentSpec and converts
placeholder objects to strings.
Args:
component_spec: The component definition.
| _extract_container_spec_and_convert_placeholders | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def set_caching_options(self,
enable_caching: bool,
cache_key: Optional[str] = None) -> 'PipelineTask':
"""Sets caching options for the task.
Args:
enable_caching: Whether to enable caching.
cache_key: Customized cache key ... | Sets caching options for the task.
Args:
enable_caching: Whether to enable caching.
cache_key: Customized cache key for this task. Default None.
Returns:
Self return to allow chained setting calls.
| set_caching_options | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def _ensure_container_spec_exists(self) -> None:
"""Ensures that the task has a container spec."""
caller_method_name = inspect.stack()[1][3]
if self.container_spec is None:
raise ValueError(
f'{caller_method_name} can only be used on single-step components, not pipe... | Ensures that the task has a container spec. | _ensure_container_spec_exists | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def set_memory_request(
self,
memory: Union[str,
pipeline_channel.PipelineChannel]) -> 'PipelineTask':
"""Sets memory request (minimum) for the task.
Args:
memory: The minimum memory requests required. This string should be
a... | Sets memory request (minimum) for the task.
Args:
memory: The minimum memory requests required. This string should be
a number or a number followed by one of "E", "Ei", "P", "Pi",
"T", "Ti", "G", "Gi", "M", "Mi", "K", or "Ki".
Returns:
Self retur... | set_memory_request | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def set_retry(self,
num_retries: int,
backoff_duration: Optional[str] = None,
backoff_factor: Optional[float] = None,
backoff_max_duration: Optional[str] = None) -> 'PipelineTask':
"""Sets task retry parameters.
Args:
n... | Sets task retry parameters.
Args:
num_retries : Number of times to retry on failure.
backoff_duration: Number of seconds to wait before triggering a retry. Defaults to ``'0s'`` (immediate retry).
backoff_factor: Exponential backoff factor applied to ``backoff_duration``. For... | set_retry | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def add_node_selector_constraint(self, accelerator: str) -> 'PipelineTask':
"""Sets accelerator type to use when executing this task.
Args:
accelerator: The name of the accelerator, such as ``'NVIDIA_TESLA_K80'``, ``'TPU_V3'``, ``'nvidia.com/gpu'`` or ``'cloud-tpus.google.com/v3'``.
... | Sets accelerator type to use when executing this task.
Args:
accelerator: The name of the accelerator, such as ``'NVIDIA_TESLA_K80'``, ``'TPU_V3'``, ``'nvidia.com/gpu'`` or ``'cloud-tpus.google.com/v3'``.
Returns:
Self return to allow chained setting calls.
| add_node_selector_constraint | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def set_env_variable(self, name: str, value: str) -> 'PipelineTask':
"""Sets environment variable for the task.
Args:
name: Environment variable name.
value: Environment variable value.
Returns:
Self return to allow chained setting calls.
"""
... | Sets environment variable for the task.
Args:
name: Environment variable name.
value: Environment variable value.
Returns:
Self return to allow chained setting calls.
| set_env_variable | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def set_container_image(
self,
name: Union[str,
pipeline_channel.PipelineChannel]) -> 'PipelineTask':
"""Sets the container image to use when executing this task.
Takes precedence over the `base_image` specified in the `@component` decorator.
Unl... | Sets the container image to use when executing this task.
Takes precedence over the `base_image` specified in the `@component` decorator.
Unlike `base_image`, this method supports dynamic values such as
Pipeline Parameters or outputs from previous tasks, which are resolved at runtime.
... | set_container_image | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def after(self, *tasks) -> 'PipelineTask':
"""Specifies an explicit dependency on other tasks by requiring this
task be executed after other tasks finish completion.
Args:
*tasks: Tasks after which this task should be executed.
Returns:
Self return to allow chai... | Specifies an explicit dependency on other tasks by requiring this
task be executed after other tasks finish completion.
Args:
*tasks: Tasks after which this task should be executed.
Returns:
Self return to allow chained setting calls.
Example:
::
... | after | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def ignore_upstream_failure(self) -> 'PipelineTask':
"""If called, the pipeline task will run when any specified upstream
tasks complete, even if unsuccessful.
This method effectively turns the caller task into an exit task
if the caller task has upstream dependencies.
If the t... | If called, the pipeline task will run when any specified upstream
tasks complete, even if unsuccessful.
This method effectively turns the caller task into an exit task
if the caller task has upstream dependencies.
If the task has no upstream tasks, either via data exchange or an explic... | ignore_upstream_failure | python | kubeflow/pipelines | sdk/python/kfp/dsl/pipeline_task.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/pipeline_task.py | Apache-2.0 |
def __eq__(self, other: Any) -> bool:
"""Used for comparing placeholders in tests."""
return isinstance(other,
self.__class__) and self.__dict__ == other.__dict__ | Used for comparing placeholders in tests. | __eq__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/placeholders.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/placeholders.py | Apache-2.0 |
def _validate_then_and_else_are_only_single_element(self) -> None:
"""Rercursively validate that then and else contain only a single
element.
This method should only be called by a ConcatPlaceholder, which
cannot have an IfPresentPlaceholder with a list in either 'then'
or 'else... | Rercursively validate that then and else contain only a single
element.
This method should only be called by a ConcatPlaceholder, which
cannot have an IfPresentPlaceholder with a list in either 'then'
or 'else_'.
| _validate_then_and_else_are_only_single_element | python | kubeflow/pipelines | sdk/python/kfp/dsl/placeholders.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/placeholders.py | Apache-2.0 |
def from_ir_component_inputs_dict(
cls, ir_component_inputs_dict: Dict[str, Any]) -> 'InputSpec':
"""Creates an InputSpec from a ComponentInputsSpec message in dict
format (pipeline_spec.components.<component-
key>.inputDefinitions.parameters.<input-key>).
Args:
... | Creates an InputSpec from a ComponentInputsSpec message in dict
format (pipeline_spec.components.<component-
key>.inputDefinitions.parameters.<input-key>).
Args:
ir_component_inputs_dict (Dict[str, Any]): The ComponentInputsSpec
message in dict format.
Retur... | from_ir_component_inputs_dict | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def __eq__(self, other: Any) -> bool:
"""Equality comparison for InputSpec. Robust to different type
representations, such that it respects the maximum amount of
information possible to encode in IR. That is, because
`typing.List[str]` can only be represented a `List` in IR,
'typ... | Equality comparison for InputSpec. Robust to different type
representations, such that it respects the maximum amount of
information possible to encode in IR. That is, because
`typing.List[str]` can only be represented a `List` in IR,
'typing.List' == 'List' in this comparison.
... | __eq__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def _validate_type(self) -> None:
"""Type should either be a parameter or a valid bundled artifact type
by the time it gets to InputSpec.
This allows us to perform fewer checks downstream.
"""
# TODO: add transformation logic so that we don't have to transform inputs at every pl... | Type should either be a parameter or a valid bundled artifact type
by the time it gets to InputSpec.
This allows us to perform fewer checks downstream.
| _validate_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def _validate_usage_of_optional(self) -> None:
"""Validates that the optional and default properties are in consistent
states."""
# Because None can be the default value, None cannot be used to to indicate no default. This is why we need the optional field. This check prevents users of InputSpec... | Validates that the optional and default properties are in consistent
states. | _validate_usage_of_optional | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_ir_component_outputs_dict(
cls, ir_component_outputs_dict: Dict[str, Any]) -> 'OutputSpec':
"""Creates an OutputSpec from a ComponentOutputsSpec message in dict
format (pipeline_spec.components.<component-
key>.outputDefinitions.parameters|artifacts.<output-key>).
A... | Creates an OutputSpec from a ComponentOutputsSpec message in dict
format (pipeline_spec.components.<component-
key>.outputDefinitions.parameters|artifacts.<output-key>).
Args:
ir_component_outputs_dict (Dict[str, Any]): The ComponentOutputsSpec
in dict format.
... | from_ir_component_outputs_dict | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def __eq__(self, other: Any) -> bool:
"""Equality comparison for OutputSpec. Robust to different type
representations, such that it respects the maximum amount of
information possible to encode in IR. That is, because
`typing.List[str]` can only be represented a `List` in IR,
'ty... | Equality comparison for OutputSpec. Robust to different type
representations, such that it respects the maximum amount of
information possible to encode in IR. That is, because
`typing.List[str]` can only be represented a `List` in IR,
'typing.List' == 'List' in this comparison.
... | __eq__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def _validate_type(self):
"""Type should either be a parameter or a valid bundled artifact type
by the time it gets to OutputSpec.
This allows us to perform fewer checks downstream.
"""
# TODO: add transformation logic so that we don't have to transform outputs at every place th... | Type should either be a parameter or a valid bundled artifact type
by the time it gets to OutputSpec.
This allows us to perform fewer checks downstream.
| _validate_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_container_dict(
cls, container_dict: Dict[str,
Any]) -> 'ContainerSpecImplementation':
"""Creates a ContainerSpecImplementation from a PipelineContainerSpec
message in dict format
(pipeline_spec.deploymentSpec.executors.<executor- key>.c... | Creates a ContainerSpecImplementation from a PipelineContainerSpec
message in dict format
(pipeline_spec.deploymentSpec.executors.<executor- key>.container).
Args:
container_dict (Dict[str, Any]): PipelineContainerSpec message in dict format.
Returns:
ContainerS... | from_container_dict | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_pipeline_spec_dict(cls, pipeline_spec_dict: Dict[str, Any],
component_name: str) -> 'Implementation':
"""Creates an Implementation object from a PipelineSpec message in dict
format.
Args:
pipeline_spec_dict (Dict[str, Any]): PipelineSpec mess... | Creates an Implementation object from a PipelineSpec message in dict
format.
Args:
pipeline_spec_dict (Dict[str, Any]): PipelineSpec message in dict format.
component_name (str): The name of the component.
Returns:
Implementation: An implementation object.
... | from_pipeline_spec_dict | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def check_placeholder_references_valid_io_name(
inputs_dict: Dict[str, InputSpec],
outputs_dict: Dict[str, OutputSpec],
arg: placeholders.CommandLineElement,
) -> None:
"""Validates input/output placeholders refer to an existing input/output.
Args:
valid_inputs: The existing input names.
... | Validates input/output placeholders refer to an existing input/output.
Args:
valid_inputs: The existing input names.
valid_outputs: The existing output names.
arg: The placeholder argument for checking.
Raises:
ValueError: if any placeholder references a nonexistant input or
... | check_placeholder_references_valid_io_name | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def _validate_placeholders(self):
"""Validates that input/output placeholders refer to an existing
input/output."""
if self.implementation.container is None:
return
valid_inputs = {} if self.inputs is None else self.inputs
valid_outputs = {} if self.outputs is None e... | Validates that input/output placeholders refer to an existing
input/output. | _validate_placeholders | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_v1_component_spec(
cls,
v1_component_spec: v1_structures.ComponentSpec) -> 'ComponentSpec':
"""Converts V1 ComponentSpec to V2 ComponentSpec.
Args:
v1_component_spec: The V1 ComponentSpec.
Returns:
Component spec in the form of V2 Compon... | Converts V1 ComponentSpec to V2 ComponentSpec.
Args:
v1_component_spec: The V1 ComponentSpec.
Returns:
Component spec in the form of V2 ComponentSpec.
Raises:
ValueError: If implementation is not found.
TypeError: If any argument is neither a st... | from_v1_component_spec | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_ir_dicts(
cls,
pipeline_spec_dict: dict,
platform_spec_dict: dict,
) -> 'ComponentSpec':
"""Creates a ComponentSpec from the PipelineSpec and PlatformSpec
messages as dicts."""
raw_name = pipeline_spec_dict['pipelineInfo']['name']
def inputs_dict_fro... | Creates a ComponentSpec from the PipelineSpec and PlatformSpec
messages as dicts. | from_ir_dicts | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def from_yaml_documents(cls, component_yaml: str) -> 'ComponentSpec':
"""Loads V1 or V2 component YAML into a ComponentSpec.
Args:
component_yaml: PipelineSpec and optionally PlatformSpec YAML documents as a single string.
Returns:
ComponentSpec: The ComponentSpec objec... | Loads V1 or V2 component YAML into a ComponentSpec.
Args:
component_yaml: PipelineSpec and optionally PlatformSpec YAML documents as a single string.
Returns:
ComponentSpec: The ComponentSpec object.
| from_yaml_documents | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def save_to_component_yaml(self, output_file: str) -> None:
"""Saves ComponentSpec into IR YAML file.
Args:
output_file: File path to store the component yaml.
"""
from kfp.compiler import pipeline_spec_builder as builder
pipeline_spec = self.to_pipeline_spec()
... | Saves ComponentSpec into IR YAML file.
Args:
output_file: File path to store the component yaml.
| save_to_component_yaml | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def to_pipeline_spec(self) -> pipeline_spec_pb2.PipelineSpec:
"""Creates a pipeline instance and constructs the pipeline spec for a
single component.
Args:
component_spec: The ComponentSpec to convert to PipelineSpec.
Returns:
A PipelineSpec proto representing t... | Creates a pipeline instance and constructs the pipeline spec for a
single component.
Args:
component_spec: The ComponentSpec to convert to PipelineSpec.
Returns:
A PipelineSpec proto representing the compiled component.
| to_pipeline_spec | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def normalize_time_string(duration: str) -> str:
"""Normalizes a time string.
Examples:
- '1 hour' -> '1h'
- '2 hours' -> '2h'
- '2hours' -> '2h'
- '2 w' -> '2w'
- '2w' -> '2w'
Args:
duration (str): The unnormalized duration string.
... | Normalizes a time string.
Examples:
- '1 hour' -> '1h'
- '2 hours' -> '2h'
- '2hours' -> '2h'
- '2 w' -> '2w'
- '2w' -> '2w'
Args:
duration (str): The unnormalized duration string.
Returns:
str: The normalized duration string.
... | normalize_time_string | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def convert_duration_to_seconds(duration: str) -> int:
"""Converts a duration string to seconds.
Args:
duration (str): The unnormalized duration string. (e.g. '1h', '1 hour', '2
hours', '2w', '2 weeks', '2d', etc.)
Raises:
ValueError: If the time unit is not one of seconds, minu... | Converts a duration string to seconds.
Args:
duration (str): The unnormalized duration string. (e.g. '1h', '1 hour', '2
hours', '2w', '2 weeks', '2d', etc.)
Raises:
ValueError: If the time unit is not one of seconds, minutes, hours, days,
or weeks.
Returns:
i... | convert_duration_to_seconds | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def load_documents_from_yaml(component_yaml: str) -> Tuple[dict, dict]:
"""Loads up to two YAML documents from a YAML string.
First document must always be present. If second document is
present, it is returned as a dict, else an empty dict.
"""
documents = list(yaml.safe_load_all(component_yaml))
... | Loads up to two YAML documents from a YAML string.
First document must always be present. If second document is
present, it is returned as a dict, else an empty dict.
| load_documents_from_yaml | python | kubeflow/pipelines | sdk/python/kfp/dsl/structures.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/structures.py | Apache-2.0 |
def __init__(
self,
group_type: TasksGroupType,
name: Optional[str] = None,
is_root: bool = False,
) -> None:
"""Create a new instance of TasksGroup.
Args:
group_type: The type of the group.
name: The name of the group. Used as display name in UI.... | Create a new instance of TasksGroup.
Args:
group_type: The type of the group.
name: The name of the group. Used as display name in UI.
| __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/tasks_group.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/tasks_group.py | Apache-2.0 |
def _make_name_unique(self):
"""Generates a unique TasksGroup name in the pipeline."""
if not pipeline_context.Pipeline.get_default_pipeline():
raise ValueError('Default pipeline not defined.')
group_id = pipeline_context.Pipeline.get_default_pipeline(
).get_next_group_id()
... | Generates a unique TasksGroup name in the pipeline. | _make_name_unique | python | kubeflow/pipelines | sdk/python/kfp/dsl/tasks_group.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/tasks_group.py | Apache-2.0 |
def remove_task_recursive(self, task: pipeline_task.PipelineTask):
"""Removes a task from the group recursively."""
if self.tasks and task in self.tasks:
self.tasks.remove(task)
for group in self.groups or []:
group.remove_task_recursive(task) | Removes a task from the group recursively. | remove_task_recursive | python | kubeflow/pipelines | sdk/python/kfp/dsl/tasks_group.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/tasks_group.py | Apache-2.0 |
def load_module(module_name: str, module_directory: str) -> types.ModuleType:
"""Dynamically imports the Python module with the given name and package
path.
E.g., Assuming there is a file called `my_module.py` under
`/some/directory/my_module`, we can use::
load_module('my_module', '/some/dire... | Dynamically imports the Python module with the given name and package
path.
E.g., Assuming there is a file called `my_module.py` under
`/some/directory/my_module`, we can use::
load_module('my_module', '/some/directory')
to effectively `import mymodule`.
Args:
module_name: The na... | load_module | python | kubeflow/pipelines | sdk/python/kfp/dsl/utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/utils.py | Apache-2.0 |
def validate_pipeline_name(name: str) -> None:
"""Validate pipeline name.
A valid pipeline name should match ^[a-z0-9][a-z0-9-]{0,127}$.
Args:
name: The pipeline name.
Raises:
ValueError if the pipeline name doesn't conform to the regular expression.
"""
pattern = re.compile(r... | Validate pipeline name.
A valid pipeline name should match ^[a-z0-9][a-z0-9-]{0,127}$.
Args:
name: The pipeline name.
Raises:
ValueError if the pipeline name doesn't conform to the regular expression.
| validate_pipeline_name | python | kubeflow/pipelines | sdk/python/kfp/dsl/utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/utils.py | Apache-2.0 |
def verify_object_against_type(x: Any, typ: Type[T]) -> T:
"""Verifies that the object is compatible to the specified type (types from
the typing package can be used)."""
#TODO: Merge with parse_object_from_struct_based_on_type which has almost the same code
if typ is type(None):
if x is None:
... | Verifies that the object is compatible to the specified type (types from
the typing package can be used). | verify_object_against_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/v1_modelbase.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/v1_modelbase.py | Apache-2.0 |
def parse_object_from_struct_based_on_type(struct: Any, typ: Type[T]) -> T:
"""Constructs an object from structure (usually dict) based on type.
Supports list and dict types from the typing package plus Optional[]
and Union[] types. If some type is a class that has .from_dict class
method, that method ... | Constructs an object from structure (usually dict) based on type.
Supports list and dict types from the typing package plus Optional[]
and Union[] types. If some type is a class that has .from_dict class
method, that method is used for object construction.
| parse_object_from_struct_based_on_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/v1_modelbase.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/v1_modelbase.py | Apache-2.0 |
def convert_object_to_struct(obj, serialized_names: Mapping[str, str] = {}):
"""Converts an object to structure (usually a dict).
Serializes all properties that do not start with underscores. If the
type of some property is a class that has .to_dict class method,
that method is used for conversion. Use... | Converts an object to structure (usually a dict).
Serializes all properties that do not start with underscores. If the
type of some property is a class that has .to_dict class method,
that method is used for conversion. Used by the ModelBase class.
| convert_object_to_struct | python | kubeflow/pipelines | sdk/python/kfp/dsl/v1_modelbase.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/v1_modelbase.py | Apache-2.0 |
def parse_object_from_struct_based_on_class_init(
cls: Type[T],
struct: Mapping,
serialized_names: Mapping[str, str] = {}) -> T:
"""Constructs an object of specified class from structure (usually dict)
using the class.__init__ method. Converts all constructor arguments to
appropriate... | Constructs an object of specified class from structure (usually dict)
using the class.__init__ method. Converts all constructor arguments to
appropriate types based on the __init__ type hints. Used by the ModelBase
class.
Arguments:
serialized_names: specifies the mapping between __init__ paramete... | parse_object_from_struct_based_on_class_init | python | kubeflow/pipelines | sdk/python/kfp/dsl/v1_modelbase.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/v1_modelbase.py | Apache-2.0 |
def pipeline_spec(self) -> pipeline_spec_pb2.PipelineSpec:
"""Returns the pipeline spec of the component."""
component_dict = structures.load_documents_from_yaml(
self.component_yaml)[0]
is_v1 = 'implementation' in set(component_dict.keys())
if is_v1:
return self.... | Returns the pipeline spec of the component. | pipeline_spec | python | kubeflow/pipelines | sdk/python/kfp/dsl/yaml_component.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/yaml_component.py | Apache-2.0 |
def __init__(self,
name: Optional[str] = None,
uri: Optional[str] = None,
metadata: Optional[Dict] = None) -> None:
"""Initializes the Artifact with the given name, URI and metadata."""
self.uri = uri or ''
self.name = name or ''
self.me... | Initializes the Artifact with the given name, URI and metadata. | __init__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_roc_data_point(self, fpr: float, tpr: float,
threshold: float) -> None:
"""Logs a single data point in the ROC curve to metadata.
Args:
fpr: False positive rate value of the data point.
tpr: True positive rate value of the data point.
thr... | Logs a single data point in the ROC curve to metadata.
Args:
fpr: False positive rate value of the data point.
tpr: True positive rate value of the data point.
threshold: Threshold value for the data point.
| log_roc_data_point | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_roc_curve(self, fpr: List[float], tpr: List[float],
threshold: List[float]) -> None:
"""Logs an ROC curve to metadata.
Args:
fpr: List of false positive rate values.
tpr: List of true positive rate values.
threshold: List of threshold values.
... | Logs an ROC curve to metadata.
Args:
fpr: List of false positive rate values.
tpr: List of true positive rate values.
threshold: List of threshold values.
Raises:
ValueError: If the lists ``fpr``, ``tpr`` and ``threshold`` are not the same length.
| log_roc_curve | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def set_confusion_matrix_categories(self, categories: List[str]) -> None:
"""Stores confusion matrix categories to metadata.
Args:
categories: List of strings specifying the categories.
"""
self._categories = []
annotation_specs = []
for category in categories... | Stores confusion matrix categories to metadata.
Args:
categories: List of strings specifying the categories.
| set_confusion_matrix_categories | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_confusion_matrix_row(self, row_category: str,
row: List[float]) -> None:
"""Logs a confusion matrix row to metadata.
Args:
row_category: Category to which the row belongs.
row: List of integers specifying the values for the row.
Rais... | Logs a confusion matrix row to metadata.
Args:
row_category: Category to which the row belongs.
row: List of integers specifying the values for the row.
Raises:
ValueError: If ``row_category`` is not in the list of categories
set in ``set_categories`` call.
... | log_confusion_matrix_row | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_confusion_matrix_cell(self, row_category: str, col_category: str,
value: int) -> None:
"""Logs a cell in the confusion matrix to metadata.
Args:
row_category: String representing the name of the row category.
col_category: String representin... | Logs a cell in the confusion matrix to metadata.
Args:
row_category: String representing the name of the row category.
col_category: String representing the name of the column category.
value: Value of the cell.
Raises:
ValueError: If ``row_category`` or ``col_c... | log_confusion_matrix_cell | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_confusion_matrix(self, categories: List[str],
matrix: List[List[int]]) -> None:
"""Logs a confusion matrix to metadata.
Args:
categories: List of the category names.
matrix: Complete confusion matrix.
Raises:
ValueError: If the... | Logs a confusion matrix to metadata.
Args:
categories: List of the category names.
matrix: Complete confusion matrix.
Raises:
ValueError: If the length of ``categories`` does not match number of rows or columns of ``matrix``.
| log_confusion_matrix | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def _upsert_classification_metrics_for_slice(self, slice: str) -> None:
"""Upserts the classification metrics instance for a slice."""
if slice not in self._sliced_metrics:
self._sliced_metrics[slice] = ClassificationMetrics() | Upserts the classification metrics instance for a slice. | _upsert_classification_metrics_for_slice | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def _update_metadata(self, slice: str) -> None:
"""Updates metadata to adhere to the metrics schema."""
self.metadata = {'evaluationSlices': []}
for slice in self._sliced_metrics.keys():
slice_metrics = {
'slice':
slice,
'sliceClass... | Updates metadata to adhere to the metrics schema. | _update_metadata | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_roc_reading(self, slice: str, threshold: float, tpr: float,
fpr: float) -> None:
"""Logs a single data point in the ROC curve of a slice to metadata.
Args:
slice: String representing slice label.
threshold: Thresold value for the data point.
... | Logs a single data point in the ROC curve of a slice to metadata.
Args:
slice: String representing slice label.
threshold: Thresold value for the data point.
tpr: True positive rate value of the data point.
fpr: False positive rate value of the data point.
| log_roc_reading | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def load_roc_readings(self, slice: str,
readings: List[List[float]]) -> None:
"""Bulk loads ROC curve readings for a slice.
Args:
slice: String representing slice label.
readings: A 2-dimensional list providing ROC curve data points. The expected order of t... | Bulk loads ROC curve readings for a slice.
Args:
slice: String representing slice label.
readings: A 2-dimensional list providing ROC curve data points. The expected order of the data points is: threshold, true positive rate, false positive rate.
| load_roc_readings | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def set_confusion_matrix_categories(self, slice: str,
categories: List[str]) -> None:
"""Logs confusion matrix categories for a slice to metadata.
Categories are stored in the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
Args... | Logs confusion matrix categories for a slice to metadata.
Categories are stored in the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
Args:
slice: String representing slice label.
categories: List of strings specifying the categories.
| set_confusion_matrix_categories | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_confusion_matrix_row(self, slice: str, row_category: str,
row: List[int]) -> None:
"""Logs a confusion matrix row for a slice to metadata.
Row is updated on the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
Args:
sl... | Logs a confusion matrix row for a slice to metadata.
Row is updated on the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
Args:
slice: String representing slice label.
row_category: Category to which the row belongs.
row: List of integers specif... | log_confusion_matrix_row | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def log_confusion_matrix_cell(self, slice: str, row_category: str,
col_category: str, value: int) -> None:
"""Logs a confusion matrix cell for a slice to metadata.
Cell is updated on the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
... | Logs a confusion matrix cell for a slice to metadata.
Cell is updated on the internal ``metrics_utils.ConfusionMatrix``
instance of the slice.
Args:
slice: String representing slice label.
row_category: String representing the name of the row category.
col_categor... | log_confusion_matrix_cell | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def load_confusion_matrix(self, slice: str, categories: List[str],
matrix: List[List[int]]) -> None:
"""Bulk loads the whole confusion matrix for a slice.
Args:
slice: String representing slice label.
categories: List of the category names.
ma... | Bulk loads the whole confusion matrix for a slice.
Args:
slice: String representing slice label.
categories: List of the category names.
matrix: Complete confusion matrix.
| load_confusion_matrix | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def get_uri(suffix: str = 'Output') -> str:
"""Gets the task root URI, a unique object storage URI associated with the
current task. This function may only be called at task runtime.
Returns an empty string if the task root cannot be inferred from the runtime environment.
Args:
suffix: A suffi... | Gets the task root URI, a unique object storage URI associated with the
current task. This function may only be called at task runtime.
Returns an empty string if the task root cannot be inferred from the runtime environment.
Args:
suffix: A suffix to append to the URI. This is a helpful for creat... | get_uri | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/artifact_types.py | Apache-2.0 |
def get_custom_artifact_type_import_statements(func: Callable) -> List[str]:
"""Gets a list of custom artifact type import statements from a lightweight
Python component function."""
artifact_imports = get_custom_artifact_import_items_from_function(func)
imports_source = []
for obj_str in artifact_i... | Gets a list of custom artifact type import statements from a lightweight
Python component function. | get_custom_artifact_type_import_statements | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_param_to_custom_artifact_class(func: Callable) -> Dict[str, type]:
"""Gets a map of parameter names to custom artifact classes.
Return key is 'return-' for normal returns and 'return-<field>' for
typing.NamedTuple returns.
"""
param_to_artifact_cls: Dict[str, type] = {}
kfp_artifact_cla... | Gets a map of parameter names to custom artifact classes.
Return key is 'return-' for normal returns and 'return-<field>' for
typing.NamedTuple returns.
| get_param_to_custom_artifact_class | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_full_qualname_for_artifact(obj: type) -> str:
"""Gets the fully qualified name for an object. For example, for class Foo
in module bar.baz, this function returns bar.baz.Foo.
Note: typing.get_type_hints purports to do the same thing, but it behaves
differently when executed within the scope of ... | Gets the fully qualified name for an object. For example, for class Foo
in module bar.baz, this function returns bar.baz.Foo.
Note: typing.get_type_hints purports to do the same thing, but it behaves
differently when executed within the scope of a test, so preferring this
approach instead.
Args:
... | get_full_qualname_for_artifact | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_symbol_import_path(artifact_class_base_symbol: str,
qualname: str) -> str:
"""Gets the fully qualified name of the symbol that must be imported for
the custom artifact type annotation to be referenced successfully.
Args:
artifact_class_base_symbol: The base symbol... | Gets the fully qualified name of the symbol that must be imported for
the custom artifact type annotation to be referenced successfully.
Args:
artifact_class_base_symbol: The base symbol from which the artifact class is referenced (e.g., aiplatform for aiplatform.VertexDataset).
qualname: The f... | get_symbol_import_path | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_custom_artifact_base_symbol_for_parameter(func: Callable,
arg_name: str) -> str:
"""Gets the symbol required for the custom artifact type annotation to be
referenced correctly."""
module_node = ast.parse(
component_factory._get_function_sourc... | Gets the symbol required for the custom artifact type annotation to be
referenced correctly. | get_custom_artifact_base_symbol_for_parameter | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_custom_artifact_base_symbol_for_return(func: Callable,
return_name: str) -> str:
"""Gets the symbol required for the custom artifact type return annotation
to be referenced correctly."""
module_node = ast.parse(
component_factory._get_function_s... | Gets the symbol required for the custom artifact type return annotation
to be referenced correctly. | get_custom_artifact_base_symbol_for_return | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def get_custom_artifact_import_items_from_function(func: Callable) -> List[str]:
"""Gets the fully qualified name of the symbol that must be imported for
the custom artifact type annotation to be referenced successfully from a
component function."""
param_to_ann_obj = get_param_to_custom_artifact_class... | Gets the fully qualified name of the symbol that must be imported for
the custom artifact type annotation to be referenced successfully from a
component function. | get_custom_artifact_import_items_from_function | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/custom_artifact_types.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/custom_artifact_types.py | Apache-2.0 |
def is_artifact_wrapped_in_Input(typ: Any) -> bool:
"""Returns True if typ is of type Input[T]."""
if not is_Input_Output_artifact_annotation(typ):
return False
return typ.__metadata__[0] == InputAnnotation | Returns True if typ is of type Input[T]. | is_artifact_wrapped_in_Input | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.py | Apache-2.0 |
def is_artifact_wrapped_in_Output(typ: Any) -> bool:
"""Returns True if typ is of type Output[T]."""
if not is_Input_Output_artifact_annotation(typ):
return False
return typ.__metadata__[0] == OutputAnnotation | Returns True if typ is of type Output[T]. | is_artifact_wrapped_in_Output | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.py | Apache-2.0 |
def maybe_strip_optional_from_annotation(annotation: T) -> T:
"""Strips 'Optional' from 'Optional[<type>]' if applicable.
For example::
Optional[str] -> str
str -> str
List[int] -> List[int]
Args:
annotation: The original type annotation which may or may not has
`Optional`.... | Strips 'Optional' from 'Optional[<type>]' if applicable.
For example::
Optional[str] -> str
str -> str
List[int] -> List[int]
Args:
annotation: The original type annotation which may or may not has
`Optional`.
Returns:
The type inside Optional[] if Optional exists, o... | maybe_strip_optional_from_annotation | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.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/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.py | Apache-2.0 |
def is_list_of_artifacts(
annotation: Union[Type[List[artifact_types.Artifact]],
Type[artifact_types.Artifact]]
) -> bool:
"""Checks if an object is a list of list of artifacts annotation (e.g.,
List[Artifact], List[Dataset])"""
return is_generic_list(annotation) and issubclass_of_... | Checks if an object is a list of list of artifacts annotation (e.g.,
List[Artifact], List[Dataset]) | is_list_of_artifacts | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.py | Apache-2.0 |
def get_inner_type(annotation: Any) -> Optional[Any]:
"""Returns the inner type of a generic annotation.
For Union or Optional types with multiple inner types, a tuple of
types is returned.
"""
# Check if the annotation has '__args__' attribute
if hasattr(annotation, '__args__'):
if len... | Returns the inner type of a generic annotation.
For Union or Optional types with multiple inner types, a tuple of
types is returned.
| get_inner_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_annotations.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_annotations.py | Apache-2.0 |
def is_task_final_status_type(type_name: Optional[Union[str, dict]]) -> bool:
"""Check if a ComponentSpec I/O type is PipelineTaskFinalStatus.
Args:
type_name: type name of the ComponentSpec I/O type.
Returns:
True if the type name is 'PipelineTaskFinalStatus'.
"""
return isinstance(ty... | Check if a ComponentSpec I/O type is PipelineTaskFinalStatus.
Args:
type_name: type name of the ComponentSpec I/O type.
Returns:
True if the type name is 'PipelineTaskFinalStatus'.
| is_task_final_status_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def is_parameter_type(type_name: Optional[Union[str, dict]]) -> bool:
"""Check if a ComponentSpec I/O type is considered as a parameter type.
Args:
type_name: type name of the ComponentSpec I/O type.
Returns:
True if the type name maps to a parameter type else False.
"""
if isinstance(... | Check if a ComponentSpec I/O type is considered as a parameter type.
Args:
type_name: type name of the ComponentSpec I/O type.
Returns:
True if the type name maps to a parameter type else False.
| is_parameter_type | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def bundled_artifact_to_artifact_proto(
bundled_artifact_str: str) -> 'pipeline_spec_pb2.ArtifactTypeSchema':
"""Gets the IR ArtifactTypeSchema proto for a bundled artifact in form
`<namespace>.<Name>@x.x.x` (e.g., system.Artifact@0.0.1)."""
bundled_artifact_str, schema_version = bundled_artifact_st... | Gets the IR ArtifactTypeSchema proto for a bundled artifact in form
`<namespace>.<Name>@x.x.x` (e.g., system.Artifact@0.0.1). | bundled_artifact_to_artifact_proto | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def verify_type_compatibility(
given_value: Union['pipeline_channel.PipelineChannel', str, bool, int,
float, dict, list],
expected_spec: Union['structures.InputSpec', 'structures.OutputSpec'],
error_message_prefix: str,
checks_input: bool = True,
raise_on_error: bool = True,
)... | Verifies the given argument type is compatible with the expected type.
Args:
given_value: The channel or constant provided as an argument.
expected_spec: The InputSpec or OutputSpec that describes the expected type of given_value.
error_message_prefix: The prefix for the error message.
... | verify_type_compatibility | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def __enter__(self) -> 'TypeCheckManager':
"""Set type check mode to self._enable.
Returns:
TypeCheckManager: Returns itself.
"""
self._prev = kfp.TYPE_CHECK
kfp.TYPE_CHECK = self._enable
return self | Set type check mode to self._enable.
Returns:
TypeCheckManager: Returns itself.
| __enter__ | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def get_canonical_name_for_outer_generic(type_name: Any) -> str:
"""Maps a complex/nested type name back to a canonical type.
E.g.
get_canonical_name_for_outer_generic('typing.List[str]')
'List'
get_canonical_name_for_outer_generic('typing.Dict[typing.List[str], str]')
'Dict'
... | Maps a complex/nested type name back to a canonical type.
E.g.
get_canonical_name_for_outer_generic('typing.List[str]')
'List'
get_canonical_name_for_outer_generic('typing.Dict[typing.List[str], str]')
'Dict'
Args:
type_name (Any): The type. Returns input if not a stri... | get_canonical_name_for_outer_generic | python | kubeflow/pipelines | sdk/python/kfp/dsl/types/type_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/types/type_utils.py | Apache-2.0 |
def init(
# annotate with subclasses, not parent class, for more helpful ref docs
runner: Union[SubprocessRunner, DockerRunner],
pipeline_root: str = './local_outputs',
raise_on_error: bool = True,
) -> None:
"""Initializes a local execution session.
Once called, components can be invoked local... | Initializes a local execution session.
Once called, components can be invoked locally outside of a pipeline definition.
Args:
runner: The runner to use. Supported runners: kfp.local.SubprocessRunner and kfp.local.DockerRunner.
pipeline_root: Destination for task outputs.
raise_on_error... | init | python | kubeflow/pipelines | sdk/python/kfp/local/config.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/config.py | Apache-2.0 |
def test_local_runner_config_init(self):
"""Test instance attributes with one constructor call."""
config.LocalExecutionConfig(
pipeline_root='my/local/root',
runner=local.SubprocessRunner(use_venv=True),
raise_on_error=True,
)
instance = config.Local... | Test instance attributes with one constructor call. | test_local_runner_config_init | python | kubeflow/pipelines | sdk/python/kfp/local/config_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/config_test.py | Apache-2.0 |
def test_local_runner_config_is_singleton(self):
"""Test instance attributes with multiple constructor calls."""
config.LocalExecutionConfig(
pipeline_root='my/local/root',
runner=local.SubprocessRunner(),
raise_on_error=True,
)
config.LocalExecutionCo... | Test instance attributes with multiple constructor calls. | test_local_runner_config_is_singleton | python | kubeflow/pipelines | sdk/python/kfp/local/config_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/config_test.py | Apache-2.0 |
def test_init_more_than_once(self):
"""Tests config instance attributes with one init() call."""
local.init(
pipeline_root='my/local/root',
runner=local.SubprocessRunner(use_venv=True),
)
instance = config.LocalExecutionConfig.instance
self.assertEqual(i... | Tests config instance attributes with one init() call. | test_init_more_than_once | python | kubeflow/pipelines | sdk/python/kfp/local/config_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/config_test.py | Apache-2.0 |
def test_init_more_than_once(self):
"""Test config instance attributes with multiple init() calls."""
local.init(
pipeline_root='my/local/root',
runner=local.SubprocessRunner(),
)
local.init(
pipeline_root='other/local/root',
runner=local.S... | Test config instance attributes with multiple init() calls. | test_init_more_than_once | python | kubeflow/pipelines | sdk/python/kfp/local/config_test.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/config_test.py | Apache-2.0 |
def join_user_inputs_and_defaults(
dag_arguments: Dict[str, Any],
dag_inputs_spec: pipeline_spec_pb2.ComponentInputsSpec,
) -> Dict[str, Any]:
"""Collects user-provided arguments and default arguments (when no user-
provided argument) into a dictionary. Returns the dictionary.
Args:
dag_arg... | Collects user-provided arguments and default arguments (when no user-
provided argument) into a dictionary. Returns the dictionary.
Args:
dag_arguments: The user-provided arguments to the DAG.
dag_inputs_spec: The ComponentInputSpec for the DAG.
Returns:
The complete DAG inputs, wi... | join_user_inputs_and_defaults | python | kubeflow/pipelines | sdk/python/kfp/local/dag_orchestrator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/dag_orchestrator.py | Apache-2.0 |
def make_task_arguments(
task_inputs_spec: pipeline_spec_pb2.TaskInputsSpec,
io_store: io.IOStore,
) -> Dict[str, Any]:
"""Obtains a dictionary of arguments required to execute the task
corresponding to TaskInputsSpec.
Args:
task_inputs_spec: The TaskInputsSpec for the task.
io_stor... | Obtains a dictionary of arguments required to execute the task
corresponding to TaskInputsSpec.
Args:
task_inputs_spec: The TaskInputsSpec for the task.
io_store: The IOStore of the current DAG. Used to obtain task arguments which come from upstream task outputs and parent component inputs.
... | make_task_arguments | python | kubeflow/pipelines | sdk/python/kfp/local/dag_orchestrator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/dag_orchestrator.py | Apache-2.0 |
def get_dag_output_parameters(
dag_outputs_spec: pipeline_spec_pb2.DagOutputsSpec,
io_store: io.IOStore,
) -> Dict[str, Any]:
"""Gets the DAG output parameter values from a DagOutputsSpec and the DAG's
IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_stor... | Gets the DAG output parameter values from a DagOutputsSpec and the DAG's
IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_store: IOStore corresponding to the DAG.
Returns:
The DAG output parameters.
| get_dag_output_parameters | python | kubeflow/pipelines | sdk/python/kfp/local/dag_orchestrator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/dag_orchestrator.py | Apache-2.0 |
def get_dag_output_artifacts(
dag_outputs_spec: pipeline_spec_pb2.DagOutputsSpec,
io_store: io.IOStore,
) -> Dict[str, Any]:
"""Gets the DAG output artifact values from a DagOutputsSpec and the DAG's
IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_store:... | Gets the DAG output artifact values from a DagOutputsSpec and the DAG's
IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_store: IOStore corresponding to the DAG.
Returns:
The DAG output artifacts.
| get_dag_output_artifacts | python | kubeflow/pipelines | sdk/python/kfp/local/dag_orchestrator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/dag_orchestrator.py | Apache-2.0 |
def get_dag_outputs(
dag_outputs_spec: pipeline_spec_pb2.DagOutputsSpec,
io_store: io.IOStore,
) -> Dict[str, Any]:
"""Gets the DAG output values from a DagOutputsSpec and the DAG's IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_store: IOStore corresponding... | Gets the DAG output values from a DagOutputsSpec and the DAG's IOStore.
Args:
dag_outputs_spec: DagOutputsSpec corresponding to the DAG.
io_store: IOStore corresponding to the DAG.
Returns:
The DAG outputs.
| get_dag_outputs | python | kubeflow/pipelines | sdk/python/kfp/local/dag_orchestrator.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/dag_orchestrator.py | Apache-2.0 |
def get_volumes_to_mount(self) -> Dict[str, Any]:
"""Gets the volume configuration to mount the pipeline root to the
container so that outputs can be obtained outside of the container."""
if not os.path.isabs(self.pipeline_root):
# defensive check. this is enforced by upstream code.
... | Gets the volume configuration to mount the pipeline root to the
container so that outputs can be obtained outside of the container. | get_volumes_to_mount | python | kubeflow/pipelines | sdk/python/kfp/local/docker_task_handler.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/docker_task_handler.py | Apache-2.0 |
def run(self) -> status.Status:
"""Runs the Docker container and returns the status."""
# nest docker import in case not available in user env so that
# this module is runnable, even if not using DockerRunner
import docker
client = docker.from_env()
try:
volum... | Runs the Docker container and returns the status. | run | python | kubeflow/pipelines | sdk/python/kfp/local/docker_task_handler.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/docker_task_handler.py | Apache-2.0 |
def construct_executor_input(
component_spec: pipeline_spec_pb2.ComponentSpec,
arguments: Dict[str, Any],
task_root: str,
block_input_artifact: bool,
) -> pipeline_spec_pb2.ExecutorInput:
"""Constructs the executor input message for a task execution."""
input_parameter_keys = list(
compo... | Constructs the executor input message for a task execution. | construct_executor_input | python | kubeflow/pipelines | sdk/python/kfp/local/executor_input_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/executor_input_utils.py | Apache-2.0 |
def construct_local_task_root(
pipeline_root: str,
pipeline_resource_name: str,
task_resource_name: str,
) -> str:
"""Constructs the local task root directory for a task."""
return os.path.join(
pipeline_root,
pipeline_resource_name,
task_resource_name,
) | Constructs the local task root directory for a task. | construct_local_task_root | python | kubeflow/pipelines | sdk/python/kfp/local/executor_input_utils.py | https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/local/executor_input_utils.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.