Justin Albinet
05/12/2023, 4:53 PMBigQueryResource
(and it works like a charm 🎉 ) but if I then try to add an io_manager linked to BigQuery on the same asset I have the following error: Resource config error: gcp_credentials config for BigQuery resource cannot be used if GOOGLE_APPLICATION_CREDENTIALS environment variable is set.
My asset is declared this way:
@asset(io_manager_key="bigquery_io_manager")
def apiBatch(bigquery: BigQueryResource):
And my definition is:
defs = Definitions(
assets = all_assets,
resources={
"bigquery": BigQueryResource(
project = "PROJECT",
location = "EU",
gcp_credentials = EnvVar("GCP_CREDS"),
),
"bigquery_io_manager": BigQueryPandasIOManager(
project="PROJECT",
location="EU",
dataset="mydataset",
gcp_credentials = EnvVar("GCP_CREDS"),
timeout=15.0,
)
},
)
I don't have this issue if I declare the io_manager_key to another asset; is it normal?Qwame
05/12/2023, 5:49 PMGOOGLE_APPLICATION_CREDENTIALS
set so you cannot have the line
gcp_credentials=EnvVar("GCP_CREDS")
in the bigqueryPandasIOManager configurationQwame
05/12/2023, 5:49 PMJustin Albinet
05/12/2023, 5:53 PMQwame
05/12/2023, 5:57 PMgcp_credential
argument override the GOOGLE_APPLICATION_CREDENTIALS
when it is set cc @jamiejamie
05/12/2023, 5:57 PMjamie
05/12/2023, 5:59 PMQwame
05/12/2023, 6:00 PMjamie
05/12/2023, 7:10 PMjamie
05/12/2023, 7:11 PMQwame
05/12/2023, 7:29 PMJustin Albinet
05/15/2023, 8:55 AMgcp_credentials
on bigquery_io_manager
and I no longer have the error at the initialization of the code but I have a new one when it's supposed to load data to BigQuery:
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see <https://cloud.google.com/docs/authentication/external/set-up-adc> for more information.
Seems like this way it's not finding the credentials 🤔Qwame
05/15/2023, 1:07 PMJustin Albinet
05/15/2023, 1:08 PMQwame
05/15/2023, 1:10 PMGOOGLE_APPLICATION_CREDENTIALS
and the value will be the path to the service account. Without a service account, download the google-cloud-sdk and just do gcloud auth login
Qwame
05/15/2023, 1:13 PMJustin Albinet
05/15/2023, 1:13 PMJustin Albinet
05/15/2023, 1:31 PM@asset
def getBigQuery(bigquery: BigQueryResource) -> pd.DataFrame:
with bigquery.get_client() as client:
df = client.query(
(
'SELECT * FROM testTable'
),
).to_dataframe()
<http://logger.info|logger.info>(df.head())
return df
@asset(io_manager_key="bigquery_io_manager")
def testExportDagster(getBigQuery: pd.DataFrame):
return getBigQuery.dropna().drop_duplicates()
But the following code gives me the error `Resource config error: gcp_credentials config for BigQuery resource cannot be used if GOOGLE_APPLICATION_CREDENTIALS environment variable is set.`if I declare gcp_credentials on bigquery & bigquer_io_manager OR google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see <https://cloud.google.com/docs/authentication/external/set-up-adc> for more information.
if I remove the gcp_credentials from "bigquery_io_manager" as you proposed:
@asset(io_manager_key="bigquery_io_manager")
def testExportDagster(bigquery: BigQueryResource):
with bigquery.get_client() as client:
df = client.query(
(
'SELECT * FROM testTable'
),
).to_dataframe()
<http://logger.info|logger.info>(df.head())
return df.dropna().drop_duplicates()
jamie
05/15/2023, 3:07 PMjamie
05/15/2023, 3:07 PMJustin Albinet
05/15/2023, 3:11 PMHector
10/11/2023, 5:56 PM