Skip to content

Commit

Permalink
SDK - Containers - Renamed constructor parameter in the private Conta…
Browse files Browse the repository at this point in the history
…inerBuilder class (#2261)
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Nov 7, 2019
1 parent e5b5b90 commit 6eb00e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions sdk/python/kfp/containers/_container_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ class ContainerBuilder(object):
"""
ContainerBuilder helps build a container image
"""
def __init__(self, gcs_staging=None, gcr_image_tag=None, namespace=None):
def __init__(self, gcs_staging=None, default_image_name=None, namespace=None):
"""
Args:
gcs_staging (str): GCS bucket/blob that can store temporary build files,
default is gs://PROJECT_ID/kfp_container_build_staging.
gcr_image_tag (str): GCR image tag where the target image is pushed
default_image_name (str): Target container image name that will be used by the build method if the target_image argument is not specified.
namespace (str): kubernetes namespace where the pod is launched,
default is the same namespace as the notebook service account in cluster
or 'kubeflow' if not in cluster
"""
self._gcs_staging = gcs_staging
self._gcs_staging_checked = False
self._default_image_name = gcr_image_tag
self._default_image_name = default_image_name
self._namespace = namespace

def _get_namespace(self):
Expand Down Expand Up @@ -164,7 +164,7 @@ def build(self, local_dir, docker_filename : str = 'Dockerfile', target_image=No
Args:
local_dir (str): local directory that stores all the necessary build files
docker_filename (str): the path of the Dockerfile relative to the local_dir
target_image (str): the target image tag to push the final image.
target_image (str): The container image name where the data will be pushed. Can include tag. If not specified, the function will use the default_image_name specified when creating ContainerBuilder.
timeout (int): time out in seconds. Default: 1000
"""
target_image = target_image or self._get_default_image_name()
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/compiler/container_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from kfp.containers._component_builder import ContainerBuilder

GCS_BASE = 'gs://kfp-testing/'
GCR_IMAGE_TAG = 'gcr.io/kfp-testing/image'
DEFAULT_IMAGE_NAME = 'gcr.io/kfp-testing/image'

@mock.patch('kfp.containers._gcs_helper.GCSHelper')
class TestContainerBuild(unittest.TestCase):
Expand All @@ -40,7 +40,7 @@ def test_wrap_dir_in_tarball(self, mock_gcshelper):
f.write('temporary file two content')

# check
builder = ContainerBuilder(gcs_staging=GCS_BASE, gcr_image_tag=GCR_IMAGE_TAG, namespace='')
builder = ContainerBuilder(gcs_staging=GCS_BASE, default_image_name=DEFAULT_IMAGE_NAME, namespace='')
builder._wrap_dir_in_tarball(temp_tarball, test_data_dir)
self.assertTrue(os.path.exists(temp_tarball))
with tarfile.open(temp_tarball) as temp_tarball_handle:
Expand All @@ -58,7 +58,7 @@ def test_generate_kaniko_yaml(self, mock_gcshelper):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testdata')

# check
builder = ContainerBuilder(gcs_staging=GCS_BASE, gcr_image_tag=GCR_IMAGE_TAG, namespace='default')
builder = ContainerBuilder(gcs_staging=GCS_BASE, default_image_name=DEFAULT_IMAGE_NAME, namespace='default')
generated_yaml = builder._generate_kaniko_spec(docker_filename='dockerfile',
context='gs://mlpipeline/kaniko_build.tar.gz', target_image='gcr.io/mlpipeline/kaniko_image:latest')
with open(os.path.join(test_data_dir, 'kaniko.basic.yaml'), 'r') as f:
Expand Down

0 comments on commit 6eb00e7

Please sign in to comment.