Giuseppe17
Giuseppe17

Reputation: 75

ImportError: cannot import name 'firestore'

I'm doing a dataflow streaming app that would write in firestore, when I run on DirectRunner it works, but when I run on DataflowRunner it doesn't works. what is the error? my requirements.txt is:

apache-beam[gcp,test]==2.19.0
google-cloud-pubsub
google-cloud-firestore==0.29.0

the row of code that throws the exeption is:

from google.cloud import firestore
db = firestore.Client(project=project)

Upvotes: 0

Views: 1126

Answers (1)

Jayadeep Jayaraman
Jayadeep Jayaraman

Reputation: 2825

This is documented in the Dataflow FAQ, there are few ways to handle this

  1. Use import statement inside the function definition
  2. Set save_main_session to True in the Pipeline Options
  3. Define the dependencies and organize your folder structure appropriately with requirements.txt and setup.py files

More details can be found here - https://cloud.google.com/dataflow/docs/resources/faq#how_do_i_handle_nameerrors

Upvotes: 1

Related Questions