Morty
Morty

Reputation: 37

how to set the path to a folder on google storage bucket using google cloud functions?

I'm using Python on Google Cloud Functions. For the package corenlp I need to set the path to the jar folder. I usually do thin on my local computer:

os.environ["CORENLP_HOME"] = r'/home/user/stanfordnlp_resources/stanford-corenlp-latest/stanford-corenlp-4.1.0/'

But how can I do it on Google Cloud Functions? I have uploaded the folder to the bucket and I need to set the path to the folder on the bucket in Python.

Upvotes: 0

Views: 684

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317740

You specify environment variables at the time you deploy with gcloud. Please see the documentation. You will use the --set-env-vars flag.

However, if your library requires a local file to read at runtime, using a reference to a file in Cloud Storage will not work. You would have to download it to /tmp and reference it from there.

Upvotes: 1

Related Questions