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

DbtShellTask #2526

Merged
merged 12 commits into from
May 11, 2020
Merged

DbtShellTask #2526

merged 12 commits into from
May 11, 2020

Conversation

mhmcdonald
Copy link

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including docs/outline.toml for API reference docs (if appropriate)

Note that your PR will not be reviewed unless all three boxes are checked.

What does this PR change?

Adds a DbtShellTask, an extension of the ShellTask, to the task library. This task is intended for working with dbt

Why is this PR important?

The dbt community is very strong and growing in the cloud data warehousing space. There is a lot of potential overlap between the prefect and dbt communities.

@jlowin
Copy link
Member

jlowin commented May 8, 2020

Thanks for the contribution @mhmcdonald! Awesome to see DBT get some first-class representation

@joshmeek
Copy link

joshmeek commented May 8, 2020

Weird test failures 🤔all look to be related to logging in some way. I attempted to reproduce using this branch on a fresh conda env but everything was passing for me locally. cc @cicdw any ideas?

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

A few requests for test hygene changes -- this is great though! I have a feeling this is going to be a very popular task

@joshmeek
Copy link

joshmeek commented May 11, 2020

@mhmcdonald I think we've narrowed down why logging related tests are failing on this branch. It appears that the dbt library modifies global logging settings when imported

https://github.com/fishtown-analytics/dbt/blob/8686ab9a9ddffb63b64d3ee2861f132bf77f54c1/core/dbt/logger.py#L362-L363

# redirect stdlib logging to logbook
_redirect_std_logging()

which in the tests is causing all logs to be redirected elsewhere. Since the dbt library isn't actually used in these tasks and they shell out to using the CLI instead I think we should remove the dependency and instead add some type of CLI check where the importorskip is in order to determine if dbt is installed. Maybe doing something like the following:

from shutil import which
if which("dbt"):
    # good to go

If updated we can see if this resolves the test failures 😄

@codecov
Copy link

codecov bot commented May 11, 2020

Codecov Report

Merging #2526 into master will increase coverage by 2.69%.
The diff coverage is 100.00%.

Copy link

@joshmeek joshmeek left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

Awesome!

from shutil import which
import pytest

if not which("dbt"):
Copy link
Member

Choose a reason for hiding this comment

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

clever

@joshmeek joshmeek merged commit 7ac5256 into PrefectHQ:master May 11, 2020
abrookins pushed a commit that referenced this pull request Jul 27, 2022
Ensure IntervalSchedules have timezones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants