Skip to content

Commit

Permalink
Don't promote tests (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxHalford authored Jan 7, 2025
1 parent 5f3375c commit 4b9f27e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lea/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def app():

@app.command()
@click.option("--select", "-m", multiple=True, default=["*"], help="Scripts to materialize.")
@click.option("--unselect", "-m", multiple=True, default=[], help="Scripts to unselect.")
@click.option("--dataset", default=None, help="Name of the base dataset.")
@click.option("--scripts", default="views", help="Directory where the scripts are located.")
@click.option(
Expand All @@ -26,7 +27,7 @@ def app():
"--production", is_flag=True, default=False, help="Whether to run the scripts in production."
)
@click.option("--restart", is_flag=True, default=False, help="Whether to restart from scratch.")
def run(select, dataset, scripts, incremental, dry, print, production, restart):
def run(select, unselect, dataset, scripts, incremental, dry, print, production, restart):
if not pathlib.Path(scripts).is_dir():
raise click.ClickException(f"Directory {scripts} does not exist")

Expand All @@ -41,7 +42,8 @@ def run(select, dataset, scripts, incremental, dry, print, production, restart):

conductor = lea.Conductor(scripts_dir=scripts, dataset_name=dataset)
conductor.run(
*select,
select=select,
unselect=unselect,
production=production,
dry_run=dry,
restart=restart,
Expand Down
14 changes: 11 additions & 3 deletions lea/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ def list_existing_audit_tables(

def run(
self,
*query: str,
select: list[str],
unselect: list[str],
production: bool = False,
dry_run: bool = False,
restart: bool = False,
Expand All @@ -487,9 +488,14 @@ def run(
database_client = self.make_client(dry_run=dry_run, print_mode=print_mode)

# We need to select the scripts we want to run. We do this by querying the DAG.
selected_table_refs = self.dag.select(*query)
selected_table_refs = self.dag.select(*select)
unselected_table_refs = self.dag.select(*unselect)
selected_table_refs -= unselected_table_refs
if not selected_table_refs:
log.error("Nothing found for query: " + ", ".join(query))
msg = "Nothing found for select " + ", ".join(select)
if unselect:
msg += " and unselect: " + ", ".join(unselect)
log.error(msg)
return sys.exit(1)
log.info(f"{len(selected_table_refs):,d} scripts selected")

Expand Down Expand Up @@ -600,6 +606,8 @@ def promote_audit_tables(session: Session):
# generator expression, the loop would be infinite because jobs are being added to
# session.jobs when session.promote is called.
for selected_table_ref in session.selected_table_refs:
if selected_table_ref.is_test:
continue
selected_table_ref = session.add_write_context_to_table_ref(selected_table_ref)
future = session.executor.submit(session.promote_audit_table, selected_table_ref)
session.promote_audit_tables_futures[future] = selected_table_ref
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "lea-cli"
packages = [
{include = "lea", from = "."},
]
version = "0.6.5"
version = "0.7.0"

[tool.poetry.dependencies]
click = "^8.1.7"
Expand Down

0 comments on commit 4b9f27e

Please sign in to comment.