Skip to content

Commit

Permalink
Improve reindex completion flag (#14308)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye217 authored Oct 12, 2024
1 parent 3a40339 commit 0fc7999
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion frigate/embeddings/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def reindex(self) -> None:
"processed_objects": 0,
"total_objects": 0,
"time_remaining": 0,
"status": "indexing",
}

self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)
Expand Down Expand Up @@ -255,6 +256,8 @@ def reindex(self) -> None:
"Embedded %d thumbnails and %d descriptions in %s seconds",
totals["thumbnails"],
totals["descriptions"],
time.time() - st,
round(time.time() - st, 1),
)
totals["status"] = "completed"

self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)
22 changes: 14 additions & 8 deletions web/src/pages/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,18 @@ export default function Explore() {

const { payload: reindexProgress } = useEmbeddingsReindexProgress();

const embeddingsReindexing = useMemo(
() =>
reindexProgress
? reindexProgress.total_objects - reindexProgress.processed_objects > 0
: undefined,
[reindexProgress],
);
const embeddingsReindexing = useMemo(() => {
if (reindexProgress) {
switch (reindexProgress.status) {
case "indexing":
return true;
case "completed":
return false;
default:
return undefined;
}
}
}, [reindexProgress]);

// model states

Expand Down Expand Up @@ -320,7 +325,8 @@ export default function Explore() {
<span className="text-primary-variant">
Tracked objects processed:
</span>
{reindexProgress.processed_objects}
{reindexProgress.processed_objects} /{" "}
{reindexProgress.total_objects}
</div>
</div>
</>
Expand Down
1 change: 1 addition & 0 deletions web/src/types/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type EmbeddingsReindexProgressType = {
processed_objects: number;
total_objects: number;
time_remaining: number;
status: string;
};

export type ToggleableSetting = "ON" | "OFF";

0 comments on commit 0fc7999

Please sign in to comment.