C2MV commited on
Commit
a7754c8
·
verified ·
1 Parent(s): 4d6b47a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -488,33 +488,31 @@ def create_gradio_interface():
488
  downloader = PaperDownloader()
489
 
490
  def update_progress(message, log_message=""):
491
- return gr.HTML.update(value=f"{message}"), gr.HTML.update(value=f"<pre>{log_message}</pre>")
492
 
493
  async def download_papers(bib_file, doi_input, dois_input):
 
494
 
495
  def custom_progress_callback(message):
496
- logger.info(f"Callback message: {message}") #for debug purposes, should log message
497
-
498
- #this method will update the custom field instead
499
- updates = update_progress(message)
500
- return updates
501
-
502
 
503
  if bib_file:
504
- # Check file type
505
  if not bib_file.name.lower().endswith('.bib'):
506
  return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file", "", None
507
 
508
  zip_path, downloaded_dois, failed_dois, _ = await downloader.process_bibtex_async(bib_file, custom_progress_callback)
509
- return zip_path, downloaded_dois, failed_dois, "", None
510
  elif doi_input:
511
  filepath, message, failed_doi, _ = await downloader.download_single_doi_async(doi_input,custom_progress_callback)
512
  return None, message, failed_doi, "", filepath
513
  elif dois_input:
514
  zip_path, downloaded_dois, failed_dois, _ = await downloader.download_multiple_dois_async(dois_input, custom_progress_callback)
515
- return zip_path, downloaded_dois, failed_dois, "", None
516
  else:
517
  return None, "Please provide a .bib file, a single DOI, or a list of DOIs", "Please provide a .bib file, a single DOI, or a list of DOIs", "", None
 
518
 
519
 
520
  # Gradio Interface
@@ -543,7 +541,7 @@ def create_gradio_interface():
543
  <div id="failed-dois"></div>
544
  </div>
545
  """),
546
- gr.HTML(label="""
547
  <div style='padding-bottom: 5px; font-weight: bold;'>
548
  Logs
549
  </div>
 
488
  downloader = PaperDownloader()
489
 
490
  def update_progress(message, log_message=""):
491
+ return gr.HTML.update(value=f"{message}"), gr.HTML.update(value=f"<pre>{log_message}</pre>")
492
 
493
  async def download_papers(bib_file, doi_input, dois_input):
494
+ progress_field = gr.HTML()
495
 
496
  def custom_progress_callback(message):
497
+ logger.info(f"Callback message: {message}")
498
+ return gr.HTML.update(value=f"{message}"), "" #return html for update output + empty logs to keep compatibility
 
 
 
 
499
 
500
  if bib_file:
501
+ # Check file type
502
  if not bib_file.name.lower().endswith('.bib'):
503
  return None, "Error: Please upload a .bib file", "Error: Please upload a .bib file", "", None
504
 
505
  zip_path, downloaded_dois, failed_dois, _ = await downloader.process_bibtex_async(bib_file, custom_progress_callback)
506
+ return zip_path, downloaded_dois, failed_dois, "", None
507
  elif doi_input:
508
  filepath, message, failed_doi, _ = await downloader.download_single_doi_async(doi_input,custom_progress_callback)
509
  return None, message, failed_doi, "", filepath
510
  elif dois_input:
511
  zip_path, downloaded_dois, failed_dois, _ = await downloader.download_multiple_dois_async(dois_input, custom_progress_callback)
512
+ return zip_path, downloaded_dois, failed_dois, "", None
513
  else:
514
  return None, "Please provide a .bib file, a single DOI, or a list of DOIs", "Please provide a .bib file, a single DOI, or a list of DOIs", "", None
515
+
516
 
517
 
518
  # Gradio Interface
 
541
  <div id="failed-dois"></div>
542
  </div>
543
  """),
544
+ gr.HTML(label="""
545
  <div style='padding-bottom: 5px; font-weight: bold;'>
546
  Logs
547
  </div>