Skip to content

feature(jobs): Ability to create immediate ('Run Now') jobs and minor ui fixes #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions llmstack/client/src/components/schedule/AddAppRunScheduleModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand All @@ -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 (
<Dialog open={true} maxWidth="lg" fullWidth onClose={props.onClose}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function FrequencyPickerWidget(props) {
variant="filled"
sx={{ lineHeight: "0.5em" }}
>
<MenuItem value="run_now">Run Now</MenuItem>
<MenuItem value="run_once">Run Once</MenuItem>
<MenuItem value="repeat">Repeat</MenuItem>
<MenuItem value="cron">Cron Job</MenuItem>
Expand Down
1 change: 1 addition & 0 deletions llmstack/client/src/components/schedule/InputDataTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
}
};

Expand Down
14 changes: 11 additions & 3 deletions llmstack/jobs/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand All @@ -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(
Expand Down Expand Up @@ -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()

Expand Down