From a19b6d2d4d2b42ec0062dff919af554db1cf3c17 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Fri, 5 Jun 2026 02:35:23 +0900 Subject: [PATCH] Cookbook scheduler: calendar events drive model serve windows (experimental, feature-flagged) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a calendar-driven scheduler so a user can pick a model in Cookbook, click "Schedule…" instead of "Launch", choose time windows + days of the week + (optional) end date, and have Odysseus auto-launch the serve when the window starts and hard-kill it when the window ends. The calendar IS the source of truth — events on a designated calendar are interpreted as serve schedules, so editing the event in the calendar UI immediately changes the schedule. Whole feature is gated by setting `cookbook_scheduler_enabled` (default False). Disabling the setting silences the reconciler and the API refuses requests; setting + three new files = entire surface, easy to revert. New files: - src/cookbook_scheduler.py — background reconciler: ticks every 60s, reads next ±90s of calendar events on the designated calendar, launches/kills serves to match. Honors "refuse if GPUs busy" (skips with reason, no retry). Adopts pre-existing manual serves matching the event's model so window-end cleanup still applies. Tags scheduler-owned tasks with `_scheduledBy: ` so it never kills serves it doesn't own. - routes/cookbook_schedule_routes.py — POST /api/cookbook/schedule/from-cookbook builds RRULE+ICS events from the modal's input (model, slots[], days[], until). GET /upcoming returns the next 24h with per-event status (scheduled / running / adopted / skipped / failed / ended) for the UI. POST /reconcile-now manually kicks the reconciler. - static/js/cookbookSchedule.js — Schedule button click handler + modal. Daily/hourly time slot picker, multi-slot ("+ add another time slot"), weekday chips with Weekdays/Weekend/Every-day quicksets, optional Until date. Calls /from-cookbook on save. Whole module is a single IIFE; deleting the file plus its + diff --git a/static/js/cookbookSchedule.js b/static/js/cookbookSchedule.js new file mode 100644 index 0000000..6a5cd82 --- /dev/null +++ b/static/js/cookbookSchedule.js @@ -0,0 +1,244 @@ +// Cookbook Schedule modal. Click the "Schedule…" button in a serve +// panel → opens this modal → user picks days + time slots → POST to +// /api/cookbook/schedule/from-cookbook which writes the calendar event. +// +// Whole feature is gated on /api/cookbook/schedule/upcoming returning +// `enabled: true`. If the server says it's disabled, this module hides +// all Schedule buttons and never opens the modal. +// +// To remove the feature entirely: delete this file + the `