Fix/close figure in the end and check the inputs
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import pytz
|
3 |
import os
|
|
|
4 |
from datetime import datetime
|
5 |
from markdown import instructions_markdown, faq_markdown
|
6 |
from fsrs4anki_optimizer import Optimizer
|
@@ -18,7 +19,11 @@ def get_w_markdown(w):
|
|
18 |
|
19 |
|
20 |
def anki_optimizer(file: gr.File, timezone, next_day_starts_at, revlog_start_date, requestRetention,
|
21 |
-
progress=gr.Progress(track_tqdm=True)):
|
|
|
|
|
|
|
|
|
22 |
now = datetime.now()
|
23 |
files = ['prediction.tsv', 'revlog.csv', 'revlog_history.tsv', 'stability_for_analysis.tsv',
|
24 |
'expected_time.csv', 'evaluation.tsv']
|
@@ -59,10 +64,10 @@ def anki_optimizer(file: gr.File, timezone, next_day_starts_at, revlog_start_dat
|
|
59 |
{rating_markdown}
|
60 |
"""
|
61 |
os.chdir('../../..')
|
|
|
62 |
files_out = [proj_dir / file for file in files if (proj_dir / file).exists()]
|
63 |
cleanup(proj_dir, files)
|
64 |
-
|
65 |
-
print(files_out)
|
66 |
return w_markdown, markdown_out, plot_output, files_out
|
67 |
|
68 |
|
|
|
1 |
import gradio as gr
|
2 |
import pytz
|
3 |
import os
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
from datetime import datetime
|
6 |
from markdown import instructions_markdown, faq_markdown
|
7 |
from fsrs4anki_optimizer import Optimizer
|
|
|
19 |
|
20 |
|
21 |
def anki_optimizer(file: gr.File, timezone, next_day_starts_at, revlog_start_date, requestRetention,
|
22 |
+
progress=gr.Progress(track_tqdm=True)):
|
23 |
+
if file is None or (not file.name.endswith(".apkg") and not file.name.endswith(".colpkg")):
|
24 |
+
raise ValueError("Please upload a deck/collection file.")
|
25 |
+
if timezone == "":
|
26 |
+
raise ValueError("Please select a timezone.")
|
27 |
now = datetime.now()
|
28 |
files = ['prediction.tsv', 'revlog.csv', 'revlog_history.tsv', 'stability_for_analysis.tsv',
|
29 |
'expected_time.csv', 'evaluation.tsv']
|
|
|
64 |
{rating_markdown}
|
65 |
"""
|
66 |
os.chdir('../../..')
|
67 |
+
print(os.getcwd())
|
68 |
files_out = [proj_dir / file for file in files if (proj_dir / file).exists()]
|
69 |
cleanup(proj_dir, files)
|
70 |
+
plt.close('all')
|
|
|
71 |
return w_markdown, markdown_out, plot_output, files_out
|
72 |
|
73 |
|