-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16b181c
commit 8b5ed23
Showing
7 changed files
with
73 additions
and
45 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
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 was deleted.
Oops, something went wrong.
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,59 @@ | ||
from pathlib import Path | ||
|
||
def init_plugins_dbtdocs_page(dbt_docs_dir: Path): | ||
from airflow.plugins_manager import AirflowPlugin | ||
from flask import Blueprint | ||
from flask_appbuilder import BaseView, expose | ||
from flask import abort | ||
from airflow.www.auth import has_access | ||
from airflow.security import permissions | ||
|
||
class DBTDocsView(BaseView): | ||
route_base = "/dbt" | ||
default_view = "dbt_docs_index" | ||
|
||
@expose("/dbt_docs_index.html") # type: ignore[misc] | ||
@has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE)]) | ||
def dbt_docs_index(self): | ||
if not dbt_docs_dir.joinpath("index.html").is_file(): | ||
abort(404) | ||
else: | ||
return dbt_docs_dir.joinpath("index.html").read_text() | ||
# return self.render_template("index.html", content="") | ||
|
||
@expose("/catalog.json") # type: ignore[misc] | ||
@has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE)]) | ||
def catalog(self): | ||
if not dbt_docs_dir.joinpath("catalog.json").is_file(): | ||
abort(404) | ||
else: | ||
data = dbt_docs_dir.joinpath("catalog.json").read_text() | ||
return data, 200, {"Content-Type": "application/json"} | ||
# return self.render_template("index.html", content="") | ||
|
||
@expose("/manifest.json") # type: ignore[misc] | ||
@has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE)]) | ||
def manifest(self): | ||
if not dbt_docs_dir.joinpath("manifest.json").is_file(): | ||
abort(404) | ||
else: | ||
data = dbt_docs_dir.joinpath("manifest.json").read_text() | ||
return data, 200, {"Content-Type": "application/json"} | ||
# return self.render_template("index.html", content="") | ||
|
||
# Creating a flask blueprint to integrate the templates and static folder | ||
bp = Blueprint( | ||
"DBT Plugin", | ||
__name__, | ||
template_folder=dbt_docs_dir.as_posix(), | ||
static_folder=dbt_docs_dir.as_posix(), | ||
# static_url_path='/dbtdocsview' | ||
) | ||
|
||
|
||
class AirflowDbtDocsPlugin(AirflowPlugin): | ||
name = "DBT Docs Plugin" | ||
flask_blueprints = [bp] | ||
appbuilder_views = [{"name": "DBT Docs", "category": "", "view": DBTDocsView()}] | ||
|
||
return AirflowDbtDocsPlugin |
Empty file.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from pathlib import Path | ||
|
||
from opendbt.airflow import dbtdocs | ||
from opendbt.airflow import plugin | ||
|
||
# create public page on airflow server to serve DBT docs | ||
airflow_dbtdocs_page = dbtdocs.init_plugins_dbtdocs_page(Path("/opt/dbttest/target")) | ||
airflow_dbtdocs_page = plugin.init_plugins_dbtdocs_page(Path("/opt/dbttest/target")) |
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