Skip to content

Commit

Permalink
Stop document map update temporarily (#350)
Browse files Browse the repository at this point in the history
* commented doc map update and reduced timeout

* added break upon append map failure

* changed script run time to 6 am utc
  • Loading branch information
star-nox authored Dec 20, 2024
1 parent 1da8e59 commit be5a007
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
26 changes: 13 additions & 13 deletions ai_ta_backend/beam/cron_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from beam import schedule


@schedule(when="@daily", name="update-nomic-maps")
@schedule(when="0 6 * * *", name="update-nomic-maps")
def task():
print("Hi, from your task running at midnight daily!")
print("Hi, from your task running at 6 AM UTC (12 AM CST) daily!")
base_url = "https://flask-production-751b.up.railway.app"

# Update conversation maps
Expand All @@ -26,16 +26,16 @@ def task():
except Exception as e:
print(f"Error updating conversation maps: {str(e)}")

# Update document maps
url = f"{base_url}/updateDocumentMaps"
try:
response = requests.get(url, timeout=30)
if response.status_code == 200:
print("Document maps updated successfully")
else:
print(f"Failed to update document maps - Status code: {response.status_code}")
print(f"Response text: {response.text}")
except Exception as e:
print(f"Error updating document maps: {str(e)}")
# # Update document maps
# url = f"{base_url}/updateDocumentMaps"
# try:
# response = requests.get(url, timeout=30)
# if response.status_code == 200:
# print("Document maps updated successfully")
# else:
# print(f"Failed to update document maps - Status code: {response.status_code}")
# print(f"Response text: {response.text}")
# except Exception as e:
# print(f"Error updating document maps: {str(e)}")

return "Task completed successfully"
3 changes: 2 additions & 1 deletion ai_ta_backend/service/nomic_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def update_conversation_maps(self):

else:
print(f"Error in updating conversation map: {result}")
break

combined_dfs = []
self.rebuild_map(course_name, "conversation")
Expand Down Expand Up @@ -530,7 +531,7 @@ def append_to_map(self, metadata, map_name):
# print("Project is currently indexing. Try again later.")
# return "Project busy"
start_time = time.monotonic()
while time.monotonic() - start_time < 180:
while time.monotonic() - start_time < 30:
if project.is_accepting_data:
project.add_data(data=metadata)
print(f"Data appended to map: {map_name}")
Expand Down

0 comments on commit be5a007

Please sign in to comment.