cheshire-cat-ai / core

Production ready AI agent framework
https://cheshirecat.ai
GNU General Public License v3.0
2.28k stars 304 forks source link

add get_job, pause_job and resume_job methods plus minor adjustments #852

Closed lucagobbi closed 3 months ago

lucagobbi commented 3 months ago

Description

Hi! As discussed in the last dev meeting, I propose adding some methods to the WhiteRabbit class to finalize the excellent work by @jacopopalumbo01 and provide a complete and useful API wrapping APScheduler features. The added methods are:

Additionally, I have made some minor adjustments for type hinting and corrected comment typos. I have replaced every id reference with job_id to avoid shadowing built-in names. However, if we consider this a breaking change, we can restore id.

Regarding other features, I think we are covering most use cases, but APScheduler also provides for a concatenation of triggers, which could be really interesting in situations where triggers are complex:


from apscheduler.triggers.combining import OrTrigger
from apscheduler.triggers.cron import CronTrigger

# run at 10:00 from Monday to Friday, but also at 11:00 from Saturday to Sunday

trigger = OrTrigger(
    CronTrigger(day_of_week="mon-fri", hour=10),
    CronTrigger(day_of_week="sat-sun", hour=11),
)

Currently we need to access the inner scheduler to achieve something like that, it would be nice to provide a simple API also in the WhiteRabbit class.

Related to issue #839

Type of change

Checklist:

jacopopalumbo01 commented 3 months ago

Looks perfect to me! About the concatenation of triggers we should definitely explore them. However they are an "advanced" feature of WhiteRabbit so maybe it could be better to wait and see if the WhiteRabbit is used by the users as we discussed yesterday in the dev meeting.

pieroit commented 3 months ago

Awesome :trophy: