Skip to content

Commit

Permalink
Add print for shell commands run in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Jan 30, 2025
1 parent 7fd998b commit fe348c7
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions scripts/ci_tests/dbt_metricflow_package_test.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
from __future__ import annotations

import subprocess
import textwrap
from pathlib import Path
from typing import Optional


def _run_shell_command(command: str, cwd: Optional[Path] = None) -> None:
if cwd is None:
cwd = Path.cwd()

print(
textwrap.dedent(
f"""\
Running via shell:
command: {command!r}
cwd: {cwd.as_posix()!r}
"""
).rstrip()
)
subprocess.check_call(command, shell=True, cwd=cwd.as_posix())


if __name__ == "__main__":
# Check that the `mf` command is installed.
print(f"Running from {Path.cwd().as_posix()}")
print("Checking path to python")
subprocess.check_call("which python", shell=True)
subprocess.check_call("mf", shell=True)
_run_shell_command("which python")
_run_shell_command("which mf")
_run_shell_command("mf")
# Run the tutorial using `--yes` to create the sample project without user interaction.
subprocess.check_call("mf tutorial --yes", shell=True)
tutorial_directory = Path.cwd().joinpath("mf_tutorial_project").as_posix()
_run_shell_command("mf tutorial --yes")
tutorial_directory = Path.cwd().joinpath("mf_tutorial_project")

# Run the first few tutorial steps.
subprocess.check_call("dbt seed", cwd=tutorial_directory, shell=True)
subprocess.check_call("dbt build", cwd=tutorial_directory, shell=True)
subprocess.check_call(
"mf query --metrics transactions --group-by metric_time --order metric_time", cwd=tutorial_directory, shell=True
_run_shell_command("dbt seed", cwd=tutorial_directory)
_run_shell_command("dbt build", cwd=tutorial_directory)
_run_shell_command(
"mf query --metrics transactions --group-by metric_time --order metric_time",
cwd=tutorial_directory,
)

0 comments on commit fe348c7

Please sign in to comment.