boryasbora commited on
Commit
2b0e975
·
verified ·
1 Parent(s): 2e7d9a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -58
app.py CHANGED
@@ -29,65 +29,7 @@ directory_path = "ohw_proj_chorma_db"
29
  file_path = "ohw_proj_chorma_db.pcl"
30
  # Function to update your retriever
31
  # Function to update your retriever
32
- def update_retriever():
33
- # Define the directory and file paths
34
- directory_path = "ohw_proj_chorma_db"
35
- file_path = "ohw_proj_chorma_db.pcl"
36
 
37
- # Remove the directory and its contents if it exists
38
- if os.path.exists(directory_path):
39
- shutil.rmtree(directory_path)
40
- st.write(f"Directory '{directory_path}' and its contents were removed successfully.")
41
-
42
- # Remove the file if it exists
43
- if os.path.exists(file_path):
44
- os.remove(file_path)
45
- st.write(f"File '{file_path}' was removed successfully.")
46
-
47
- # Run the first Python script
48
- try:
49
- subprocess.run(["python", "scrape_github.py"], check=True)
50
- st.write("GitHub repos downloaded")
51
- except subprocess.CalledProcessError as e:
52
- st.error(f"Error running scrape_github.py: {e}")
53
-
54
- # Run the second Python script
55
- try:
56
- subprocess.run(["python", "create_retriever.py"], check=True)
57
- st.write("Retriever updated")
58
- except subprocess.CalledProcessError as e:
59
- st.error(f"Error running create_retriever.py: {e}")
60
-
61
- # Additional logic to update your retriever after running the scripts
62
- st.write("Retriever updated!")
63
-
64
- # Function to run the scheduler
65
- def run_scheduler():
66
- while True:
67
- schedule.run_pending()
68
- time.sleep(1) # Check every second
69
-
70
- # Schedule the retriever update every 24 hours
71
- schedule.every(24).hours.do(update_retriever)
72
-
73
- # Run the scheduler in a separate thread to not block the main thread
74
- scheduler_thread = threading.Thread(target=run_scheduler)
75
- scheduler_thread.start()
76
- if os.path.exists(directory_path):
77
- st.write('retriever loaded')
78
- else:
79
- # try:
80
- subprocess.run(["python", "scrape_github.py"], check=True)
81
- st.write("GitHub repos downloaded")
82
- # except subprocess.CalledProcessError as e:
83
- # st.error(f"Error running scrape_github.py: {e}")
84
-
85
- # Run the second Python script
86
- # try:
87
- subprocess.run(["python", "create_retriever.py"], check=True)
88
- st.write("Retriever updated")
89
- # except subprocess.CalledProcessError as e:
90
- # st.error(f"Error running create_retriever.py: {e}")
91
  def load_from_pickle(filename):
92
  with open(filename, "rb") as file:
93
  return pickle.load(file)
 
29
  file_path = "ohw_proj_chorma_db.pcl"
30
  # Function to update your retriever
31
  # Function to update your retriever
 
 
 
 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  def load_from_pickle(filename):
34
  with open(filename, "rb") as file:
35
  return pickle.load(file)