akhaliq HF staff commited on
Commit
d2a8abe
·
verified ·
1 Parent(s): 91c14ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -5
app.py CHANGED
@@ -288,14 +288,25 @@ class PaperManager:
288
 
289
 
290
  # Initialize PaperList and PaperManager
291
- def initialize_paper_manager() -> PaperManager:
292
  df = get_df()
293
  paper_list = PaperList(df)
294
  manager = PaperManager(paper_list)
295
- return manager
296
 
297
 
298
- paper_manager = initialize_paper_manager()
 
 
 
 
 
 
 
 
 
 
 
299
 
300
 
301
  def update_paper_manager() -> str:
@@ -489,6 +500,7 @@ with demo:
489
 
490
  Once your paper is submitted, it will automatically appear in this demo.
491
  """)
 
492
  # Header with Refresh Button
493
  with gr.Row():
494
  gr.HTML("""
@@ -505,6 +517,7 @@ with demo:
505
  </tr>
506
  </table>
507
  """)
 
508
  # Sort Options
509
  with gr.Row():
510
  sort_radio = gr.Radio(
@@ -513,15 +526,20 @@ with demo:
513
  label="Sort By",
514
  interactive=True
515
  )
 
516
  # Paper list
517
  paper_list = gr.HTML()
 
518
  # Navigation Buttons
519
  with gr.Row():
520
  prev_button = gr.Button("Prev")
521
  next_button = gr.Button("Next")
522
 
523
  # Load papers on app start
524
- demo.load(initialize_paper_manager, outputs=[paper_list])
 
 
 
525
 
526
  # Button clicks for pagination
527
  prev_button.click(paper_manager.prev_page, outputs=[paper_list])
@@ -558,4 +576,4 @@ with demo:
558
  # --- Launch the App ---
559
 
560
  if __name__ == "__main__":
561
- demo.launch()
 
288
 
289
 
290
  # Initialize PaperList and PaperManager
291
+ def initialize_paper_manager() -> str:
292
  df = get_df()
293
  paper_list = PaperList(df)
294
  manager = PaperManager(paper_list)
295
+ return manager.get_current_page_papers() # Return HTML string instead of the manager object
296
 
297
 
298
+ paper_manager = None # Initialize globally
299
+
300
+
301
+ def setup_paper_manager():
302
+ global paper_manager
303
+ df = get_df()
304
+ paper_list = PaperList(df)
305
+ paper_manager = PaperManager(paper_list)
306
+
307
+
308
+ # Initialize PaperManager at the start
309
+ setup_paper_manager()
310
 
311
 
312
  def update_paper_manager() -> str:
 
500
 
501
  Once your paper is submitted, it will automatically appear in this demo.
502
  """)
503
+
504
  # Header with Refresh Button
505
  with gr.Row():
506
  gr.HTML("""
 
517
  </tr>
518
  </table>
519
  """)
520
+
521
  # Sort Options
522
  with gr.Row():
523
  sort_radio = gr.Radio(
 
526
  label="Sort By",
527
  interactive=True
528
  )
529
+
530
  # Paper list
531
  paper_list = gr.HTML()
532
+
533
  # Navigation Buttons
534
  with gr.Row():
535
  prev_button = gr.Button("Prev")
536
  next_button = gr.Button("Next")
537
 
538
  # Load papers on app start
539
+ demo.load(
540
+ fn=lambda: paper_manager.get_current_page_papers(),
541
+ outputs=[paper_list]
542
+ )
543
 
544
  # Button clicks for pagination
545
  prev_button.click(paper_manager.prev_page, outputs=[paper_list])
 
576
  # --- Launch the App ---
577
 
578
  if __name__ == "__main__":
579
+ demo.launch()