xquercus / load-balanced-scheduler

GNU General Public License v3.0
10 stars 9 forks source link

Fix load balancer not working for cards with short intervals in the v2 scheduler #14

Open kuroahna opened 2 years ago

kuroahna commented 2 years ago

This should fix the issue in https://github.com/xquercus/load-balanced-scheduler/issues/11

I also made a fork of AnkiDroid, porting this addon to Android, and added some JUnit tests which you can find here: https://github.com/kuroahna/Anki-Android/commit/1268be0709b260b783842b804831a1f7b8f1871d

I think it'd be good to add some python unit tests here as well so that we don't face regression. Relying on manual debugging with the logging is bad IMO, but I'm not too sure on how to add them. AnkiDroid surprisingly has better documentation, and well, Java being easier to work with than Python, so it was fairly easy to write some tests there.

I have manually tested these changes in v2.1.48 and things are working as expected as far as I can tell.

Willz7 commented 2 years ago

Hi @kuroahna, I tested your version, it's works. This fixes the bug that started to appear recently in the Anki v2 scheduler. I tried it on Anki 2.1.22, which I use because there are some addons that might not be updated for 2.1.48. I tried using your version in conjunction with two addons, DeFuzz Quick Effective Trimming and Agent Orange Pseudo-Fuzz Defoliator created by @lovac42, to make the fuzz more flexible and change it around for different decks, the idea of this is in the defuzz link, but I don't see any changes in the console output.

How do we use your fork of Ankidroid do we just use it normally and sync with ankiweb?

Thank you for the great work

kuroahna commented 2 years ago

Cool! Thanks for confirming it as well! I briefly looked at those addons and ya I don't think there should be any issues. Seems like DeFuzz patches the _fuzzIvlRange function in the v2 scheduler, which this load balanced scheduler addon doesn't affect. And similarly, Agent Orange addon wraps the _fuzzIvlRange function in the v2 scheduler.

but I don't see any changes in the console output.

Is this the console output for the load-balanced-scheduler addon? You'll need to edit the load_balanced_scheduler.py file and change

LOG_LEVEL = 0

to

LOG_LEVEL = 2

How do we use your fork of Ankidroid do we just use it normally and sync with ankiweb?

Yep! Just uninstall your current version of AnkiDroid, and then download and install the APK from https://github.com/kuroahna/Anki-Android/releases Everything should work as normal. Unfortunately, I couldn't build the release APKs and only the debug APKs. I think I might need AnkiDroid's API key to do so. But regardless, I don't think there's much difference between the 2. I've been using the debug APK for a few days now, and things are working as expected from what I can see (and the JUnit tests give us more confidence as well).

Cheers! 🍻

@xquercus If you have time, do you mind reviewing the PR and seeing if there's any changes you'd like to make here? If not, it'd be cool to merge this in and update the ankiweb addon!

Technically, I think this v2 scheduler bug existed since Jan 13, 2018 from this commit: https://github.com/ankitects/anki/commit/575f61c384ea5906535d23e0df59d06ceee45a49 and it went unnoticed ever since. Here, we're fixing it from the addon level, but eventually when this gets fixed upstream in anki, we don't need to apply our fix anymore to the latest versions of anki. We'll still need to keep it for backwards compatibility though (just a simple check for the anki version being used), as noted in the comments of the addon.

Willz7 commented 2 years ago

Cool! Thanks for confirming it as well! I briefly looked at those addons and ya I don't think there should be any issues. Seems like DeFuzz patches the _fuzzIvlRange function in the v2 scheduler, which this load balanced scheduler addon doesn't affect. And similarly, Agent Orange addon wraps the _fuzzIvlRange function in the v2 scheduler.

but I don't see any changes in the console output.

Is this the console output for the load-balanced-scheduler addon? You'll need to edit the load_balanced_scheduler.py file and change

LOG_LEVEL = 0

to

LOG_LEVEL = 2

How do we use your fork of Ankidroid do we just use it normally and sync with ankiweb?

Yep! Just uninstall your current version of AnkiDroid, and then download and install the APK from https://github.com/kuroahna/Anki-Android/releases Everything should work as normal. Unfortunately, I couldn't build the release APKs and only the debug APKs. I think I might need AnkiDroid's API key to do so. But regardless, I don't think there's much difference between the 2. I've been using the debug APK for a few days now, and things are working as expected from what I can see (and the JUnit tests give us more confidence as well).

Cheers! 🍻

@xquercus If you have time, do you mind reviewing the PR and seeing if there's any changes you'd like to make here? If not, it'd be cool to merge this in and update the ankiweb addon!

Technically, I think this v2 scheduler bug existed since Jan 13, 2018 from this commit: ankitects/anki@575f61c and it went unnoticed ever since. Here, we're fixing it from the addon level, but eventually when this gets fixed upstream in anki, we don't need to apply our fix anymore to the latest versions of anki. We'll still need to keep it for backwards compatibility though (just a simple check for the anki version being used), as noted in the comments of the addon.

Hi @kuroahna, Thank you for your answer!

I tried it a couple of times using the two addons that I mentioned above. It does show the interval ranges however, I was referring to this bug which shows up(look below) sometime without any showing any fuzz intervals like it used to before the bug appeared.

This is what I got from the console output earlier

__adjusted lapse ivl: 5 instead of 22

Hard button pressed. Setting card interval to: 3 days

Good button pressed. Setting card interval to: 4 days

Easy button pressed. Setting card interval to: 5 days

Another example with a longterm card


Hard button pressed. Setting card interval to: 39 days

Good button pressed. Setting card interval to: 106 days

Easy button pressed. Setting card interval to: 107 days

With further experimenting by disabling addons that effect the scheduler/behind the scene I still have other addons on but I don't think it gives any conflicts. I am getting this ` Hard button pressed. Setting card interval to: 4 days

Good button pressed. Setting card interval to: 10 days

Easy button pressed. Setting card interval to: 11 days

Caught exception: Traceback (most recent call last): File "aqt\webview.py", line 75, in javaScriptConsoleMessage AttributeError: 'Stream' object has no attribute 'encoding'

Hard button pressed. Setting card interval to: 5 days

Good button pressed. Setting card interval to: 10 days

Easy button pressed. Setting card interval to: 11 days

Hard button pressed. Setting card interval to: 86 days

Good button pressed. Setting card interval to: 230 days

Easy button pressed. Setting card interval to: 231 days

Hard button pressed. Setting card interval to: 4 days

Good button pressed. Setting card interval to: 10 days

Easy button pressed. Setting card interval to: 11 days

Hard button pressed. Setting card interval to: 4 days

Good button pressed. Setting card interval to: 6 days

Easy button pressed. Setting card interval to: 7 days

picture for evidence. I am not sure what I am doing wrong. image

kuroahna commented 2 years ago

That's strange, as I'm definitely seeing the console output after setting LOG_LEVEL = 2:

image

Not exactly sure what's going on your end, but I guess you've already tried disabling all other addons and it still doesn't work? Not sure what else to try other than to reinstall anki and see if that helps

Willz7 commented 2 years ago

That's strange, as I'm definitely seeing the console output after setting LOG_LEVEL = 2:

image

Not exactly sure what's going on your end, but I guess you've already tried disabling all other addons and it still doesn't work? Not sure what else to try other than to reinstall anki and see if that helps

It worked after removing some add-on that was giving some conflicts.