-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated credentials docs "Added section Destination configuration via Python" #2182
base: devel
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for dlt-hub-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Sorry for this, but can you move this section to this page: https://deploy-preview-2182--dlt-hub-docs.netlify.app/docs/devel/general-usage/credentials/advanced#write-configs-and-secrets-in-code |
|
||
## Destination configuration via Python | ||
|
||
In addition to configuring credentials for sources, you can configure credentials directly for your **destination** in Python code. Below is an example of using **GcpServiceAccountCredentials** within a Google Colab environment to set up a pipeline writing to BigQuery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove please info about Colab, it would be less confusing with simple os.getenv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import os | ||
from google.colab import userdata | ||
|
||
creds_dict = userdata.get('BIGQUERY_CREDENTIALS') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREDS_DICT = os.getenv("BIGQUERY_CREDENTIALS")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -386,6 +386,33 @@ This applies not only to credentials but to [all specs](#writing-custom-specs). | |||
Check out the [complete example](https://github.com/dlt-hub/dlt/blob/devel/tests/common/configuration/test_spec_union.py), to learn how to create unions of credentials that derive from the common class, so you can handle it seamlessly in your code. | |||
::: | |||
|
|||
Below is an example of how you might include the snippet under a new heading, **"Destination configuration via Python"**, while preserving the same tone, formatting, and writing structure as in the original doc. You can place this new heading, for instance, right after the [**"Working with alternatives of credentials (Union types)"**](#working-with-alternatives-of-credentials-union-types) section or at the very end of the document—whichever fits best with your overall documentation flow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is some extra chat gpt line, remove pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed sorry
pipeline.run([{"key1": "value1"}], table_name="temp") | ||
``` | ||
|
||
Above, we retrieve the service account credentials from Colab’s `userdata`, parse them, and attach them to the pipeline’s destination. This pattern applies to any other **CredentialsConfiguration** you wish to pass to your destination. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this section to this section: https://deploy-preview-2182--dlt-hub-docs.netlify.app/docs/devel/general-usage/credentials/advanced#write-configs-and-secrets-in-code
also link GcpServiceAccountCredentials: https://deploy-preview-2182--dlt-hub-docs.netlify.app/docs/devel/general-usage/credentials/complex_types#gcp-credentials
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
Description
Updated credentials docs "Added section Destination configuration via Python"