Created
February 28, 2021 17:33
-
-
Save Geremie/81a52472f26bdee772d71aed3d1afbd9 to your computer and use it in GitHub Desktop.
Never struggle again to share data between your Kubeflow Pipelines components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_model_location(bucket_name: str, model_folder: str) -> NamedTuple('returns', [('location', 'GCSPath')]): | |
from google.cloud import storage | |
folder = 'model/{}/export/exporter/'.format(model_folder) | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(bucket_name) | |
blobs = bucket.list_blobs(prefix=folder) | |
blob_name = None | |
for blob in blobs: | |
tmp = len(blob.name.rstrip('/').split('/')) | |
if tmp == 5: | |
blob_name = blob.name | |
print('Model location: {}'.format(blob_name)) | |
print('Model full location: gs://{0}/{1}'.format(bucket_name, blob_name)) | |
from collections import namedtuple | |
output = namedtuple('returns', ['location']) | |
return output('gs://{0}/{1}'.format(bucket_name, blob_name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment