Show model version on dashboard

This commit is contained in:
Andras Schmelczer 2022-07-04 09:28:29 +02:00
parent 9e183bbfc0
commit c5012e43a4
4 changed files with 22 additions and 9 deletions

View file

@ -12,7 +12,7 @@ PATH = Path(__file__).parent.resolve()
def bootstrap_dashboard(app: FastAPI, function_name: str, documentation: str) -> None:
dash_app = create_dash_app(function_name, documentation)
dash_app = create_dash_app(function_name, app.version, documentation)
app.mount(DASHBOARD_PATH, WSGIMiddleware(dash_app))

View file

@ -127,6 +127,15 @@ main > header > div > h1 {
margin-top: 0;
}
.version-tag {
border-radius: var(--border-radius);
background: #ddd;
display: inline-block;
font-size: 1rem;
padding: 3px 6px;
margin-left: var(--small-padding)
}
main > header > *:nth-child(2) {
min-width: 250px;
max-width: 550px;

View file

@ -19,7 +19,7 @@ from .get_footer import get_footer
from .get_traces_table import get_traces_table
def create_dash_app(function_name: str, function_docs: str) -> Flask:
def create_dash_app(function_name: str, version: str, function_docs: str) -> Flask:
accent_color = text_to_hex_color(function_name)
app = Dash(
@ -44,6 +44,7 @@ def create_dash_app(function_name: str, function_docs: str) -> Flask:
[
get_description(
function_name=function_name,
version=version,
function_docs=function_docs,
accent_color=accent_color,
),

View file

@ -4,26 +4,29 @@ from ....helper import snake_case_to_text, strip_lines
def get_description(
function_name: str, function_docs: str, accent_color: str
function_name: str, version: str, function_docs: str, accent_color: str
) -> html.Div:
return html.Div(
[
html.H1(
f"{snake_case_to_text(function_name)} - dashboard",
[
f"{snake_case_to_text(function_name)} - dashboard",
html.Span(version, className="version-tag"),
],
style={"color": accent_color},
),
dcc.Markdown(
strip_lines(
f"""
> View the live data of your deployment here.
> View the live data of your deployment here.
## Using the API
## Using the API
You can find the available endpoints at [/docs](/docs).
You can find the available endpoints at [/docs](/docs).
## Details
## Details
{function_docs}
{function_docs}
"""
),
className="description",