Skip to content

Commit

Permalink
fix: Added Game in the setup and cancel jobs if they fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowtter committed Jan 29, 2023
1 parent 67d44b5 commit 4ec6092
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crispy-api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def is_tool_installed(ffmpeg_tool: str) -> None:
@app.on_event("startup")
async def setup_crispy() -> None:
await handle_musics(MUSICS)
await handle_highlights(VIDEOS, SupportedGames.OVERWATCH, framerate=8)
await handle_highlights(VIDEOS, GAME, framerate=8)


@app.exception_handler(HTTPException)
Expand Down
4 changes: 1 addition & 3 deletions crispy-api/api/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ async def generate_dataset(game: SupportedGames) -> None:

if __name__ == "__main__":
if not _args.dataset:
uvicorn.run(
"api:app", host=HOST, port=PORT, reload=DEBUG, proxy_headers=True, workers=8
)
uvicorn.run("api:app", host=HOST, port=PORT, reload=DEBUG, proxy_headers=True)
else:
game = SupportedGames(_args.game)
if not game:
Expand Down
2 changes: 1 addition & 1 deletion crispy-api/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

config = Config(".env")

DEBUG = config("DEBUG", cast=bool, default=True)
DEBUG = config("DEBUG", cast=bool, default=False)
HOST = config("HOST", default="127.0.0.1")
PORT = config("PORT", cast=int, default=7821)
MONGO_URI = config("MONGO_URI", default="mongodb://localhost/crispy")
Expand Down
18 changes: 16 additions & 2 deletions crispy-frontend/src/lib/components/Menubar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@
if (jobs.every((highlight) => highlight.status == "completed")) {
break;
}
if (jobs.some((highlight) => highlight.status == "failed")) {
globalError("Error while generating.");
dispatch("changeMode", "clips");
return false;
}
} else {
if (jobs.status == "completed") {
break;
}
if (jobs.status == "failed") {
globalError("Error while generating.");
dispatch("changeMode", "clips");
return false;
}
}
if (id) {
// count how many times "completed" is in the status
Expand All @@ -136,8 +146,9 @@
}
}
await sleep(1500);
await sleep(5000);
}
return true;
};
async function generateSegments() {
Expand All @@ -163,7 +174,10 @@
return;
});
waitForJobs(API_URL + "/highlights/segments/generate/status", id, "Generating Segments!").then(() => {
waitForJobs(API_URL + "/highlights/segments/generate/status", id, "Generating Segments!").then((result) => {
if (!result) {
return;
}
toast.pop(0);
globalSuccess("Segments generated!");
globalInfo("You can now generate the result.");
Expand Down
2 changes: 1 addition & 1 deletion crispy-frontend/src/lib/components/Segments.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
if (highlights.data.every((highlight) => highlight.status == "completed")) {
break;
}
await sleep(1500);
await sleep(5000);
}
};
mainLoop();
Expand Down

0 comments on commit 4ec6092

Please sign in to comment.