Home > Back-end >  Specify the GCP project in tf.io.GFile()
Specify the GCP project in tf.io.GFile()

Time:01-09

Is there a way how to specify the GCP project for downloading some objects using the tf.io.gfile.GFile? I know it can be used like this:

import tensorflow as tf
with tf.io.gfile.GFile("gs://<bucket>/<path>") as f:
    f.read()

but this does not have any parameter for project. I know you can select active project using the CLI tools, but I want to download data from different projects. Is it possible, or do I need to use some other GCS client? If so, which is the most compatible with TF and can be most easily used in tf.function?

CodePudding user response:

Buckets are unique across projects, so although you see only buckets created as a part of a project on the https://console.cloud.google.com/storage/browser?project=<project>&prefix=&forceOnObjectsSortingFiltering=false page, you can query it regardless of the project, so as long as you have access there, you just can access the data without specifying project.

  • Related