-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdbt_setup.sh
executable file
·68 lines (54 loc) · 1.6 KB
/
dbt_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# create a 'databases' directory if it does not exist
databases_dir="databases"
if [ ! -d "$databases_dir" ]; then
echo "Creating 'databases' directory..."
mkdir "$databases_dir"
fi
# define the name of your virtual environment
venv_name="venv"
# check if the virtual environment exists, fail if it does not
if [ ! -d "$venv_name" ]; then
echo "Error: Virtual environment '$venv_name' does not exist. Please create it first."
exit 1
fi
echo "Activating the virtual environment: $venv_name"
source "$venv_name/bin/activate"
# specify the path to your requirements.txt file
requirements_file="requirements.txt"
# check if requirements.txt exists, fail if it does not
if [ ! -f "$requirements_file" ]; then
echo "Error: Requirements file '$requirements_file' not found."
deactivate
exit 1
fi
echo "Installing Python packages from $requirements_file..."
pip install -r "$requirements_file"
# fail if pip install fails
if [ $? -ne 0 ]; then
echo "Error: Failed to install requirements."
deactivate
exit 1
fi
# ensure the dbt setup is correctly configured
echo "Running dbt debug to check the dbt project..."
dbt debug
# fail if dbt debug fails
if [ $? -ne 0 ]; then
echo "Error: dbt debug failed."
deactivate
exit 1
fi
# integrate external dbt packages into the dbt project
echo "Running dbt deps"
dbt deps
# fail if dbt deps fails
if [ $? -ne 0 ]; then
echo "Error: dbt deps failed."
deactivate
exit 1
fi
# deactivate the virtual environment and indicate success
echo "Deactivating the virtual environment."
deactivate
echo "Setup completed successfully."