From d695d15ab3018b27b2ab55917e0e4abac449a10f Mon Sep 17 00:00:00 2001 From: Bala Subrahmanyam Varanasi Date: Mon, 25 Mar 2024 22:14:50 +0530 Subject: [PATCH 1/3] fix: app run job ui - manual job data entry will save on focus out --- llmstack/client/src/components/schedule/InputDataTable.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/llmstack/client/src/components/schedule/InputDataTable.jsx b/llmstack/client/src/components/schedule/InputDataTable.jsx index 18475f18e20..57a868bef0d 100644 --- a/llmstack/client/src/components/schedule/InputDataTable.jsx +++ b/llmstack/client/src/components/schedule/InputDataTable.jsx @@ -86,6 +86,7 @@ export default function InputDataTable({ columnData, rowData, onChange }) { const handleRowEditStop = (params, event) => { if (params.reason === GridRowEditStopReasons.rowFocusOut) { event.defaultMuiPrevented = true; + handleSaveClick(params.id)(); } }; From bb7a57322ad4bbab2f9362087156d25ef1107343 Mon Sep 17 00:00:00 2001 From: Bala Subrahmanyam Varanasi Date: Mon, 25 Mar 2024 22:41:11 +0530 Subject: [PATCH 2/3] fix: job input entries will not be replaced when data or other fields are updated --- .../schedule/AddAppRunScheduleModal.jsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx b/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx index 406117e0166..063f14a43f4 100644 --- a/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx +++ b/llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx @@ -14,6 +14,18 @@ import { axios } from "../../data/axios"; import AddAppRunScheduleConfigForm from "./AddAppRunScheduleConfigForm"; import InputDataTable from "./InputDataTable"; +function checkIfColumnFieldsAreSame(prevColumns, newColumns) { + if (prevColumns && newColumns && prevColumns.length === newColumns.length) { + for (let i = 0; i < prevColumns.length; i++) { + if (prevColumns[i].field !== newColumns[i].field) { + return false; + } + } + return true; + } + return false; +} + export default function AddAppRunScheduleModal(props) { const [columns, setColumns] = useState([]); const [configuration, setConfiguration] = useState({}); @@ -34,10 +46,18 @@ export default function AddAppRunScheduleModal(props) { }; }, ); - setColumns(columnFields); - setAppRunData([]); + + const hasSameColumnFields = checkIfColumnFieldsAreSame( + columns, + columnFields, + ); + + if (!hasSameColumnFields) { + setColumns(columnFields); + setAppRunData([]); + } } - }, [configuration]); + }, [configuration?.appDetail, columns]); return ( From 9b14b4912db3e8ef2f4e367e2b06f7c19519af59 Mon Sep 17 00:00:00 2001 From: Bala Subrahmanyam Varanasi Date: Tue, 26 Mar 2024 00:49:52 +0530 Subject: [PATCH 3/3] feat: adhoc job scheduling --- .../components/schedule/FrequencyPickerWidget.jsx | 1 + llmstack/jobs/apis.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx b/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx index 35a6b0e147e..a432cc8e811 100644 --- a/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx +++ b/llmstack/client/src/components/schedule/FrequencyPickerWidget.jsx @@ -34,6 +34,7 @@ export default function FrequencyPickerWidget(props) { variant="filled" sx={{ lineHeight: "0.5em" }} > + Run Now Run Once Repeat Cron Job diff --git a/llmstack/jobs/apis.py b/llmstack/jobs/apis.py index f4ba7d8995b..2a5a7247972 100644 --- a/llmstack/jobs/apis.py +++ b/llmstack/jobs/apis.py @@ -334,7 +334,7 @@ def create(self, request): if batch_size > len(data["app_run_data"]): return DRFResponse(status=400, data={"message": "Batch size cannot be greater than total rows"}) - if frequency_type not in ["run_once", "repeat", "cron"]: + if frequency_type not in ["run_now", "run_once", "repeat", "cron"]: return DRFResponse( status=400, data={ @@ -343,7 +343,10 @@ def create(self, request): ) scheduled_time = None - if frequency_type == "run_once" or frequency_type == "repeat": + if frequency_type == "run_now": + scheduled_time = timezone.now() + + elif frequency_type == "run_once" or frequency_type == "repeat": if ( not frequency.get("start_date") or not frequency.get( @@ -390,7 +393,12 @@ def create(self, request): "task_category": "app_run", } - if frequency_type == "run_once": + if frequency_type == "run_now": + job = ScheduledJob(**job_args) + job.save() + job.schedule_now() + + elif frequency_type == "run_once": job = ScheduledJob(**job_args) job.save()