mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Add age_sec field to loading serving models
Return serving instance charts sorted by instance name
This commit is contained in:
parent
a3b303fa28
commit
83dbf0fcb8
@ -40,7 +40,8 @@ from .sub_projects import (
|
|||||||
_ids_with_children,
|
_ids_with_children,
|
||||||
_ids_with_parents,
|
_ids_with_parents,
|
||||||
_get_project_depth,
|
_get_project_depth,
|
||||||
ProjectsChildren, _get_writable_project_from_name,
|
ProjectsChildren,
|
||||||
|
_get_writable_project_from_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
log = config.logger(__file__)
|
log = config.logger(__file__)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, timezone
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from time import time
|
from time import time
|
||||||
@ -75,7 +75,7 @@ class ServingBLL:
|
|||||||
"""
|
"""
|
||||||
Register a serving container
|
Register a serving container
|
||||||
"""
|
"""
|
||||||
now = datetime.utcnow()
|
now = datetime.now(timezone.utc)
|
||||||
key = self._get_container_key(company_id, request.container_id)
|
key = self._get_container_key(company_id, request.container_id)
|
||||||
entry = ServingContainerEntry(
|
entry = ServingContainerEntry(
|
||||||
**request.to_struct(),
|
**request.to_struct(),
|
||||||
@ -120,7 +120,7 @@ class ServingBLL:
|
|||||||
Serving container status report
|
Serving container status report
|
||||||
"""
|
"""
|
||||||
container_id = report.container_id
|
container_id = report.container_id
|
||||||
now = datetime.utcnow()
|
now = datetime.now(timezone.utc)
|
||||||
entry = self._get_serving_container_entry(company_id, container_id)
|
entry = self._get_serving_container_entry(company_id, container_id)
|
||||||
if entry:
|
if entry:
|
||||||
ip = ip or entry.ip
|
ip = ip or entry.ip
|
||||||
@ -252,7 +252,7 @@ class ServingBLL:
|
|||||||
"instances": len(entries),
|
"instances": len(entries),
|
||||||
**{counter.name: counter() for counter in counters},
|
**{counter.name: counter() for counter in counters},
|
||||||
}
|
}
|
||||||
ret["last_update"] = self._naive_time(ret.get("last_update"))
|
ret["last_update"] = ret.get("last_update")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_endpoints(self, company_id: str):
|
def get_endpoints(self, company_id: str):
|
||||||
@ -307,18 +307,12 @@ class ServingBLL:
|
|||||||
"input_type": entry.input_type,
|
"input_type": entry.input_type,
|
||||||
"input_size": entry.input_size,
|
"input_size": entry.input_size,
|
||||||
"uptime_sec": entry.uptime_sec,
|
"uptime_sec": entry.uptime_sec,
|
||||||
"last_update": self._naive_time(entry.last_activity_time),
|
"age_sec": int((datetime.now(timezone.utc) - entry.register_time).total_seconds()),
|
||||||
|
"last_update": entry.last_activity_time,
|
||||||
}
|
}
|
||||||
for entry in entries
|
for entry in entries
|
||||||
]
|
]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _naive_time(input_: datetime) -> datetime:
|
|
||||||
if not isinstance(input_, datetime):
|
|
||||||
return input_
|
|
||||||
|
|
||||||
return input_.replace(tzinfo=None)
|
|
||||||
|
|
||||||
def get_endpoint_details(self, company_id, endpoint_url: str) -> dict:
|
def get_endpoint_details(self, company_id, endpoint_url: str) -> dict:
|
||||||
entries = self._get_endpoint_entries(company_id, endpoint_url)
|
entries = self._get_endpoint_entries(company_id, endpoint_url)
|
||||||
if not entries:
|
if not entries:
|
||||||
@ -346,7 +340,7 @@ class ServingBLL:
|
|||||||
"model_source": first_entry.model_source,
|
"model_source": first_entry.model_source,
|
||||||
"model_version": first_entry.model_version,
|
"model_version": first_entry.model_version,
|
||||||
"uptime_sec": max(e.uptime_sec for e in entries),
|
"uptime_sec": max(e.uptime_sec for e in entries),
|
||||||
"last_update": self._naive_time(max(e.last_activity_time for e in entries)),
|
"last_update": max(e.last_activity_time for e in entries),
|
||||||
"instances": [
|
"instances": [
|
||||||
{
|
{
|
||||||
"id": entry.container_id,
|
"id": entry.container_id,
|
||||||
@ -354,7 +348,7 @@ class ServingBLL:
|
|||||||
"requests": entry.requests_num,
|
"requests": entry.requests_num,
|
||||||
"requests_min": entry.requests_min,
|
"requests_min": entry.requests_min,
|
||||||
"latency_ms": entry.latency_ms,
|
"latency_ms": entry.latency_ms,
|
||||||
"last_update": self._naive_time(entry.last_activity_time),
|
"last_update": entry.last_activity_time,
|
||||||
"reference": [ref.to_struct() for ref in entry.reference]
|
"reference": [ref.to_struct() for ref in entry.reference]
|
||||||
if isinstance(entry.reference, list)
|
if isinstance(entry.reference, list)
|
||||||
else entry.reference,
|
else entry.reference,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from typing import Tuple, Optional, Sequence
|
from typing import Tuple, Optional, Sequence
|
||||||
@ -35,7 +35,7 @@ class ServingStats:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_es_index_suffix():
|
def _get_es_index_suffix():
|
||||||
"""Get the index name suffix for storing current month data"""
|
"""Get the index name suffix for storing current month data"""
|
||||||
return datetime.utcnow().strftime("%Y-%m")
|
return datetime.now(timezone.utc).strftime("%Y-%m")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_average_value(value) -> Tuple[Optional[float], Optional[int]]:
|
def _get_average_value(value) -> Tuple[Optional[float], Optional[int]]:
|
||||||
@ -292,7 +292,7 @@ class ServingStats:
|
|||||||
hist_ret["total"]["values"] = cls.round_series(total)
|
hist_ret["total"]["values"] = cls.round_series(total)
|
||||||
hist_ret["instances"] = {
|
hist_ret["instances"] = {
|
||||||
key: {"title": key, "dates": dates_, "values": cls.round_series(values)}
|
key: {"title": key, "dates": dates_, "values": cls.round_series(values)}
|
||||||
for key, values in instances.items()
|
for key, values in sorted(instances.items(), key=lambda p: p[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
return hist_ret
|
return hist_ret
|
||||||
|
@ -190,6 +190,10 @@ _definitions {
|
|||||||
format: "date-time"
|
format: "date-time"
|
||||||
description: The latest time when the container instance sent update
|
description: The latest time when the container instance sent update
|
||||||
}
|
}
|
||||||
|
age_sec {
|
||||||
|
type: integer
|
||||||
|
description: Amount of seconds since the container registration
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
metrics_history_series {
|
metrics_history_series {
|
||||||
|
Loading…
Reference in New Issue
Block a user