Search code examples
pythongoogle-cloud-platformgoogle-cloud-automl

how to set two os.environ in one single flask project


i have a project in gogole cloud with automl vision , and another project in google cloud automl tables, but i have two os.environ

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='path/to/my/fileVisionKey.json'

and

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]='path/to/my/fileTablesKey.json'

for each project. Please can i gather them in one single app.py instead of separate them into different flask project.


Solution

  • You'll need to specify these files separately when instantiating the the clients for these APIs, rather than using the environment variable.

    from google.cloud import automl_v1beta1 as automl
    
    vision_client = automl.AutoMlClient.from_service_account_json('path/to/my/fileVisionKey.json')
    tables_client = automl.AutoMlClient.from_service_account_json('path/to/my/fileTablesKey.json')