-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
[Anki 23.10 Beta 2] SchedulerV3 #86
Comments
The code for the v1 and v2 scheduler was removed in ankitects/anki@558c754, and v3 does not support the legacy functions. I tried monkey patching to v3's What I tried: from typing import Sequence
import anki
from anki import version
from anki.cards import Card, CardId
from anki.consts import QUEUE_TYPE_NEW, QUEUE_TYPE_REV
from anki.hooks import wrap
from anki.utils import ids2str, int_time
from aqt import gui_hooks, mw
from .libaddon.platform import ANKI20
from .template import checkModel
anki21 = version.startswith("2.1.")
if ANKI20:
from anki.sched import Scheduler as SchedulerV1
SCHEDULERS = (SchedulerV1,)
elif anki21:
from anki.schedv2 import Scheduler as SchedulerV2
SCHEDULERS = (SchedulerV1, SchedulerV2)
else: # new version scheme, starting with 23.10
from anki.scheduler.v3 import Scheduler as SchedulerV3
SCHEDULERS = (SchedulerV3,)
.
.
.
.
def my_bury_cards_v3(
self: SchedulerV3, ids: Sequence[CardId], manual: bool, _old
) -> anki.collection_pb2.OpChangesWithCount:
"""Skip sibling burying for our note type if so configured"""
if manual:
return _old(self, ids, manual)
sched_conf = mw.col.conf["olcloze"].get("sched", None)
if not sched_conf:
return _old(self, ids, manual)
override_new, override_review, bury_full = sched_conf
to_bury = []
for id in ids:
card = Card(self.col, id)
card.load()
if checkModel(card.note_type(), fields=False, notify=False):
if card.queue == QUEUE_TYPE_REV and override_review:
continue
elif card.queue == QUEUE_TYPE_NEW and override_new:
continue
to_bury.append(id)
return _old(self, to_bury, manual)
def initializeScheduler():
for scheduler in SCHEDULERS:
if scheduler.version == 3:
scheduler.bury_cards = wrap(
scheduler.bury_cards, my_bury_cards_v3, "around"
)
else:
scheduler._burySiblings = wrap(
scheduler._burySiblings, myBurySiblings, "around"
) |
According to the FAQs, "It is no longer possible to selectively replace parts of the scheduler's code ("monkey patching"), so some add-ons may not be practical to port without significant effort." |
So just disable rescheduling, do one cloze card per note per day, and call it good? Tell people to put it in its own deck that doesn't bury siblings? #from .sched import initializeScheduler
from .reviewer import initializeReviewer
def delayedInit():
initializeModels()
#initializeScheduler() |
Problem description
A hack that selects the v3 scheduler and allows burying siblings, and then it still doesn't load
Please describe the issue concisely in here. In case of an error: Walk us through the steps you took to get there. What happened? What did you expect to happen?
Checklist
Please replace the space inside the brackets with an x if the following items apply:
Information about your Anki set-up
Please fill out the section corresponding with your Anki version:
If you are using Anki 2.1
Please open Anki, go to Help → About, click on "Copy Debug Info", and paste the result between the backticks below (if the button does not appear you are using an older version of Anki 2.1 and will need to update first):
Please fill in details about your operating system (Windows/macOS/Linux, which version):
Please open Anki, go to Tools → Add-ons, take a screenshot of your installed add-ons, and paste it below:
Error message (if any)
If you've received an error message, please copy and paste it between the backticks below:
?
The text was updated successfully, but these errors were encountered: