derek-thomas HF staff commited on
Commit
6f07fa0
1 Parent(s): 1f530a5

Updating Markdown

Browse files

Adding `fast_mode`

Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -9,13 +9,32 @@ from memory_states import get_my_memory_states
9
  from plot import make_plot
10
 
11
 
12
- def anki_optimizer(file, timezone, next_day_starts_at, revlog_start_date, requestRetention,
 
 
 
 
 
 
 
 
 
13
  progress=gr.Progress(track_tqdm=True)):
14
  now = datetime.now()
 
 
15
  prefix = now.strftime(f'%Y_%m_%d_%H_%M_%S')
 
16
  proj_dir = extract(file, prefix)
 
17
  type_sequence, df_out = create_time_series_features(revlog_start_date, timezone, next_day_starts_at, proj_dir)
18
  w, dataset = train_model(proj_dir)
 
 
 
 
 
 
19
  my_collection, rating_markdown = process_personalized_collection(requestRetention, w)
20
  difficulty_distribution_padding, difficulty_distribution = get_my_memory_states(proj_dir, dataset, my_collection)
21
  fig, suggested_retention_markdown = make_plot(proj_dir, type_sequence, w, difficulty_distribution_padding)
@@ -33,20 +52,10 @@ def anki_optimizer(file, timezone, next_day_starts_at, revlog_start_date, reques
33
  # Ratings
34
  {rating_markdown}
35
  """
36
-
37
- w_markdown = f"""
38
- # Updated Parameters
39
- Copy and paste these as shown in step 5 of the instructions:
40
-
41
- `var w = {w};`
42
-
43
- Check out the Analysis tab for more detailed information."""
44
- files = ['prediction.tsv', 'revlog.csv', 'revlog_history.tsv', 'stability_for_analysis.tsv',
45
- 'expected_repetitions.csv']
46
- files_out = [proj_dir / file for file in files]
47
- cleanup(proj_dir, files)
48
  return w_markdown, df_out, fig, markdown_out, files_out
49
 
 
50
  description = """
51
  # FSRS4Anki Optimizer App
52
  Based on the [tutorial](https://medium.com/@JarrettYe/how-to-use-the-next-generation-spaced-repetition-algorithm-fsrs-on-anki-5a591ca562e2)
@@ -61,7 +70,9 @@ with gr.Blocks() as demo:
61
  gr.Markdown(description)
62
  with gr.Box():
63
  with gr.Row():
64
- file = gr.File(label='Review Logs (Step 1)')
 
 
65
  with gr.Column():
66
  next_day_starts_at = gr.Number(value=4,
67
  label="Next Day Starts at (Step 2)",
@@ -116,7 +127,7 @@ with gr.Blocks() as demo:
116
  files_output = gr.Files(label="Analysis Files")
117
 
118
  btn_plot.click(anki_optimizer,
119
- inputs=[file, timezone, next_day_starts_at, revlog_start_date, requestRetention],
120
  outputs=[w_output, df_output, plot_output, markdown_output, files_output])
121
 
122
  if __name__ == '__main__':
 
9
  from plot import make_plot
10
 
11
 
12
+ def get_w_markdown(w):
13
+ return f"""
14
+ # Updated Parameters
15
+ Copy and paste these as shown in step 5 of the instructions:
16
+
17
+ `var w = {w};`
18
+ Check out the Analysis tab for more detailed information."""
19
+
20
+
21
+ def anki_optimizer(file, timezone, next_day_starts_at, revlog_start_date, requestRetention, fast_mode,
22
  progress=gr.Progress(track_tqdm=True)):
23
  now = datetime.now()
24
+ files = ['prediction.tsv', 'revlog.csv', 'revlog_history.tsv', 'stability_for_analysis.tsv',
25
+ 'expected_repetitions.csv']
26
  prefix = now.strftime(f'%Y_%m_%d_%H_%M_%S')
27
+
28
  proj_dir = extract(file, prefix)
29
+
30
  type_sequence, df_out = create_time_series_features(revlog_start_date, timezone, next_day_starts_at, proj_dir)
31
  w, dataset = train_model(proj_dir)
32
+ w_markdown = get_w_markdown(w)
33
+ cleanup(proj_dir, files)
34
+ if fast_mode:
35
+ files_out = [proj_dir / file for file in files if (proj_dir / file).exists()]
36
+ return w_markdown, None, None, "", files_out
37
+
38
  my_collection, rating_markdown = process_personalized_collection(requestRetention, w)
39
  difficulty_distribution_padding, difficulty_distribution = get_my_memory_states(proj_dir, dataset, my_collection)
40
  fig, suggested_retention_markdown = make_plot(proj_dir, type_sequence, w, difficulty_distribution_padding)
 
52
  # Ratings
53
  {rating_markdown}
54
  """
55
+ files_out = [proj_dir / file for file in files if (proj_dir / file).exists()]
 
 
 
 
 
 
 
 
 
 
 
56
  return w_markdown, df_out, fig, markdown_out, files_out
57
 
58
+
59
  description = """
60
  # FSRS4Anki Optimizer App
61
  Based on the [tutorial](https://medium.com/@JarrettYe/how-to-use-the-next-generation-spaced-repetition-algorithm-fsrs-on-anki-5a591ca562e2)
 
70
  gr.Markdown(description)
71
  with gr.Box():
72
  with gr.Row():
73
+ with gr.Column():
74
+ file = gr.File(label='Review Logs (Step 1)')
75
+ fast_mode_in = gr.Checkbox(value=False, label="Fast Mode (No analysis)")
76
  with gr.Column():
77
  next_day_starts_at = gr.Number(value=4,
78
  label="Next Day Starts at (Step 2)",
 
127
  files_output = gr.Files(label="Analysis Files")
128
 
129
  btn_plot.click(anki_optimizer,
130
+ inputs=[file, timezone, next_day_starts_at, revlog_start_date, requestRetention, fast_mode_in],
131
  outputs=[w_output, df_output, plot_output, markdown_output, files_output])
132
 
133
  if __name__ == '__main__':