Skip to content

Commit

Permalink
Renamed InputArtifactArgument to InputArgumentPath
Browse files Browse the repository at this point in the history
Also renamed input_artifact_arguments to artifact_argument_paths in the ContainerOp's constructor
  • Loading branch information
Ark-kun committed Aug 28, 2019
1 parent 6bd95bd commit 582b6cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion sdk/python/kfp/dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from ._pipeline_param import PipelineParam, match_serialized_pipelineparam
from ._pipeline import Pipeline, pipeline, get_pipeline_conf
from ._container_op import ContainerOp, InputArtifactArgument, UserContainer, Sidecar
from ._container_op import ContainerOp, InputArgumentPath, UserContainer, Sidecar
from ._resource_op import ResourceOp
from ._volume_op import (
VolumeOp, VOLUME_MODE_RWO, VOLUME_MODE_RWM, VOLUME_MODE_ROM
Expand Down
13 changes: 7 additions & 6 deletions sdk/python/kfp/dsl/_container_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ def __repr__(self):
from ._pipeline_volume import PipelineVolume # The import is here to prevent circular reference problems.


class InputArtifactArgument:
class InputArgumentPath:
def __init__(self, argument, input=None, path=None):
self.argument = argument
self.input = input
Expand Down Expand Up @@ -968,7 +968,7 @@ def __init__(
init_containers: List[UserContainer] = None,
sidecars: List[Sidecar] = None,
container_kwargs: Dict = None,
input_artifact_arguments : List[InputArtifactArgument] = None,
artifact_argument_paths : List[InputArgumentPath] = None,
file_outputs: Dict[str, str] = None,
output_artifact_paths : Dict[str, str]=None,
artifact_location: V1alpha1ArtifactLocation=None,
Expand All @@ -992,9 +992,10 @@ def __init__(
together with the `main` container.
container_kwargs: the dict of additional keyword arguments to pass to the
op's `Container` definition.
input_artifact_arguments: Maps artifact inputs to the artifact argument values and paths.
Only artifact argument value is required.
artifact_argument_paths: Optional. Maps input artifact arguments (values or references) to the local file paths where they'll be placed.
At pipeline run time, the value of the artifact argument is saved to a local file with specified path.
This parameter is only needed when the input file paths are hard-coded in the program.
Otherwise it's better to pass input artifact placement paths by including artifact arguments in the command-line using the InputArgumentPath class instances.
file_outputs: Maps output labels to local file paths. At pipeline run time,
the value of a PipelineParam is saved to its corresponding local file. It's
one way for outside world to receive outputs of the container.
Expand All @@ -1019,7 +1020,7 @@ def __init__(

def resolve_artifact_argument(artarg):
from ..components._components import _generate_input_file_name
if not isinstance(artarg, InputArtifactArgument):
if not isinstance(artarg, InputArgumentPath):
return artarg
input_name = getattr(artarg.input, 'name', artarg.input) or ('input-' + str(len(artifact_arguments)))
input_path = artarg.path or _generate_input_file_name(input_name)
Expand All @@ -1030,7 +1031,7 @@ def resolve_artifact_argument(artarg):
artifact_arguments[input_name] = artarg.argument
return input_path

for artarg in input_artifact_arguments or []:
for artarg in artifact_argument_paths or []:
resolve_artifact_argument(artarg)

if isinstance(command, Sequence) and not isinstance(command, str):
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/tests/compiler/testdata/input_artifact_raw_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def component_with_inline_input_artifact(text: str):
return dsl.ContainerOp(
name='component_with_inline_input_artifact',
image='alpine',
command=['cat', dsl.InputArtifactArgument(text, path='/tmp/inputs/text/data', input='text')], # path and input are optional
command=['cat', dsl.InputArgumentPath(str(text), path='/tmp/inputs/text/data', input='text')], # path and input are optional
)


Expand All @@ -36,8 +36,8 @@ def component_with_input_artifact(text):

return dsl.ContainerOp(
name='component_with_input_artifact',
input_artifact_arguments=[
dsl.InputArtifactArgument(argument=text, path='/tmp/inputs/text/data', input='text'), # path and input are optional
artifact_argument_paths=[
dsl.InputArgumentPath(argument=str(text), path='/tmp/inputs/text/data', input='text'), # path and input are optional
],
image='alpine',
command=['cat', '/tmp/inputs/text/data'],
Expand All @@ -57,7 +57,7 @@ def component_with_input_artifact_value_from_file(file_path):
name='Pipeline with artifact input raw argument value.',
description='Pipeline shows how to define artifact inputs and pass raw artifacts to them.'
)
def retry_sample_pipeline():
def input_artifact_pipeline():
component_with_inline_input_artifact('Constant artifact value')
component_with_input_artifact('Constant artifact value')
component_with_hardcoded_input_artifact_value()
Expand All @@ -66,4 +66,4 @@ def retry_sample_pipeline():
component_with_input_artifact_value_from_file(file_path)

if __name__ == '__main__':
kfp.compiler.Compiler().compile(retry_sample_pipeline, __file__ + '.yaml')
kfp.compiler.Compiler().compile(input_artifact_pipeline, __file__ + '.yaml')

0 comments on commit 582b6cd

Please sign in to comment.