-
Notifications
You must be signed in to change notification settings - Fork 134
Refactor dbt utility for modularity #1095
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
108c157
Refactored dbt utility for modularity
austinweisgrau bc45ffc
Enhanced log message for source freshness errors + warns
austinweisgrau d86f250
fix linting
austinweisgrau d8e16d3
skip load if table is empty
austinweisgrau 8d56b8a
hook docs for dbt utilities
austinweisgrau 6d09cb1
Remove obsolete line of documentation
austinweisgrau 1e7866b
Merge branch 'main' into dbt_bq
austinweisgrau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """Utility for running and logging output from dbt commands | ||
|
|
||
| Enable this utility by installing parsons with a dbt extra: | ||
| `pip install parsons[dbt-redshift]` | ||
| or `pip install parsons[dbt-postgres]` | ||
| or `pip install parsons[dbt-snowflake]` | ||
| or `pip install parsons[dbt-bigquery]` | ||
|
|
||
| To run dbt commands, you will need to have a dbt project directory | ||
| somewhere on the local filesystem. | ||
|
|
||
| The dbt command will inherit environment variables from the python | ||
| process shell, so if your dbt profiles.yml file uses environment | ||
| variables, ensure those are set in python or the parent shell before | ||
| running this dbt utility. | ||
|
|
||
| Logging is handled separately from the dbt run itself. The | ||
| dbtRunner.run method returns a dbtCommandResult object which can be | ||
| passed to a child class of dbtLogger for logging to stdout, slack, | ||
| etc. | ||
|
|
||
| Parsons provides a few example dbtLogger child classes, but for | ||
| best results, design your own! | ||
|
|
||
| Example usage: | ||
| ``` | ||
| from parsons.utilities.dbt import ( | ||
| run_dbt_commands, | ||
| dbtLoggerSlack, | ||
| dbtLoggerPython | ||
| ) | ||
|
|
||
| run_dbt_commands( | ||
| commands=['run', 'test'], | ||
| dbt_project_directory='/home/ubuntu/code/dbt_project/', | ||
| loggers=[ | ||
| dbtLoggerPython, | ||
| dbtLoggerSlack(slack_webhook=os.environ['SLACK_WEBHOOK']) | ||
| ] | ||
| ) | ||
|
|
||
| ``` | ||
|
|
||
| """ | ||
|
|
||
| from parsons.utilities.dbt.dbt import run_dbt_commands | ||
| from parsons.utilities.dbt.logging import ( | ||
| dbtLoggerMarkdown, | ||
| dbtLoggerPython, | ||
| dbtLoggerSlack, | ||
| dbtLoggerStdout, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "run_dbt_commands", | ||
| "dbtLoggerMarkdown", | ||
| "dbtLoggerSlack", | ||
| "dbtLoggerStdout", | ||
| "dbtLoggerPython", | ||
| ] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These docs are good, but ideally we want to be able to surface them on the docs website. Maybe add a hook into the autodocs on this page? https://move-coop.github.io/parsons/html/stable/utilities.html#
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 thiiink 8d56b8a should do this