Skip to content

Commit

Permalink
Merge pull request #84 from jakeberesford-palmetto/feature/support-ym…
Browse files Browse the repository at this point in the history
…l-selectors

[FEATURE] Add support for yaml selectors to relevant commands
  • Loading branch information
jakeberesford-palmetto authored Sep 11, 2023
2 parents 073b5b8 + 0042b75 commit bbd3572
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions palm/plugins/dbt/commands/cmd_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
@click.command("compile")
@click.option("--models", "-m", multiple=True, help="See dbt docs on models flag")
@click.option("--select", "-s", multiple=True, help="See dbt docs on select flag")
@click.option("--selector", multiple=True, help="See dbt docs on selector flag")
@click.option("--exclude", "-e", multiple=True, help="See dbt docs on exclude flag")
@click.pass_obj
def cli(
environment,
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
selector: Optional[Tuple] = tuple(),
exclude: Optional[Tuple] = tuple(),
):
"""Compiles the dbt repo"""
Expand All @@ -24,6 +26,9 @@ def cli(
if targets:
cmd.append("--select")
cmd.extend(targets)
if selector:
cmd.append("--selector")
cmd.extend(selector)
if exclude:
cmd.append('--exclude')
cmd.extend(exclude)
Expand Down
7 changes: 7 additions & 0 deletions palm/plugins/dbt/commands/cmd_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@click.option("--clean", is_flag=True, help="Drop the test schema after the run")
@click.option("--models", "-m", multiple=True, help="See dbt docs on models flag")
@click.option("--select", "-s", multiple=True, help="See dbt docs on select flag")
@click.option("--selector", multiple=True, help="See dbt docs on selector flag")
@click.option("--exclude", "-e", multiple=True, help="See dbt docs on exclude flag")
@click.option("--defer", "-d", is_flag=True, help="See dbt docs on defer flag")
@click.option("--iterative", "-i", is_flag=True, help="Iterative stateful dbt run")
Expand All @@ -35,6 +36,7 @@ def cli(
seed: bool,
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
selector: Optional[Tuple] = tuple(),
exclude: Optional[Tuple] = tuple(),
vars: Optional[str] = None,
):
Expand Down Expand Up @@ -67,6 +69,7 @@ def cli(
seed=seed,
no_fail_fast=(no_fail_fast or iterative),
targets=targets,
selector=selector,
exclude=exclude,
defer=defer,
vars=vars,
Expand Down Expand Up @@ -104,6 +107,7 @@ def build_run_command(
seed: bool = True,
no_fail_fast: bool = False,
targets: Optional[list] = None,
selector: Optional[Tuple] = None,
exclude: Optional[Tuple] = None,
defer: bool = False,
vars: Optional[str] = None,
Expand All @@ -119,6 +123,9 @@ def build_run_command(
if targets:
cmd.append("--select")
cmd.extend(targets)
if selector:
cmd.append("--selector")
cmd.extend(selector)
if exclude:
cmd.append("--exclude")
cmd.extend(exclude)
Expand Down
5 changes: 5 additions & 0 deletions palm/plugins/dbt/commands/cmd_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"--clean", is_flag=True, help="drop the test schema after the run is complete"
)
@click.option("--select", '-s', multiple=True, help="see dbt docs on select flag")
@click.option("--selector", multiple=True, help="see dbt docs on selector flag")
@click.option("--exclude", '-e', multiple=True, help="see dbt docs on exclude flag")
@click.option(
"--no-full-refresh",
Expand All @@ -21,6 +22,7 @@ def cli(
clean: bool,
no_full_refresh: bool,
select: Optional[Tuple] = tuple(),
selector: Optional[Tuple] = tuple(),
exclude: Optional[Tuple] = tuple(),
):
"""Run dbt seeds"""
Expand All @@ -29,6 +31,9 @@ def cli(
if select:
cmd.append('--select')
cmd.extend(select)
if selector:
cmd.append('--selector')
cmd.extend(selector)
if exclude:
cmd.append('--exclude')
cmd.extend(exclude)
Expand Down
7 changes: 7 additions & 0 deletions palm/plugins/dbt/commands/cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)
@click.option("--models", "-m", multiple=True, help="See dbt docs on models flag")
@click.option("--select", "-s", multiple=True, help="See dbt docs on select flag")
@click.option("--selector", multiple=True, help="See dbt docs on selector flag")
@click.option("--exclude", "-e", multiple=True, help="See dbt docs on exclude flag")
@click.option("--defer", "-d", is_flag=True, help="See dbt docs on defer flag")
@click.option(
Expand All @@ -23,6 +24,7 @@ def cli(
defer: bool,
models: Optional[Tuple] = tuple(),
select: Optional[Tuple] = tuple(),
selector: Optional[Tuple] = tuple(),
exclude: Optional[Tuple] = tuple(),
):
"""Tests the dbt repo"""
Expand Down Expand Up @@ -50,6 +52,7 @@ def cli(
run_cmd = build_test_command(
no_fail_fast=no_fail_fast,
targets=targets,
selector=selector,
exclude=exclude,
defer=defer,
)
Expand All @@ -67,6 +70,7 @@ def build_test_command(
defer: bool = False,
no_fail_fast: bool = False,
targets: Optional[list] = None,
selector: Optional[Tuple] = None,
exclude: Optional[Tuple] = None,
) -> str:
cmd = []
Expand All @@ -75,6 +79,9 @@ def build_test_command(
if targets:
cmd.append('--select')
cmd.extend(targets)
if selector:
cmd.append('--selector')
cmd.extend(selector)
if exclude:
cmd.append('--exclude')
cmd.extend(exclude)
Expand Down

0 comments on commit bbd3572

Please sign in to comment.