Production improvements
This commit is contained in:
parent
7bd2e89070
commit
378047e622
5 changed files with 21 additions and 7 deletions
|
|
@ -27,5 +27,5 @@ ONLINE_TAG_NAME = "online"
|
|||
|
||||
SERVER_NAME = "GreatAI-Server"
|
||||
|
||||
SE4ML_WEBSITE = "https://se-ml.github.io/practices/"
|
||||
SE4ML_WEBSITE = "https://se-ml.github.io/practices"
|
||||
LIST_ITEM_PREFIX = " 🔩 "
|
||||
|
|
|
|||
|
|
@ -80,7 +80,11 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
|
|||
html.Div(className="space-filler"),
|
||||
get_footer(),
|
||||
interval := dcc.Interval(
|
||||
interval=4 * 1000, # in milliseconds
|
||||
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
|
||||
),
|
||||
]
|
||||
)
|
||||
|
|
@ -113,6 +117,7 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
|
|||
Output(execution_time_histogram_container, "children"),
|
||||
Output(parallel_coordinates, "figure"),
|
||||
Output(parallel_coordinates, "style"),
|
||||
Output(interval, "max_intervals"),
|
||||
Input(table, "page_current"),
|
||||
Input(table, "page_size"),
|
||||
Input(table, "sort_by"),
|
||||
|
|
@ -124,7 +129,7 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
|
|||
page_size: int,
|
||||
sort_by: List[Dict[str, Union[str, int]]],
|
||||
filter_query: str,
|
||||
n_intervals: int,
|
||||
n_intervals: Optional[int],
|
||||
) -> Tuple[
|
||||
List[Dict[str, Any]],
|
||||
int,
|
||||
|
|
@ -133,6 +138,7 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
|
|||
Any,
|
||||
go.Figure,
|
||||
Dict[str, Any],
|
||||
int,
|
||||
]:
|
||||
conjunctive_filters = (
|
||||
[get_filter_from_datatable(f) for f in filter_query.split(" && ")]
|
||||
|
|
@ -165,6 +171,7 @@ def create_dash_app(function_name: str, version: str, function_docs: str) -> Fla
|
|||
execution_time_histogram,
|
||||
parallel_coords_fig,
|
||||
style,
|
||||
((n_intervals or 0) + 1) if get_context().is_production else -1,
|
||||
)
|
||||
|
||||
return app.server
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ def parse_arguments() -> Namespace:
|
|||
help="the name of the file containing your to-be-served function such as `main.py`\n",
|
||||
)
|
||||
|
||||
default_host = "127.0.0.1"
|
||||
default_host = "0.0.0.0"
|
||||
parser.add_argument(
|
||||
"--host",
|
||||
type=str,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo import ASCENDING, DESCENDING, MongoClient
|
||||
|
||||
from ..utilities import chunk
|
||||
from ..views import Filter, SortBy, Trace
|
||||
|
|
@ -31,6 +31,11 @@ class MongodbDriver(TracingDatabaseDriver):
|
|||
"Please configure the MongoDB access options by calling MongodbDriver.configure_credentials"
|
||||
)
|
||||
|
||||
with MongoClient[Any](self.mongo_connection_string) as client:
|
||||
client[self.mongo_database].traces.create_index(
|
||||
[("tags", ASCENDING), ("created", DESCENDING)], background=True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def configure_credentials( # type: ignore
|
||||
cls,
|
||||
|
|
@ -93,11 +98,13 @@ class MongodbDriver(TracingDatabaseDriver):
|
|||
"filter": {},
|
||||
}
|
||||
|
||||
and_query: List[Dict[str, Any]] = [{}]
|
||||
and_query: List[Dict[str, Any]] = []
|
||||
and_query.extend({"tags": tag} for tag in conjunctive_tags)
|
||||
and_query.extend(
|
||||
{f.property: {self._get_operator(f): f.value}} for f in conjunctive_filters
|
||||
)
|
||||
if not and_query:
|
||||
and_query.append({})
|
||||
|
||||
if since:
|
||||
and_query.append({"created": {"$gte": since}})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ async def call_remote_great_ai_async(
|
|||
base_uri: str,
|
||||
data: Mapping[str, Any],
|
||||
retry_count: int = 4,
|
||||
timeout_in_seconds: int = 60,
|
||||
timeout_in_seconds: int = 300,
|
||||
model_class: Optional[Type[T]] = None,
|
||||
) -> Trace[T]:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue