Spaces:
Sleeping
Sleeping
earlsab commited on
Commit ·
cbdd8ec
1
Parent(s): 7656bed
use filename as column
Browse files
app.py
CHANGED
|
@@ -88,7 +88,7 @@ def wake_servers(progress=gr.Progress()):
|
|
| 88 |
|
| 89 |
def try_wake_endpoint(name, url):
|
| 90 |
"""Helper function to wake endpoint with retry logic"""
|
| 91 |
-
retry_delays = [30,
|
| 92 |
|
| 93 |
for retry_count, retry_delay in enumerate(retry_delays):
|
| 94 |
try:
|
|
@@ -297,10 +297,14 @@ def process_resume(resume_text: str, job_skills: List[str], progress=None, progr
|
|
| 297 |
|
| 298 |
return formatted_result
|
| 299 |
|
| 300 |
-
def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
|
| 301 |
"""Create HTML output for the interface"""
|
| 302 |
html = "<div style='font-family: Arial, sans-serif;'>"
|
| 303 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
# Job Description Section
|
| 305 |
html += "<h2>Job Description Analysis</h2>"
|
| 306 |
html += f"<p><strong>Total Skills Found:</strong> {job_result['total_skills']}</p>"
|
|
@@ -449,7 +453,8 @@ def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
|
|
| 449 |
'total_experience': total_experience,
|
| 450 |
'category': category,
|
| 451 |
'quality_score': quality_score,
|
| 452 |
-
'resume_result': resume_result
|
|
|
|
| 453 |
})
|
| 454 |
|
| 455 |
# Sort resume data:
|
|
@@ -500,9 +505,10 @@ def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
|
|
| 500 |
collaboration_count = resume_data['collaboration_count']
|
| 501 |
total_experience = resume_data['total_experience']
|
| 502 |
category = resume_data['category']
|
|
|
|
| 503 |
|
| 504 |
-
# Add row to summary table
|
| 505 |
-
html += f"<tr><td style='padding: 8px; border: 1px solid #ddd;'>
|
| 506 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{match_count}/{job_result['total_skills']}</td>"
|
| 507 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{match_percentage}%</td>"
|
| 508 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{leadership_count}</td>"
|
|
@@ -552,9 +558,12 @@ def create_html_output(job_result: Dict, resume_results: List[Dict]) -> str:
|
|
| 552 |
html += f"<p><strong>Total Years of Experience:</strong> {total_experience}</p>"
|
| 553 |
html += f"<p><strong>Category:</strong> {category}</p>"
|
| 554 |
|
|
|
|
|
|
|
|
|
|
| 555 |
# Detailed resume section with visibility control
|
| 556 |
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};'>"
|
| 557 |
-
html += f"<h3>
|
| 558 |
|
| 559 |
# Display all skills found in the resume
|
| 560 |
html += "<p><strong>Skills Found:</strong></p>"
|
|
@@ -643,8 +652,11 @@ def process_single_resume(file_path, job_skills, progress=None, resume_index=0,
|
|
| 643 |
with open(file_path, 'r', encoding='utf-8') as f:
|
| 644 |
resume_content = f.read()
|
| 645 |
|
| 646 |
-
|
| 647 |
progress=progress, progress_base=progress_base, progress_cap=progress_cap)
|
|
|
|
|
|
|
|
|
|
| 648 |
|
| 649 |
def process_inputs(job_description: str, input_type: str, resume_text: str, resume_files: List[str], progress=gr.Progress()) -> str:
|
| 650 |
"""Main processing function"""
|
|
@@ -657,12 +669,15 @@ def process_inputs(job_description: str, input_type: str, resume_text: str, resu
|
|
| 657 |
|
| 658 |
# Process resumes based on input type
|
| 659 |
resume_results = []
|
|
|
|
|
|
|
| 660 |
if input_type == "Paste Text":
|
| 661 |
# Process single resume from text input
|
| 662 |
progress(0.4, desc="Analyzing resume structure and extracting roles...")
|
| 663 |
resume_result = process_resume(resume_text, job_skills,
|
| 664 |
progress=progress, progress_base=0.4, progress_cap=0.9)
|
| 665 |
resume_results.append(resume_result)
|
|
|
|
| 666 |
else:
|
| 667 |
# Process multiple resumes from file uploads in parallel
|
| 668 |
resume_count = len(resume_files)
|
|
@@ -678,14 +693,17 @@ def process_inputs(job_description: str, input_type: str, resume_text: str, resu
|
|
| 678 |
progress,
|
| 679 |
i,
|
| 680 |
resume_count
|
| 681 |
-
):
|
| 682 |
}
|
| 683 |
|
| 684 |
# Collect results as they complete
|
| 685 |
completed = 0
|
| 686 |
total = len(future_to_resume)
|
| 687 |
for future in concurrent.futures.as_completed(future_to_resume):
|
| 688 |
-
|
|
|
|
|
|
|
|
|
|
| 689 |
completed += 1
|
| 690 |
try:
|
| 691 |
if progress is not None:
|
|
@@ -696,7 +714,7 @@ def process_inputs(job_description: str, input_type: str, resume_text: str, resu
|
|
| 696 |
|
| 697 |
# Create HTML output
|
| 698 |
progress(0.9, desc="Generating results and preparing final report...")
|
| 699 |
-
html_output = create_html_output(job_result, resume_results)
|
| 700 |
progress(1.0, desc="Analysis complete!")
|
| 701 |
return html_output
|
| 702 |
|
|
|
|
| 88 |
|
| 89 |
def try_wake_endpoint(name, url):
|
| 90 |
"""Helper function to wake endpoint with retry logic"""
|
| 91 |
+
retry_delays = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30] # Seconds to wait between retries
|
| 92 |
|
| 93 |
for retry_count, retry_delay in enumerate(retry_delays):
|
| 94 |
try:
|
|
|
|
| 297 |
|
| 298 |
return formatted_result
|
| 299 |
|
| 300 |
+
def create_html_output(job_result: Dict, resume_results: List[Dict], filenames: List[str] = None) -> str:
|
| 301 |
"""Create HTML output for the interface"""
|
| 302 |
html = "<div style='font-family: Arial, sans-serif;'>"
|
| 303 |
|
| 304 |
+
# Set default filenames if not provided
|
| 305 |
+
if not filenames:
|
| 306 |
+
filenames = [f"Resume {i}" for i in range(1, len(resume_results) + 1)]
|
| 307 |
+
|
| 308 |
# Job Description Section
|
| 309 |
html += "<h2>Job Description Analysis</h2>"
|
| 310 |
html += f"<p><strong>Total Skills Found:</strong> {job_result['total_skills']}</p>"
|
|
|
|
| 453 |
'total_experience': total_experience,
|
| 454 |
'category': category,
|
| 455 |
'quality_score': quality_score,
|
| 456 |
+
'resume_result': resume_result,
|
| 457 |
+
'filename': filenames[i-1] # Store the filename
|
| 458 |
})
|
| 459 |
|
| 460 |
# Sort resume data:
|
|
|
|
| 505 |
collaboration_count = resume_data['collaboration_count']
|
| 506 |
total_experience = resume_data['total_experience']
|
| 507 |
category = resume_data['category']
|
| 508 |
+
filename = resume_data['filename'] # Get the filename
|
| 509 |
|
| 510 |
+
# Add row to summary table - using filename instead of "Resume {i}"
|
| 511 |
+
html += f"<tr><td style='padding: 8px; border: 1px solid #ddd;'>{filename}</td>"
|
| 512 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{match_count}/{job_result['total_skills']}</td>"
|
| 513 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{match_percentage}%</td>"
|
| 514 |
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{leadership_count}</td>"
|
|
|
|
| 558 |
html += f"<p><strong>Total Years of Experience:</strong> {total_experience}</p>"
|
| 559 |
html += f"<p><strong>Category:</strong> {category}</p>"
|
| 560 |
|
| 561 |
+
# Get the filename for this resume
|
| 562 |
+
resume_file = filenames[i-1]
|
| 563 |
+
|
| 564 |
# Detailed resume section with visibility control
|
| 565 |
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};'>"
|
| 566 |
+
html += f"<h3>{resume_file} Details</h3>"
|
| 567 |
|
| 568 |
# Display all skills found in the resume
|
| 569 |
html += "<p><strong>Skills Found:</strong></p>"
|
|
|
|
| 652 |
with open(file_path, 'r', encoding='utf-8') as f:
|
| 653 |
resume_content = f.read()
|
| 654 |
|
| 655 |
+
result = process_resume(resume_content, job_skills,
|
| 656 |
progress=progress, progress_base=progress_base, progress_cap=progress_cap)
|
| 657 |
+
|
| 658 |
+
# Return both the result and the filename
|
| 659 |
+
return result, os.path.basename(file_path)
|
| 660 |
|
| 661 |
def process_inputs(job_description: str, input_type: str, resume_text: str, resume_files: List[str], progress=gr.Progress()) -> str:
|
| 662 |
"""Main processing function"""
|
|
|
|
| 669 |
|
| 670 |
# Process resumes based on input type
|
| 671 |
resume_results = []
|
| 672 |
+
filenames = [] # Track filenames for multiple uploads
|
| 673 |
+
|
| 674 |
if input_type == "Paste Text":
|
| 675 |
# Process single resume from text input
|
| 676 |
progress(0.4, desc="Analyzing resume structure and extracting roles...")
|
| 677 |
resume_result = process_resume(resume_text, job_skills,
|
| 678 |
progress=progress, progress_base=0.4, progress_cap=0.9)
|
| 679 |
resume_results.append(resume_result)
|
| 680 |
+
filenames.append("Pasted Resume") # Default name for pasted text
|
| 681 |
else:
|
| 682 |
# Process multiple resumes from file uploads in parallel
|
| 683 |
resume_count = len(resume_files)
|
|
|
|
| 693 |
progress,
|
| 694 |
i,
|
| 695 |
resume_count
|
| 696 |
+
): file_path for i, file_path in enumerate(resume_files)
|
| 697 |
}
|
| 698 |
|
| 699 |
# Collect results as they complete
|
| 700 |
completed = 0
|
| 701 |
total = len(future_to_resume)
|
| 702 |
for future in concurrent.futures.as_completed(future_to_resume):
|
| 703 |
+
file_path = future_to_resume[future]
|
| 704 |
+
result, filename = future.result()
|
| 705 |
+
resume_results.append(result)
|
| 706 |
+
filenames.append(filename)
|
| 707 |
completed += 1
|
| 708 |
try:
|
| 709 |
if progress is not None:
|
|
|
|
| 714 |
|
| 715 |
# Create HTML output
|
| 716 |
progress(0.9, desc="Generating results and preparing final report...")
|
| 717 |
+
html_output = create_html_output(job_result, resume_results, filenames)
|
| 718 |
progress(1.0, desc="Analysis complete!")
|
| 719 |
return html_output
|
| 720 |
|