-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from andrewm4894/fasthtml
Fasthtml
- Loading branch information
Showing
24 changed files
with
431 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,3 +178,6 @@ models/* | |
# tmp | ||
tmp | ||
tmpdata | ||
.sesskey | ||
.telemetry/id.yaml | ||
.sesskey |
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 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,6 @@ | ||
# Dashboard | ||
|
||
Some simple local dashboard options live here. | ||
|
||
- [`streamlit-dashboard.py`](streamlit-dashboard.py): [Streamlit](https://streamlit.io/) dashboard for the project. | ||
- [`fasthtml-dashboard.py`](fasthtml-dashboard.py): [FastHTML](https://fastht.ml/) dashboard for the project (WIP). |
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,54 @@ | ||
import logging | ||
|
||
from fasthtml.common import Title, fast_app, serve | ||
from fh_plotly import plotly2fasthtml, plotly_headers | ||
from utils import get_enabled_dagster_jobs, plot_time_series | ||
|
||
from anomstack.config import specs | ||
from anomstack.jinja.render import render | ||
from anomstack.sql.read import read_sql | ||
|
||
log = logging.getLogger("fasthtml") | ||
|
||
app, rt = fast_app(hdrs=(plotly_headers,)) | ||
|
||
|
||
@app.get('/') | ||
def home(): | ||
|
||
# get enabled jobs from Dagster | ||
enabled_jobs = get_enabled_dagster_jobs() | ||
|
||
figs = [] | ||
|
||
# loop through metric batches | ||
for i, metric_batch in enumerate(specs, start=1): | ||
|
||
if i > 3: | ||
break | ||
|
||
# check if the job is enabled | ||
if f'{metric_batch}_ingest' in enabled_jobs: | ||
|
||
spec = specs[metric_batch] | ||
sql = render("dashboard_sql", spec, params={"alert_max_n": 90}) | ||
db = spec["db"] | ||
df = read_sql(sql, db=db) | ||
|
||
for metric_name in df["metric_name"].unique(): | ||
|
||
metric_df = df[df["metric_name"] == metric_name] | ||
fig = plotly2fasthtml(plot_time_series(metric_df, metric_name)) | ||
figs.append(fig) | ||
|
||
else: | ||
log.debug(f"job {metric_batch}_ingest is not enabled.") | ||
|
||
return ( | ||
Title("Anomstack"), | ||
figs | ||
) | ||
|
||
|
||
|
||
serve() |
Oops, something went wrong.