Skip to content

Commit

Permalink
Merge pull request #86 from Hazannovich/remove_old_processed_files
Browse files Browse the repository at this point in the history
Remove old processed files
  • Loading branch information
srbhr committed Aug 7, 2023
2 parents b66dbac + a6ba552 commit 4d2598c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
21 changes: 20 additions & 1 deletion run_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,39 @@
from scripts.ResumeProcessor import ResumeProcessor
from scripts.JobDescriptionProcessor import JobDescriptionProcessor
import logging

import os
logging.basicConfig(filename='app.log', filemode='w',
level=logging.DEBUG,
format='%(name)s - %(levelname)s - %(message)s')

PROCESSED_RESUMES_PATH = "Data/Processed/Resumes"
PROCESSED_JOB_DESCRIPTIONS_PATH = "Data/Processed/JobDescription"

def read_json(filename):
with open(filename) as f:
data = json.load(f)
return data

def remove_old_files(files_path):

for filename in os.listdir(files_path):
try:
file_path = os.path.join(files_path, filename)

if os.path.isfile(file_path):
os.remove(file_path)
except Exception as e:
logging.error(f"Error deleting {file_path}:\n{e}")

logging.info("Deleted old files from "+files_path)


logging.info('Started to read from Data/Resumes')
try:
# Check if there are resumes present or not.
# If present then parse it.
remove_old_files(PROCESSED_RESUMES_PATH)

file_names = get_filenames_from_dir("Data/Resumes")
logging.info('Reading from Data/Resumes is now complete.')
except:
Expand All @@ -40,6 +57,8 @@ def read_json(filename):
try:
# Check if there are resumes present or not.
# If present then parse it.
remove_old_files(PROCESSED_JOB_DESCRIPTIONS_PATH)

file_names = get_filenames_from_dir("Data/JobDescription")
logging.info('Reading from Data/JobDescription is now complete.')
except:
Expand Down
19 changes: 14 additions & 5 deletions streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@ def tokenize_string(input_string):

resume_names = get_filenames_from_dir("Data/Processed/Resumes")

st.write("There are", len(resume_names),
output = 0

if len(resume_names) > 1:
st.write("There are", len(resume_names),
" resumes present. Please select one from the menu below:")
output = st.slider('Select Resume Number', 0, len(resume_names)-1, 2)
output = st.slider('Select Resume Number', 0, len(resume_names)-1, 0)
else:
st.write("There is 1 resume present")

avs.add_vertical_space(5)

Expand Down Expand Up @@ -199,10 +204,14 @@ def tokenize_string(input_string):

job_descriptions = get_filenames_from_dir("Data/Processed/JobDescription")

st.write("There are", len(job_descriptions),
output = 0
if len(job_descriptions) > 1:
st.write("There are", len(job_descriptions),
" resumes present. Please select one from the menu below:")
output = st.slider('Select Job Description Number',
0, len(job_descriptions)-1, 2)
output = st.slider('Select Job Description Number',
0, len(job_descriptions)-1, 0)
else:
st.write("There is 1 job description present")

avs.add_vertical_space(5)

Expand Down

0 comments on commit 4d2598c

Please sign in to comment.