Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Component build fix #1703

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions sdk/python/kfp/compiler/_container_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,10 @@ def _generate_kaniko_spec(self, context, docker_filename, target_image):

def _wrap_dir_in_tarball(self, tarball_path, dir_name):
""" _wrap_files_in_tarball creates a tarball for all the files in the directory"""
old_wd = os.getcwd()
os.chdir(dir_name)
if not tarball_path.endswith('.tar.gz'):
raise ValueError('the tarball path should end with .tar.gz')
with tarfile.open(tarball_path, 'w:gz') as tarball:
for f in os.listdir(dir_name):
tarball.add(f)
os.chdir(old_wd)

tarball.add(dir_name, arcname='')

def build(self, local_dir, docker_filename, target_image, timeout):
"""
Expand Down
3 changes: 1 addition & 2 deletions sdk/python/tests/compiler/container_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def test_wrap_dir_in_tarball(self):
self.assertTrue(os.path.exists(temp_tarball))
with tarfile.open(temp_tarball) as temp_tarball_handle:
temp_files = temp_tarball_handle.getmembers()
self.assertTrue(len(temp_files) == 2)
for temp_file in temp_files:
self.assertTrue(temp_file.name in ['test_data_one.tmp', 'test_data_two.tmp'])
self.assertTrue(temp_file.name in ['test_data_one.tmp', 'test_data_two.tmp', ''])

# clean up
os.remove(temp_tarball)
Expand Down