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

Some cleanups to dbtshelltask #2980

Merged
merged 5 commits into from
Jul 20, 2020
Merged

Some cleanups to dbtshelltask #2980

merged 5 commits into from
Jul 20, 2020

Conversation

lauralorenz
Copy link

@lauralorenz lauralorenz commented Jul 16, 2020

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • add a changelog entry in the changes/ directory (if appropriate)
  • [n/a] 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?

First off, adds return that I think just got missed in the original dbtshelltask. Otherwise the stdout from dbt being run in the shell is not retrieved as the return value of the task, against what is says in its docstrings and the intention of ShellTask itself and presumably its derivatives. This was brought up in this slack thread: https://prefect-community.slack.com/archives/CL09KU1K7/p1594912760250100

While writing tests I realized that the super method was also failing to forward command and env kwargs which made the @default_from_attrs functionality not work properly for those two, so I fixed that too.

And while running tests that actually called dbt I realized that it wasn't being added as an extras option in setup.py (and thus it wasn't really possible to meaningfully run the tests on CI) so I've added that as well.

Why is this PR important?

So that people can use the stdout from the DbtShellTask for anything downstream.

@codecov
Copy link

codecov bot commented Jul 16, 2020

Codecov Report

Merging #2980 into master will increase coverage by 0.00%.
The diff coverage is 76.47%.

@@ -86,10 +86,12 @@ def __init__(
self.dbt_kwargs = dbt_kwargs
super().__init__(
**kwargs,
command=command,
Copy link
Author

Choose a reason for hiding this comment

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

FYI command and env weren't being forwarded here and thus were overwritten to None in the super method, so they couldn't be provided at initialization

# when set to `return_all=True`, should return a list
assert isinstance(out, list)
# check that the result is multiple lines
assert len(out) > 1
Copy link
Author

Choose a reason for hiding this comment

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

FYI the output of dbt --version I am depending on looks like this:

(prefect_dev) ➜  prefect git:(cleanup-on-dbt-task-return) dbt --version
installed version: 0.17.1
   latest version: 0.17.1

Up to date!

Plugins:
  - bigquery: 0.17.1
  - snowflake: 0.17.1
  - redshift: 0.17.1
  - postgres: 0.17.1

@lauralorenz lauralorenz changed the title Add return to dbtshelltask to return stdout Some cleanups to dbtshelltask Jul 20, 2020
@lauralorenz lauralorenz marked this pull request as ready for review July 20, 2020 19:14
@jcrist jcrist merged commit def8b20 into master Jul 20, 2020
@jcrist jcrist deleted the cleanup-on-dbt-task-return branch July 20, 2020 22:57
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.

3 participants