Spaces:
Sleeping
Sleeping
Update src/app_job_copy_1.py
#1
by jyotidabass91 - opened
- src/app_job_copy_1.py +20 -14
src/app_job_copy_1.py
CHANGED
|
@@ -410,28 +410,34 @@ def display_job_selection(jobs_df, candidates_df, sh):
|
|
| 410 |
# Clear previous job state when a new job is selected
|
| 411 |
if selected_job_index != st.session_state.last_selected_job_index:
|
| 412 |
old_job_key = st.session_state.last_selected_job_index
|
| 413 |
-
|
| 414 |
-
# Clear job-specific session state
|
| 415 |
job_processed_key = f"job_{old_job_key}_processed_successfully"
|
| 416 |
job_is_processing_key = f"job_{old_job_key}_is_currently_processing"
|
| 417 |
|
|
|
|
| 418 |
for key in [job_processed_key, job_is_processing_key, 'stop_processing_flag', 'total_input_tokens', 'total_output_tokens']:
|
| 419 |
-
|
| 420 |
-
del st.session_state[key]
|
| 421 |
|
| 422 |
-
# Clear selected candidates for
|
| 423 |
-
if 'Selected_Candidates' in st.session_state
|
| 424 |
-
|
| 425 |
|
| 426 |
-
# Clear
|
| 427 |
st.cache_data.clear()
|
| 428 |
|
| 429 |
# Update last selected job index
|
| 430 |
st.session_state.last_selected_job_index = selected_job_index
|
| 431 |
|
| 432 |
-
#
|
| 433 |
st.rerun()
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
job_row = jobs_df.iloc[selected_job_index]
|
| 436 |
job_row_stack = parse_tech_stack(job_row["Tech Stack"])
|
| 437 |
|
|
@@ -528,13 +534,13 @@ def display_job_selection(jobs_df, candidates_df, sh):
|
|
| 528 |
headers = existing_candidates_from_sheet[0]
|
| 529 |
for row in existing_candidates_from_sheet[1:]:
|
| 530 |
cand = {headers[i]: row[i] if i < len(row) else None for i in range(len(headers))}
|
| 531 |
-
try: cand['Fit Score'] = float(cand.get('Fit Score',0))
|
| 532 |
except: cand['Fit Score'] = 0.0
|
| 533 |
final_candidates.append(cand)
|
| 534 |
-
final_candidates.sort(key=lambda x: x.get('Fit Score',0.0), reverse=True)
|
| 535 |
|
| 536 |
if should_display:
|
| 537 |
-
col_title, col_copyall = st.columns([3,1])
|
| 538 |
with col_title:
|
| 539 |
st.subheader("Selected Candidates")
|
| 540 |
with col_copyall:
|
|
@@ -559,8 +565,8 @@ def display_job_selection(jobs_df, candidates_df, sh):
|
|
| 559 |
display_token_usage()
|
| 560 |
|
| 561 |
for i, candidate in enumerate(final_candidates):
|
| 562 |
-
score = candidate.get('Fit Score',0.0)
|
| 563 |
-
score_display = f"{score:.3f}" if isinstance(score,(int,float)) else score
|
| 564 |
exp_title = f"{i+1}. {candidate.get('Name','N/A')} (Score: {score_display})"
|
| 565 |
with st.expander(exp_title):
|
| 566 |
text_copy = f"Candidate: {candidate.get('Name','N/A')}\nLinkedIn: {candidate.get('LinkedIn','N/A')}\n"
|
|
|
|
| 410 |
# Clear previous job state when a new job is selected
|
| 411 |
if selected_job_index != st.session_state.last_selected_job_index:
|
| 412 |
old_job_key = st.session_state.last_selected_job_index
|
|
|
|
|
|
|
| 413 |
job_processed_key = f"job_{old_job_key}_processed_successfully"
|
| 414 |
job_is_processing_key = f"job_{old_job_key}_is_currently_processing"
|
| 415 |
|
| 416 |
+
# Remove old job flags
|
| 417 |
for key in [job_processed_key, job_is_processing_key, 'stop_processing_flag', 'total_input_tokens', 'total_output_tokens']:
|
| 418 |
+
st.session_state.pop(key, None)
|
|
|
|
| 419 |
|
| 420 |
+
# Clear selected candidates for old job if they exist
|
| 421 |
+
if 'Selected_Candidates' in st.session_state:
|
| 422 |
+
st.session_state.Selected_Candidates.pop(old_job_key, None)
|
| 423 |
|
| 424 |
+
# Clear cache to avoid old data in UI
|
| 425 |
st.cache_data.clear()
|
| 426 |
|
| 427 |
# Update last selected job index
|
| 428 |
st.session_state.last_selected_job_index = selected_job_index
|
| 429 |
|
| 430 |
+
# Rerun to refresh UI and prevent stale data
|
| 431 |
st.rerun()
|
| 432 |
|
| 433 |
+
# Ensure Selected_Candidates is initialized for the new job
|
| 434 |
+
if 'Selected_Candidates' not in st.session_state:
|
| 435 |
+
st.session_state.Selected_Candidates = {}
|
| 436 |
+
|
| 437 |
+
if selected_job_index not in st.session_state.Selected_Candidates:
|
| 438 |
+
st.session_state.Selected_Candidates[selected_job_index] = []
|
| 439 |
+
|
| 440 |
+
# Proceed with job details
|
| 441 |
job_row = jobs_df.iloc[selected_job_index]
|
| 442 |
job_row_stack = parse_tech_stack(job_row["Tech Stack"])
|
| 443 |
|
|
|
|
| 534 |
headers = existing_candidates_from_sheet[0]
|
| 535 |
for row in existing_candidates_from_sheet[1:]:
|
| 536 |
cand = {headers[i]: row[i] if i < len(row) else None for i in range(len(headers))}
|
| 537 |
+
try: cand['Fit Score'] = float(cand.get('Fit Score', 0))
|
| 538 |
except: cand['Fit Score'] = 0.0
|
| 539 |
final_candidates.append(cand)
|
| 540 |
+
final_candidates.sort(key=lambda x: x.get('Fit Score', 0.0), reverse=True)
|
| 541 |
|
| 542 |
if should_display:
|
| 543 |
+
col_title, col_copyall = st.columns([3, 1])
|
| 544 |
with col_title:
|
| 545 |
st.subheader("Selected Candidates")
|
| 546 |
with col_copyall:
|
|
|
|
| 565 |
display_token_usage()
|
| 566 |
|
| 567 |
for i, candidate in enumerate(final_candidates):
|
| 568 |
+
score = candidate.get('Fit Score', 0.0)
|
| 569 |
+
score_display = f"{score:.3f}" if isinstance(score, (int, float)) else score
|
| 570 |
exp_title = f"{i+1}. {candidate.get('Name','N/A')} (Score: {score_display})"
|
| 571 |
with st.expander(exp_title):
|
| 572 |
text_copy = f"Candidate: {candidate.get('Name','N/A')}\nLinkedIn: {candidate.get('LinkedIn','N/A')}\n"
|