def download_blob()

in radlab-launcher/radlab.py [0:0]


def download_blob(projid, tfbucket, prefix, env_path):
    """Downloads a blob from the bucket."""
    try:
        bucket_dir = 'radlab/' + prefix + '/deployments/'
        local_dir = env_path + '/'

        storage_client = storage.Client(project=projid)
        bucket = storage_client.get_bucket(tfbucket)
        blobs = bucket.list_blobs(prefix=bucket_dir)  # Get list of files

        for blob in blobs:
            content = blob.name.replace(bucket_dir, '')
            # Create Nested Folders structure in Local Directory
            if '/' in content:
                if (os.path.isdir(local_dir + os.path.dirname(content)) == False):
                    os.makedirs(local_dir + os.path.dirname(content))
                    # Download file
            blob.download_to_filename(local_dir + content)  # Download
        return True

    except:
        return False