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

Sync queue index #2140

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Changes from 3 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
27 changes: 9 additions & 18 deletions libs/libcommon/src/libcommon/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
from bson import ObjectId
from mongoengine import Document
from mongoengine.errors import DoesNotExist, NotUniqueError
from mongoengine.fields import (
DateTimeField,
EnumField,
IntField,
ObjectIdField,
StringField,
)
from mongoengine.fields import DateTimeField, EnumField, IntField, ObjectIdField, StringField
from mongoengine.queryset.queryset import QuerySet

from libcommon.constants import (
Expand All @@ -39,14 +33,7 @@
QUEUE_MONGOENGINE_ALIAS,
QUEUE_TTL_SECONDS,
)
from libcommon.utils import (
FlatJobInfo,
JobInfo,
Priority,
Status,
get_datetime,
inputs_to_string,
)
from libcommon.utils import FlatJobInfo, JobInfo, Priority, Status, get_datetime, inputs_to_string

# START monkey patching ### hack ###
# see https://github.com/sbdchd/mongo-types#install
Expand Down Expand Up @@ -160,12 +147,16 @@ class JobDocument(Document):
"collection": QUEUE_COLLECTION_JOBS,
"db_alias": QUEUE_MONGOENGINE_ALIAS,
"indexes": [
("dataset", "status"),
("type", "dataset", "status"),
("type", "dataset", "revision", "config", "split", "status", "priority"),
("priority", "status", "created_at", "namespace"),
# ("type", "dataset", "revision", "config", "split", "status", "priority"),
# ("priority", "status", "created_at", "namespace"),
("priority", "status", "created_at", "namespace", "difficulty", "unicity_id"),
("priority", "status", "created_at", "difficulty", "namespace"),
("priority", "status", "type", "namespace", "unicity_id", "created_at", "-difficulty"),
("status", "type"),
("unicity_id", "-created_at", "status"),
# ("unicity_id", "-created_at", "status"),
("unicity_id", "status", "-created_at"),
{
"fields": ["finished_at"],
"expireAfterSeconds": QUEUE_TTL_SECONDS,
Expand Down