pelayorodriguezgarcia opened a new issue #9389:
URL: https://github.com/apache/airflow/issues/9389


   I have the following code:
   
   `import os
   
   from airflow import models
   from airflow.providers.google.cloud.operators.bigquery import (
       BigQueryCreateEmptyDatasetOperator, BigQueryDeleteDatasetOperator,
   )
   from airflow.utils.dates import days_ago
   
   PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "project_id")
   DATASET_NAME = os.environ.get("GCP_BIGQUERY_DATASET_NAME", "dataset_id")
   
   default_args = {"start_date": days_ago(1)}
   
   with models.DAG( "test_dag" , default_args=default_args , 
schedule_interval=None , tags=["testing"] ) as dag:
   
       create_dataset = BigQueryCreateEmptyDatasetOperator(
           task_id="create_dataset", dataset_id=DATASET_NAME
       )
   
       delete_dataset = BigQueryDeleteDatasetOperator(
           task_id="delete_dataset", dataset_id=DATASET_NAME, 
delete_contents=True
       )
   
       create_dataset >> delete_dataset`
   
   I just want to debug my Airflow connection with Google Cloud, creating a 
dataset and then removing it. I am currently getting this error:
   
   `Traceback (most recent call last):
     File "/home/airflow/.local/bin/airflow", line 10, in <module>
       sys.exit(main())
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/__main__.py", line 
40, in main
       args.func(args)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/cli/cli_parser.py", 
line 52, in command
       return func(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/cli.py", line 
84, in wrapper
       return f(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/cli/commands/task_command.py",
 line 341, in task_test
       ti.run(ignore_task_deps=True, ignore_ti_state=True, test_mode=True)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/session.py", 
line 61, in wrapper
       return func(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py",
 line 1153, in run
       session=session)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/session.py", 
line 57, in wrapper
       return func(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py",
 line 1028, in _run_raw_task
       result = task_copy.execute(context=context)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/providers/google/cloud/operators/bigquery.py",
 line 1223, in execute
       exists_ok=False,
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/providers/google/common/hooks/base_google.py",
 line 356, in inner_wrapper
       return func(self, *args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/providers/google/cloud/hooks/bigquery.py",
 line 401, in create_empty_dataset
       self.get_client(location=location).create_dataset(dataset=dataset, 
exists_ok=exists_ok)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/providers/google/cloud/hooks/bigquery.py",
 line 124, in get_client
       credentials=self._get_credentials()
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/cloud/bigquery/client.py",
 line 177, in __init__
       project=project, credentials=credentials, _http=_http
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/cloud/client.py", line 
226, in __init__
       _ClientProjectMixin.__init__(self, project=project)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/cloud/client.py", line 
178, in __init__
       project = self._determine_default(project)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/cloud/client.py", line 
193, in _determine_default
       return _determine_default_project(project)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/cloud/_helpers.py", 
line 186, in _determine_default_project
       _, project = google.auth.default()
     File 
"/home/airflow/.local/lib/python3.6/site-packages/google/auth/_default.py", 
line 321, 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
   `
   The problem here is that every path i set to this env variable, Im gettin 
same error **"google.auth.exceptions.DefaultCredentialsError: File  was not 
found"**
   
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to