earlsab commited on
Commit
6f4eee8
·
1 Parent(s): 9ebd77d

better progress bars

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -444,7 +444,7 @@ def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
444
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{total_experience}</td>"
445
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{category}</td>"
446
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>"
447
- html += f"<button onclick=\"document.getElementById('resume-detail-{i}').style.display = document.getElementById('resume-detail-{i}').style.display === 'none' ? 'block' : 'none';\" style='background-color: #4CAF50; color: white; padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;'>Toggle Details</button>"
448
  html += "</td></tr>"
449
 
450
  html += "</table>"
@@ -487,7 +487,7 @@ def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
487
  html += f"<p><strong>Category:</strong> {category}</p>"
488
 
489
  # Detailed resume section with visibility control
490
- html += f"<div id='resume-detail-{i}' style='margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; display: {display_style};'>"
491
  html += f"<h3>Resume {i} Details</h3>"
492
 
493
  # Display all skills found in the resume
@@ -600,7 +600,7 @@ def process_inputs(job_description: str, input_type: str, resume_text: str, resu
600
  else:
601
  # Process multiple resumes from file uploads in parallel
602
  resume_count = len(resume_files)
603
- progress(0.4, desc=f"Starting analysis of {resume_count} resumes...")
604
 
605
  with concurrent.futures.ThreadPoolExecutor() as executor:
606
  # Submit all resume processing tasks
@@ -616,8 +616,17 @@ def process_inputs(job_description: str, input_type: str, resume_text: str, resu
616
  }
617
 
618
  # Collect results as they complete
 
 
619
  for future in concurrent.futures.as_completed(future_to_resume):
620
  resume_results.append(future.result())
 
 
 
 
 
 
 
621
 
622
  # Create HTML output
623
  progress(0.9, desc="Generating results and preparing final report...")
@@ -630,10 +639,9 @@ with gr.Blocks(title="Beyond Keywords: Resume Analysis System", js=js_func) as d
630
  gr.Markdown("# Beyond Keywords: Job Description and Resume Analyzer")
631
  gr.Markdown("Upload a job description and resume(s) to analyze skill matches and quality.")
632
 
633
- # Wake servers button
634
  wake_btn = gr.Button("Wake Servers (Do this first!)")
635
- wake_status = gr.HTML(label="Server Status")
636
- wake_btn.click(fn=wake_servers, inputs=None, outputs=wake_status)
637
 
638
  with gr.Row():
639
  with gr.Column():
@@ -676,9 +684,11 @@ with gr.Blocks(title="Beyond Keywords: Resume Analysis System", js=js_func) as d
676
  inputs=input_type,
677
  outputs=[resume_text, resume_file]
678
  )
 
679
 
680
  submit_btn = gr.Button("Analyze")
681
- output = gr.HTML(label="Analysis Results")
 
682
 
683
  submit_btn.click(
684
  fn=process_inputs,
 
444
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{total_experience}</td>"
445
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{category}</td>"
446
  html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>"
447
+ html += f"<button onclick=\"const allDetails = document.querySelectorAll('.resume-detail'); allDetails.forEach(detail => {{ if(detail.id !== 'resume-detail-{i}') detail.style.display = 'none'; }}); document.getElementById('resume-detail-{i}').style.display = document.getElementById('resume-detail-{i}').style.display === 'none' ? 'block' : 'none';\" style='background-color: #4CAF50; color: white; padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;'>Toggle Details</button>"
448
  html += "</td></tr>"
449
 
450
  html += "</table>"
 
487
  html += f"<p><strong>Category:</strong> {category}</p>"
488
 
489
  # Detailed resume section with visibility control
490
+ html += f"<div id='resume-detail-{i}' class='resume-detail' style='margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; display: {display_style};'>"
491
  html += f"<h3>Resume {i} Details</h3>"
492
 
493
  # Display all skills found in the resume
 
600
  else:
601
  # Process multiple resumes from file uploads in parallel
602
  resume_count = len(resume_files)
603
+ progress(0.4, desc=f"Starting analysis of {resume_count} resumes in parallel...")
604
 
605
  with concurrent.futures.ThreadPoolExecutor() as executor:
606
  # Submit all resume processing tasks
 
616
  }
617
 
618
  # Collect results as they complete
619
+ completed = 0
620
+ total = len(future_to_resume)
621
  for future in concurrent.futures.as_completed(future_to_resume):
622
  resume_results.append(future.result())
623
+ completed += 1
624
+ try:
625
+ if progress is not None:
626
+ progress(0.4 + (0.5 * completed/total), desc=f"Completed analysis of {completed}/{total} resumes...")
627
+ except:
628
+ pass
629
+
630
 
631
  # Create HTML output
632
  progress(0.9, desc="Generating results and preparing final report...")
 
639
  gr.Markdown("# Beyond Keywords: Job Description and Resume Analyzer")
640
  gr.Markdown("Upload a job description and resume(s) to analyze skill matches and quality.")
641
 
 
642
  wake_btn = gr.Button("Wake Servers (Do this first!)")
643
+ wake_status = gr.HTML(label="Server Status", value="<div style='color: #666;'>Click 'Wake Servers'<br>to initialize the system...</div>"); wake_btn.click(fn=wake_servers, inputs=None, outputs=wake_status)
644
+ gr.Markdown("""<div style="height: 20px;"></div>""")
645
 
646
  with gr.Row():
647
  with gr.Column():
 
684
  inputs=input_type,
685
  outputs=[resume_text, resume_file]
686
  )
687
+ gr.Markdown("""<div style="height: 20px;"></div>""")
688
 
689
  submit_btn = gr.Button("Analyze")
690
+ output = gr.HTML(label="Analysis Results", value="<div style='color: #666;'>Click 'Wake Servers'<br>to initialize the system...</div>"); submit_btn.click(fn=process_inputs, inputs=[job_description, input_type, resume_text, resume_file], outputs=output)
691
+ gr.Markdown("""<div style="height: 20px;"></div>""")
692
 
693
  submit_btn.click(
694
  fn=process_inputs,