-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to host dbt docs on cluster (#892)
Adds the (optional, off by default) ability to run dbt docs in the Tutor context so that custom dbt packages and Superset dashboards / charts will be represented in the documentation and be correct for what is actually being run in the environment.
- Loading branch information
Showing
17 changed files
with
368 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,3 +101,4 @@ ASPECTS_ENABLE_EVENT_BUS_PRODUCER: true | |
SUPERSET_DASHBOARD_LOCALES: | ||
- en | ||
- fr_CA | ||
RUN_ASPECTS_DOCS: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tutoraspects/templates/aspects/apps/aspects/migrations/alembic/versions/0038_aspects_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
revision = "0038" | ||
down_revision = "0037" | ||
branch_labels = None | ||
depends_on = None | ||
on_cluster = " ON CLUSTER '{{CLICKHOUSE_CLUSTER_NAME}}' " if "{{CLICKHOUSE_CLUSTER_NAME}}" else "" | ||
engine = ( | ||
"ReplicatedReplacingMergeTree" | ||
if "{{CLICKHOUSE_CLUSTER_NAME}}" | ||
else "ReplacingMergeTree" | ||
) | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
f""" | ||
CREATE TABLE IF NOT EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.aspects_data | ||
{on_cluster} | ||
( | ||
path String NOT NULL, | ||
content String NOT NULL, | ||
) ENGINE {engine} | ||
PRIMARY KEY (path); | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
"DROP TABLE IF EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.aspects_data" | ||
f"{on_cluster};" | ||
) |
42 changes: 42 additions & 0 deletions
42
tutoraspects/templates/aspects/apps/aspects/scripts/bootstrap.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
set -eo pipefail | ||
|
||
if [ -z "${DBT_SSH_KEY+x}" ] | ||
then | ||
mkdir -p /root/.ssh | ||
echo "${DBT_SSH_KEY}" | tr -d '\r' > /root/.ssh/id_rsa | ||
chmod 600 /root/.ssh/id_rsa | ||
eval `ssh-agent -s` | ||
|
||
ssh -o StrictHostKeyChecking=no [email protected] || true | ||
ssh-add /root/.ssh/id_rsa | ||
fi | ||
|
||
export branch=$(git -C aspects-dbt/ branch --show-current) | ||
export repo=$(git -C aspects-dbt/ config --get remote.origin.url) | ||
if [ "$DBT_BRANCH" != "$branch" ] && [ "$DBT_REPOSITORY" != "$repo" ]; | ||
then | ||
rm -rf aspects-dbt | ||
|
||
echo "Installing aspects-dbt" | ||
echo "git clone -b ${DBT_BRANCH} ${DBT_REPOSITORY}" | ||
git clone -b ${DBT_BRANCH} ${DBT_REPOSITORY} aspects-dbt | ||
|
||
cd aspects-dbt | ||
|
||
if [ -e "./requirements.txt" ] | ||
then | ||
echo "Installing dbt python requirements" | ||
pip install -r ./requirements.txt | ||
else | ||
echo "No requirements.txt file found; skipping" | ||
fi | ||
|
||
echo "Installing dbt dependencies" | ||
dbt deps | ||
|
||
fi | ||
|
||
mkdir -p $DBT_STATE |
Oops, something went wrong.