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

Feat/Inbuilt optimizer #91

Closed
Closed
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
aada9d5
Added: Temp export
Luc-Mcgrady Apr 30, 2023
d357a8b
Updated: Gitignore
Luc-Mcgrady Apr 30, 2023
76d4c9e
Added: Command line call
Luc-Mcgrady Apr 30, 2023
6607fe4
Added: Exclusive worker
Luc-Mcgrady May 1, 2023
fd40da9
Added: Install button
Luc-Mcgrady May 1, 2023
4f66784
Added: "Waiting for:" message
Luc-Mcgrady May 1, 2023
ea38f59
Fix: install called twice
Luc-Mcgrady May 1, 2023
ec4fd8a
Added: Non-blocking installer
Luc-Mcgrady May 1, 2023
6110488
Fix: Message not shown
Luc-Mcgrady May 1, 2023
ecf7b8b
Added: Critical fail message
Luc-Mcgrady May 1, 2023
800fc46
Added: Output
Luc-Mcgrady May 1, 2023
c0a13f7
Added: Results saving
Luc-Mcgrady May 1, 2023
285ee99
Added: Optimize thread
Luc-Mcgrady May 2, 2023
ba1997b
Fix: Error spam when training
Luc-Mcgrady May 2, 2023
9a46cb3
Fix: Install
Luc-Mcgrady May 2, 2023
14673c4
Added: Extra complete text
Luc-Mcgrady May 2, 2023
f315120
Added: optional retention opt-out
Luc-Mcgrady May 2, 2023
f9e6763
Updated: Gitignore
Luc-Mcgrady May 2, 2023
b3319df
Added: Thread quit
Luc-Mcgrady May 2, 2023
ea21e89
Fix: Doesn't run twice
Luc-Mcgrady May 2, 2023
d044f4c
Added: Auto-timezone
Luc-Mcgrady May 3, 2023
b98a4b6
Fix: Un-Optimized message when optimized
Luc-Mcgrady May 3, 2023
cec89d5
Fix: tqdm imported when not installed
Luc-Mcgrady May 3, 2023
abf3725
Added: Install error popup
Luc-Mcgrady May 3, 2023
43fd99f
Added: Better cog dialog
Luc-Mcgrady May 3, 2023
a688efa
Added: Progress bar
Luc-Mcgrady May 4, 2023
42a6f8a
Fix: Optimizer gives error
Luc-Mcgrady May 6, 2023
457cb75
Added: Config save rather than disk
Luc-Mcgrady May 6, 2023
d7d1de1
Added: Non string json config save
Luc-Mcgrady May 6, 2023
023b27e
Updated: Gitignore
Luc-Mcgrady May 6, 2023
4bffda3
Added: Editable other configs
Luc-Mcgrady May 6, 2023
de25710
Fix: Installer doesn't output to console
Luc-Mcgrady May 6, 2023
6f618cb
Added: Windows install
Luc-Mcgrady May 6, 2023
b8c8fef
Added: Timed update
Luc-Mcgrady May 6, 2023
a569832
Renamed: install path variables
Luc-Mcgrady May 6, 2023
b21a6b1
Last attempt at windows progress bar fix
Luc-Mcgrady May 6, 2023
7864f14
Fix: Windows errors
Luc-Mcgrady May 6, 2023
9dd9b15
Fix: Tooltip on wrong thread
Luc-Mcgrady May 6, 2023
70df2d2
Added: Stage to tooltip
Luc-Mcgrady May 6, 2023
2c3c6f3
"Fix": Optimal retention total number
Luc-Mcgrady May 6, 2023
98010a2
Added: No reviews message
Luc-Mcgrady May 6, 2023
5ba2b2a
Added: Moved results string to config class
Luc-Mcgrady May 6, 2023
c6a368e
Added: View results option
Luc-Mcgrady May 6, 2023
a5b9889
Fix: Results not loading before showing
Luc-Mcgrady May 6, 2023
564a506
Merge branch 'main' into optimizer
Luc-Mcgrady May 6, 2023
ac0516c
Added: Comment cleanup
Luc-Mcgrady May 6, 2023
5a757f0
Added: Git warning
Luc-Mcgrady May 6, 2023
d18a6d3
Fix: Retention warning wrong way around
Luc-Mcgrady May 6, 2023
9f3f590
Fix: Missing exporting deck tooltip.
Luc-Mcgrady May 7, 2023
98f5b1f
Added: Global config
Luc-Mcgrady May 7, 2023
8244672
Fix: Crash when optimizing empty deck
Luc-Mcgrady May 7, 2023
2319638
Merge branch 'main' into optimizer
Luc-Mcgrady May 8, 2023
2cc1775
Added: Operating system not supported message
Luc-Mcgrady May 11, 2023
12bb895
Merge branch 'main' into optimizer
Luc-Mcgrady May 19, 2023
b7a3b9f
Merge branch 'main' into optimizer
L-M-Sherlock Jun 21, 2023
e61cb25
add Dialog for installer
L-M-Sherlock Jun 21, 2023
0c6cb41
Merge branch 'open-spaced-repetition:main' into optimizer
Luc-Mcgrady Jul 2, 2023
0eb13c2
Added pip user flags
Luc-Mcgrady Jul 2, 2023
1be2c47
Loosened package version requirements
Luc-Mcgrady Jul 2, 2023
c5e2905
Removed: obsolete info
Luc-Mcgrady Jul 2, 2023
2aed3c9
Added: Install cancel
Luc-Mcgrady Jul 2, 2023
d22c6f7
Moved: Stdout function from global scope
Luc-Mcgrady Jul 2, 2023
1feae77
Fix: Errors with version 4
Luc-Mcgrady Jul 23, 2023
06c60e4
Added: Version 4 result string
Luc-Mcgrady Jul 23, 2023
1068279
Merge branch 'open-spaced-repetition:main' into optimizer
Luc-Mcgrady Jul 23, 2023
a9cb0fe
Fix: Missing closing bracket
Luc-Mcgrady Jul 23, 2023
be8383d
Fix: Double curley bracket
Luc-Mcgrady Jul 23, 2023
a94172f
Merge remote-tracking branch 'origin/main' into optimizer
Luc-Mcgrady Aug 17, 2023
14594b4
Fix: Prevent concurrent optimizations
Luc-Mcgrady Aug 17, 2023
616fc2e
Merge remote-tracking branch 'upstream/main' into optimizer
Luc-Mcgrady Sep 11, 2023
02f0d35
Merge branch 'open-spaced-repetition:main' into optimizer
Luc-Mcgrady Sep 25, 2023
e293976
Fix: Optimizer locked after error
Luc-Mcgrady Sep 25, 2023
453c0bf
Merge branch 'optimizer' of https://github.com/Luc-mcgrady/fsrs4anki-…
Luc-Mcgrady Sep 25, 2023
f8cd7be
Fix:fsrs4anki optimizer takes 0 arguments (Thanks
Luc-Mcgrady Sep 25, 2023
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
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
.DS_Store
.idea/
__pycache__

*.anki*
*.apkg
*.colpkg
media
meta

*.csv
*.tsv
*.pth

meta.json
.vscode/
8 changes: 8 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
Config,
run_on_configuration_change
)
from .optimizer import optimize, install as install_optimizer

from aqt.utils import showInfo

"""
Acknowledgement to Arthur Milchior, Carlos Duarte and oakkitten.
Expand Down Expand Up @@ -111,6 +113,10 @@ def reschedule_recent(did):

menu_disperse_siblings = build_action(disperse_siblings, "Disperse all siblings")

menu_install_optimizer = build_action(install_optimizer, "Install local optimizer")
menu_show_saved_optimized = build_action(lambda _: showInfo(config.results_string()), "Show saved optimized deck settings")
add_action_to_gear(optimize, "Optimize")

menu_for_helper = mw.form.menuTools.addMenu("FSRS4Anki Helper")
menu_for_helper.addAction(menu_auto_reschedule)
menu_for_helper.addAction(menu_auto_disperse)
Expand All @@ -123,6 +129,8 @@ def reschedule_recent(did):
menu_for_helper.addAction(menu_advance)
menu_for_helper.addAction(menu_reset)
menu_for_helper.addAction(menu_disperse_siblings)
menu_for_helper.addAction(menu_install_optimizer)
menu_for_helper.addAction(menu_show_saved_optimized)


def set_free_days(day, checked):
Expand Down
63 changes: 61 additions & 2 deletions configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@

tag = mw.addonManager.addonFromModule(__name__)

# Config
LOAD_BALANCE = "load_balance"
FREE_DAYS = "free_days"
DAYS_TO_RESCHEDULE = "days_to_reschedule"
AUTO_RESCHEDULE_AFTER_SYNC = "auto_reschedule_after_sync"
AUTO_DISPERSE = "auto_disperse"

SAVED_OPTIMIZED_PARAMETERS = "saved_optimized"

# Deck params
RETENTION_IS_NOT_OPTIMIZED = "unoptimized_retention_warning"
REQUEST_RETENTION = "requested_retention"
MAX_INTERVAL = "maximum_interval"
EASY_BONUS = "easy_bonus"
HARD_INTERVAL = "hard_interval"

DEFAULT_PARAMS = {
"DEFAULT": {
"name": "global config for FSRS4Anki",
"w": [1, 1, 5, -0.5, -0.5, 0.2, 1.4, -0.12, 0.8, 2, -0.2, 0.2, 1],
REQUEST_RETENTION: 0.9,
MAX_INTERVAL: 36500,
EASY_BONUS: 1.3,
HARD_INTERVAL: 1.2,
RETENTION_IS_NOT_OPTIMIZED: False,
}
}

def load_config():
return mw.addonManager.getConfig(tag)
Expand Down Expand Up @@ -77,4 +97,43 @@ def auto_disperse(self):
@auto_disperse.setter
def auto_disperse(self, value):
self.data[AUTO_DISPERSE] = value
self.save()
self.save()

@property
def saved_optimized(self):
return self.data.get(SAVED_OPTIMIZED_PARAMETERS, DEFAULT_PARAMS)

@saved_optimized.setter
def saved_optimized(self, value):
self.data[SAVED_OPTIMIZED_PARAMETERS] = value
self.save()

@staticmethod
def result_string(result: dict[str]):
"""Produce the pasteable config for a singular result"""
return \
f""" {{
// Generated, Optimized anki deck settings
"deckName": "{result["name"]}",
"w": {result["w"]},
"requestRetention": {result[REQUEST_RETENTION]}, {"//Un-optimized, Replace this with desired number." if result[RETENTION_IS_NOT_OPTIMIZED] else ""}
"maximumInterval": {result[MAX_INTERVAL]},
"easyBonus": {result[EASY_BONUS]},
"hardInterval": {result[HARD_INTERVAL]},
}},"""

def results_string(self):
"""Get the config for every result"""
self.load()
results = '\n'.join(self.result_string(a) for a in self.saved_optimized.values())

return \
f"""// Copy this into your optimizer code.
// You can edit these values in the addon's config.
// The full optimizer you need to paste this into can be found here
// https://github.com/open-spaced-repetition/fsrs4anki/blob/main/fsrs4anki_scheduler.js

const deckParams = [
{results}
]
"""
Loading