Skip to content
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

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from

Conversation

dat-a-man
Copy link
Collaborator

Description

Updated credentials docs "Added section Destination configuration via Python"

@dat-a-man dat-a-man added the documentation Improvements or additions to documentation label Jan 1, 2025
Copy link

netlify bot commented Jan 1, 2025

Deploy Preview for dlt-hub-docs ready!

Name Link
🔨 Latest commit cb2faea
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/67777c2eac8cc20008d7467f
😎 Deploy Preview https://deploy-preview-2182--dlt-hub-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AstrakhantsevaAA
Copy link
Contributor


## 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.
Copy link
Contributor

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

Copy link
Collaborator Author

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')
Copy link
Contributor

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")

Copy link
Collaborator Author

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.
Copy link
Contributor

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

Copy link
Collaborator Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants