Issue
I'm trying to develop a plugin for Airflow (2.3.3) to host the html output that's generated from great expectations. (0.1.5). I'm able to get it to load the index.html page, but as soon as I click any of the links within, it directs me to an "Airflow 404 Page cannot be found." page.
Here is my plugin:
from airflow.plugins_manager import AirflowPlugin
from flask import Blueprint
from flask_appbuilder import expose, BaseView as AppBuilderBaseView
import os
class GreatExpectationsView(AppBuilderBaseView):
@expose('/')
def list(self):
return self.render_template("index.html", content="")
v_appbuilder_view = GreatExpectationsView()
v_appbuilder_package = {
"name": "Great Expectations",
"category": "Browse",
"view": v_appbuilder_view,
}
bp = Blueprint(
"great_expectation",
__name__,
template_folder="/opt/great_expectations",
static_folder='/opt/great_expectations/static',
static_url_path='/greatexpectationsview/static'
)
class AirflowGEPlugin(AirflowPlugin):
name = "great_expectation"
appbuilder_views = [v_appbuilder_package]
flask_blueprints = [bp]
This is the folder structure of the html generated by great expectations
/opt/great_expectations/
|-- expectations
| `-- src
| `-- dag1
| `-- warning.html
|-- index.html
|-- static
| |-- fonts
| | `-- HKGrotesk
| | |-- HKGrotesk-Bold.otf
| | |-- HKGrotesk-BoldItalic.otf
| | |-- HKGrotesk-Italic.otf
| | |-- HKGrotesk-Light.otf
| | |-- HKGrotesk-LightItalic.otf
| | |-- HKGrotesk-Medium.otf
| | |-- HKGrotesk-MediumItalic.otf
| | |-- HKGrotesk-Regular.otf
| | |-- HKGrotesk-SemiBold.otf
| | `-- HKGrotesk-SemiBoldItalic.otf
| |-- images
| | |-- favicon.ico
| | |-- glossary_scroller.gif
| | |-- iterative-dev-loop.png
| | |-- logo-long-vector.svg
| | |-- logo-long.png
| | |-- short-logo-vector.svg
| | |-- short-logo.png
| | `-- validation_failed_unexpected_values.gif
| `-- styles
| |-- data_docs_custom_styles_template.css
| `-- data_docs_default_styles.css
`-- validations
`-- src
`-- dag1
`-- warning
|-- 20220914-170251-src_dag1
| `-- 20220914T170251.386427Z
| `-- 1811b6d2fab709c0e35cab11873288dc.html
`-- 20220914-182123-src_dag1
`-- 20220914T182123.138118Z
`-- 1811b6d2fab709c0e35cab11873288dc.html
The links are attempting to route me to the html files in validations/src/dag1/warning/...
Any help on how I need to configure the plugin for this to work?
Solution
Figured out my issue. I just needed to tweak the static_folder
and static_url_path
options to this:
bp = Blueprint(
"great_expectation",
__name__,
template_folder="/opt/great_expectations",
static_folder='/opt/great_expectations',
static_url_path='/greatexpectationsview'
)
Answered By - wymangr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.