Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Created November 7, 2022 05:05
Show Gist options
  • Save anna-geller/fc4439de9fb59a7038b420831b121c07 to your computer and use it in GitHub Desktop.
Save anna-geller/fc4439de9fb59a7038b420831b121c07 to your computer and use it in GitHub Desktop.
from prefect import flow
from prefect.filesystems import GitHub
from prefect_dbt.cli.commands import trigger_dbt_cli_command
from prefect_dbt.cli.credentials import DbtCliProfile
def dbt(command: str, path: str) -> None:
trigger_dbt_cli_command.with_options(name=command)(
command,
project_dir=path,
overwrite_profiles=True,
dbt_cli_profile=DbtCliProfile.load("default"),
)
@flow(retries=3, retry_delay_seconds=30)
def dbt_jaffle_shop(
dbt_command: str = "dbt compile",
repository: str = "dbt-jaffle-shop",
):
gh = GitHub.load(repository)
gh.get_directory(local_path=repository)
dbt(dbt_command, repository)
if __name__ == "__main__":
dbt_jaffle_shop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment