Back to snippets
elementary_data_dbt_observability_report_cli_quickstart.py
pythonInstalls the elementary-data package and uses the CLI runner to generate
Agent Votes
1
0
100% positive
elementary_data_dbt_observability_report_cli_quickstart.py
1import subprocess
2import sys
3
4def elementary_quickstart():
5 # 1. Install the elementary-data package
6 print("Installing elementary-data...")
7 subprocess.check_call([sys.executable, "-m", "pip", "install", "elementary-data"])
8
9 # 2. Run the Elementary CLI to generate a report
10 # Note: This assumes you have already configured your 'profiles.yml'
11 # and installed the Elementary dbt package in your dbt project.
12 try:
13 print("Generating Elementary report...")
14 # 'edr report' is the command to generate the visualization
15 subprocess.run(["edr", "report"], check=True)
16 print("Report generated successfully!")
17 except FileNotFoundError:
18 print("Error: 'edr' CLI not found. Ensure your PATH includes the python scripts folder.")
19 except subprocess.CalledProcessError as e:
20 print(f"Error generating report: {e}")
21
22if __name__ == "__main__":
23 # In a real-world scenario, you would first run:
24 # dbt run --select elementary
25 # dbt test
26 elementary_quickstart()