Modernise
Some checks failed
Publish documentation / publish (push) Successful in 58s
Check / Lint, format & type checks (push) Failing after 1m2s
Check / Test on Python 3.10 (push) Successful in 1m9s
Check / Test on Python 3.9 (push) Successful in 50s

This commit is contained in:
Andras Schmelczer 2026-06-06 21:39:06 +01:00
parent 4c6441182b
commit 8faee98ec6
44 changed files with 214 additions and 201 deletions

View file

@ -16,7 +16,7 @@ from typing import (
)
from fastapi import FastAPI
from tqdm.cli import tqdm
from tqdm import tqdm
from typing_extensions import Literal # <= Python 3.7
from ..constants import DASHBOARD_PATH
@ -103,15 +103,13 @@ class GreatAI(Generic[T, V]):
# Overloaded function signatures 1 and 2 overlap with incompatible return types
# https://github.com/python/mypy/issues/12759
func: Callable[..., Awaitable[V]],
) -> "GreatAI[Awaitable[Trace[V]], V]":
...
) -> "GreatAI[Awaitable[Trace[V]], V]": ...
@overload
@staticmethod
def create(
func: Callable[..., V],
) -> "GreatAI[Trace[V], V]":
...
) -> "GreatAI[Trace[V], V]": ...
@staticmethod
def create(
@ -146,7 +144,7 @@ class GreatAI(Generic[T, V]):
>>> my_function('3').output
Traceback (most recent call last):
...
TypeError: type of a must be int; got str instead
TypeError: argument a is not of the expected type: ...
Args:
func: The prediction function that needs to be decorated.
@ -170,8 +168,7 @@ class GreatAI(Generic[T, V]):
concurrency: Optional[int] = None,
unpack_arguments: Literal[True],
do_not_persist_traces: bool = ...,
) -> List[Trace[V]]:
...
) -> List[Trace[V]]: ...
@overload
def process_batch(
@ -181,8 +178,7 @@ class GreatAI(Generic[T, V]):
concurrency: Optional[int] = None,
unpack_arguments: Literal[False] = ...,
do_not_persist_traces: bool = ...,
) -> List[Trace[V]]:
...
) -> List[Trace[V]]: ...
def process_batch(
self,
@ -237,9 +233,11 @@ class GreatAI(Generic[T, V]):
return list(
tqdm(
parallel_map(
inner_async
if get_function_metadata_store(self).is_asynchronous
else inner,
(
inner_async
if get_function_metadata_store(self).is_asynchronous
else inner
),
batch,
concurrency=concurrency,
),
@ -249,7 +247,7 @@ class GreatAI(Generic[T, V]):
@staticmethod
def _get_cached_traced_function(
func: Callable[..., Union[V, Awaitable[V]]]
func: Callable[..., Union[V, Awaitable[V]]],
) -> Callable[..., T]:
@lru_cache(maxsize=get_context().prediction_cache_size)
def func_in_tracing_context_sync(

View file

@ -31,7 +31,7 @@ def bootstrap_feedback_endpoints(app: FastAPI) -> None:
return trace.feedback
@router.delete("/", status_code=status.HTTP_204_NO_CONTENT)
def delete_feedback(trace_id: str) -> Any:
def delete_feedback(trace_id: str) -> Response:
trace = get_context().tracing_database.get(trace_id)
if trace is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)

View file

@ -22,10 +22,10 @@ def bootstrap_prediction_endpoint(
try:
if inspect.iscoroutinefunction(func):
return await cast(Callable[..., Awaitable[Trace]], func)(
**cast(BaseModel, input_value).dict()
**cast(BaseModel, input_value).model_dump()
)
return cast(Callable[..., Trace], func)(
**cast(BaseModel, input_value).dict()
**cast(BaseModel, input_value).model_dump()
)
except Exception as e:
raise HTTPException(

View file

@ -26,9 +26,9 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
app = Dash(
function_name,
requests_pathname_prefix=DASHBOARD_PATH + "/",
server=Flask(__name__),
server=Flask(__name__), # type: ignore[arg-type]
title=function_name,
update_title=None,
update_title=None, # type: ignore[arg-type]
external_stylesheets=[
"/assets/index.css",
],
@ -64,9 +64,9 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
interval = dcc.Interval(
interval=2 * 1000, # in milliseconds
n_intervals=0,
max_intervals=1
if get_context().is_production
else -1, # will be incremented in production upon each successful request
max_intervals=(
1 if get_context().is_production else -1
), # will be incremented in production upon each successful request
)
app.layout = html.Main(
@ -159,7 +159,7 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
take=page_size,
conjunctive_filters=non_null_conjunctive_filters,
conjunctive_tags=[ONLINE_TAG_NAME],
sort_by=[SortBy.parse_obj(s) for s in sort_by],
sort_by=[SortBy.model_validate(s) for s in sort_by],
)
if non_null_conjunctive_filters:
@ -244,7 +244,7 @@ def update_charts(
fig.update_layout(
margin=dict(l=0, r=0, b=0, t=0, pad=0),
)
execution_time_histogram.figure = fig
execution_time_histogram.figure = fig # type: ignore[attr-defined]
parallel_coords_fig = go.Figure(
go.Parcoords(

View file

@ -16,8 +16,7 @@ def get_description(
style={"color": accent_color},
),
dcc.Markdown(
strip_lines(
f"""
strip_lines(f"""
> View the live data of your deployment here.
## Using the API
@ -27,8 +26,7 @@ def get_description(
## Details
{function_docs}
"""
),
"""),
className="description",
),
]

View file

@ -1,10 +1,12 @@
from typing import Any
from dash import dash_table
from ....context import get_context
def get_traces_table() -> dash_table.DataTable:
return dash_table.DataTable(
def get_traces_table() -> Any:
return dash_table.DataTable( # type: ignore[attr-defined]
page_current=0,
page_size=get_context().dashboard_table_size,
page_action="custom",