Skip to content

Commit

Permalink
Merge 468f44a into 21869d6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-kun committed Nov 12, 2018
2 parents 21869d6 + 468f44a commit c11dc51
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions sdk/python/kfp/compiler/_component_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,31 @@ class GCSHelper(object):
""" GCSHelper manages the connection with the GCS storage """

@staticmethod
def upload_gcs_file(local_path, gcs_path):
def get_blob_from_gcs_uri(gcs_path):
from google.cloud import storage
pure_path = PurePath(gcs_path)
gcs_bucket = pure_path.parts[1]
gcs_blob = '/'.join(pure_path.parts[2:])
client = storage.Client()
bucket = client.get_bucket(gcs_bucket)
bucket = client.bucket(gcs_bucket)
blob = bucket.blob(gcs_blob)
return blob

@staticmethod
def upload_gcs_file(local_path, gcs_path):
blob = GCSHelper.get_blob_from_gcs_uri(gcs_path)
blob.upload_from_filename(local_path)

@staticmethod
def remove_gcs_blob(gcs_path):
pure_path = PurePath(gcs_path)
gcs_bucket = pure_path.parts[1]
gcs_blob = '/'.join(pure_path.parts[2:])
client = storage.Client()
bucket = client.get_bucket(gcs_bucket)
blob = bucket.blob(gcs_blob)
blob = GCSHelper.get_blob_from_gcs_uri(gcs_path)
blob.delete()

@staticmethod
def download_gcs_blob(local_path, gcs_path):
pure_path = PurePath(gcs_path)
gcs_bucket = pure_path.parts[1]
gcs_blob = '/'.join(pure_path.parts[2:])
client = storage.Client()
bucket = client.get_bucket(gcs_bucket)
blob = bucket.blob(gcs_blob)
blob = GCSHelper.get_blob_from_gcs_uri(gcs_path)
blob.download_to_filename(local_path)


class DockerfileHelper(object):
""" Dockerfile Helper generates a tarball with dockerfile, ready for docker build
arc_dockerfile_name: dockerfile filename that is stored in the tarball
Expand Down

0 comments on commit c11dc51

Please sign in to comment.