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

fix: fix runs queue; scheduler query #31

Merged
merged 2 commits into from
Jun 5, 2024
Merged
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
5 changes: 4 additions & 1 deletion invenio_jobs/services/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from celery.beat import ScheduleEntry, Scheduler, logger
from invenio_db import db
from sqlalchemy import and_

from invenio_jobs.models import Job, Run, Task
from invenio_jobs.tasks import execute_run
Expand Down Expand Up @@ -97,7 +98,9 @@ def sync(self):
"""Sync Jobs from db to the scheduler."""
# TODO Should we also have a cleaup task for runs? "stale" run (status running, starttime > hour, Run pending for > 1 hr)
with self.app.flask_app.app_context():
jobs = Job.query.filter(Job.active == True).all()
jobs = Job.query.filter(
and_(Job.active == True, Job.schedule != None)
).all()
self.entries = {} # because some jobs might be deactivated
for job in jobs:
self.entries[job.id] = JobEntry.from_job(job)
Expand Down
1 change: 1 addition & 0 deletions invenio_jobs/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def create(self, identity, job_id, data, uow=None):
execute_run,
kwargs={"run_id": run.id, "kwargs": run.args},
task_id=str(run.task_id),
queue=run.queue,
)
)

Expand Down