Darren Zou
Darren Zou

Reputation: 143

How to use different buckets in GCS python?

I have:

bucket_name = os.environ.get(
            'mosaictest', app_identity.get_default_gcs_bucket_name())

But It would always show the default gcs bucket(for me it is "{project id}.appspot.com" instead of 'mosaictest'(I created this bucket) how do I use the "mosaictest' bucket?

Upvotes: 0

Views: 250

Answers (2)

Darren Zou
Darren Zou

Reputation: 143

I am an idiot just write: bucket_name={literally name the bucket you want to use lol}

Upvotes: 1

Kolban
Kolban

Reputation: 15246

Your code retrieves the value of an environment variable called mosaictest and uses the value of that variable. If the variable is not set, then you will get the default value as returned from the get_default_gcs_bucket_name() function call. If you are finding that you are getting the default value then it is likely your environment variable is not set. You didn't specify how you might have been setting it in your original post. In Linux, you would do something like:

export mosaictest=MYVALUE
python myapp.py

Upvotes: 1

Related Questions