-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: bigtableIssues related to the googleapis/python-bigtable API.Issues related to the googleapis/python-bigtable API.triage meI really want to be triaged.I really want to be triaged.
Description
maybe related to:
#184
In the local environment, when the BigTable client is connected to a BigTable Emulator credentials shouldn't be required.
Environment details
- OS type and version: macOS Big Sur v11.0.1
- Python version:
3.7.9 - pip version:
20.1.1 google-cloud-bigtableversion:1.7.0
Steps to reproduce
1. gcloud beta emulators bigtable start
2. env BIGTABLE_EMULATOR_HOST=localhost:8086 python main.py
Code example
# main.py
import os
from google.cloud import bigtable
PROJECT_ID = 'my-project'
BIGTABLE_INSTANCE = 'emulator'
TABLE_ID = 'my-table'
print(f"bigtable emulator: {os.getenv('BIGTABLE_EMULATOR_HOST')}")
def main(project_id="project-id", instance_id="instance-id",
table_id="my-table"):
# Create a Cloud Bigtable client.
client = bigtable.Client(project=project_id)
# Connect to an existing Cloud Bigtable instance.
instance = client.instance(instance_id)
# Open an existing table.
table = instance.table(table_id)
row_key = 'r1'
row = table.read_row(row_key.encode('utf-8'))
column_family_id = 'cf1'
column_id = 'c1'.encode('utf-8')
value = row.cells[column_family_id][column_id][0].value.decode('utf-8')
print('Row key: {}\nData: {}'.format(row_key, value))
if __name__ == '__main__':
main(PROJECT_ID, BIGTABLE_INSTANCE, TABLE_ID)Stack trace
bigtable emulator: localhost:8086
Traceback (most recent call last):
File "main.py", line 33, in <module>
main(PROJECT_ID, BIGTABLE_INSTANCE, TABLE_ID)
File "main.py", line 14, in main
client = bigtable.Client(project=project_id)
File "/Users/xx/Documents/gcloud-playground/bigtable__temp/env/lib/python3.7/site-packages/google/cloud/bigtable/client.py", line 192, in __init__
client_options=client_options,
File "/Users/xx/Documents/gcloud-playground/bigtable__temp/env/lib/python3.7/site-packages/google/cloud/client.py", line 278, in __init__
Client.__init__(self, credentials=credentials, client_options=client_options, _http=_http)
File "/Users/xx/Documents/gcloud-playground/bigtable__temp/env/lib/python3.7/site-packages/google/cloud/client.py", line 153, in __init__
credentials, _ = google.auth.default(scopes=scopes)
File "/Users/xx/Documents/gcloud-playground/bigtable__temp/env/lib/python3.7/site-packages/google/auth/_default.py", line 483, in default
raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
Please help to look into this issue 🙏 Thanks!
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: bigtableIssues related to the googleapis/python-bigtable API.Issues related to the googleapis/python-bigtable API.triage meI really want to be triaged.I really want to be triaged.