Skip to content
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

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

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

lucagobbi
Copy link
Contributor

@lucagobbi lucagobbi commented Jun 10, 2024

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:

  • get_job: Returns a dictionary of a single scheduled job.
  • pause_job: Temporarily pauses a scheduled job.
  • resume_job: Resumes a paused job.

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@jacopopalumbo01
Copy link
Contributor

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 pieroit merged commit b69bcfa into cheshire-cat-ai:develop Jun 17, 2024
1 check failed
@pieroit
Copy link
Member

pieroit commented Jun 17, 2024

Awesome 🏆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants