Skip to content

Commit

Permalink
Remove debug prints and use 'model_dump' in notifications
Browse files Browse the repository at this point in the history
Removed unnecessary debug print statements across multiple files to clean up the code. Updated the function calls to use 'model_dump' for consistency and clarity in handling notifications.
  • Loading branch information
Zerskk committed Nov 20, 2024
1 parent 00a269a commit 107d53c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/api/middlewares/github_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ async def github_authentication(request: Request, x_hub_signature_256: str = Hea
payload = await request.body()
secret = os.environ.get("GITHUB_SECRET").encode("utf-8")
signature = generate_hash_signature(secret, payload)
print("in auth")
if x_hub_signature_256 != f"sha256={signature}":
raise HTTPException(status.HTTP_401_UNAUTHORIZED,
detail="Not Authorized")
Expand Down
20 changes: 12 additions & 8 deletions app/tasks/database_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ def add_ontologies(self, data):

notifications = notifications.dict()

print("notis", notifications)

return notifications


Expand All @@ -155,8 +153,10 @@ def update_ontologies(self, task_results):

messages = task_results.get("notifications")


notifications = Notifications(**messages)


# backend = S3Backend(app=app)
backend = StorageBackend()

Expand All @@ -167,9 +167,10 @@ def update_ontologies(self, task_results):
if data is None:
print("could not connect to storage backend")
notifications.messages.append(Message(type="fail", message="Could not connect to storage backend"))
notifications = notifications.dict()
notifications = notifications.model_dump()
return notifications


data = json.loads(data)

terms = data.get("terms")
Expand All @@ -180,14 +181,15 @@ def update_ontologies(self, task_results):
for term in terms:
term_accessions.append(term.get("accession"))



conn = Neo4jConnection()

status = conn.check()

if status is False:
print("database not connected")
notifications.messages.append(Message(type="fail", message="Could not connect to database"))
notifications = notifications.dict()
notifications = notifications.model_dump()
return notifications


Expand All @@ -196,7 +198,9 @@ def update_ontologies(self, task_results):
except:
notifications.messages.append(
Message(type="fail", message="No valid ontology found, skipping..."))
return notifications

return notifications.model_dump()


# get list of to deleted terms
db_term_list = conn.list_terms_of_ontology(ontology_name)
Expand All @@ -213,7 +217,6 @@ def update_ontologies(self, task_results):

conn.delete_terms(terms_remove_df)

print("after deletion")

terms_df = pd.DataFrame(data.get("terms"), index=None)

Expand Down Expand Up @@ -257,7 +260,8 @@ def update_ontologies(self, task_results):
notifications.messages.append(Message(type="success", message="File contained " +str(len( relations_df)) +" relations"))


notifications = notifications.dict()
notifications = notifications.model_dump()


return notifications

Expand Down
5 changes: 4 additions & 1 deletion app/tasks/mail_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ def send_webhook_mail(messages):

print("messages", messages)


print("notifications", messages)
print("type", type(messages))

notifications = Notifications(**messages)

print("notifications", notifications)

print("after import")

print("is_hook?", notifications.is_webhook)
Expand Down
2 changes: 1 addition & 1 deletion app/tasks/ontology_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def add_ontology_task(self, url, **notis):
print("failed")
# data = None
ontology_buffer = None
# notifications.messages.append(Message(type="fail", message="Error in Pronto conversion"))
notifications.messages.append(Message(type="fail", message="Error in converting OWL file to OBO file"))

print(f"notificatoins {notifications}")
else:
Expand Down

0 comments on commit 107d53c

Please sign in to comment.