Skip to content

Commit

Permalink
Merge pull request #40 from glrs/feature/core
Browse files Browse the repository at this point in the history
Add `user_info` and `is_sensitive` attributes to AbstractProject | Us…
  • Loading branch information
glrs authored Jan 24, 2025
2 parents 9042d60 + 511c827 commit cb69e2b
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion lib/base/abstract_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,43 @@ def __init__(self, doc: Any, yggdrasil_db_manager: Any) -> None:
self.method: str = self.doc.get("details", {}).get(
"library_construction_method", ""
)
self.user_info: dict = {
"owner": {
"email": self.doc.get("order_details", {})
.get("owner", {})
.get("email", ""),
"name": self.doc.get("order_details", {})
.get("owner", {})
.get("name", ""),
},
"bioinformatician": {
"email": self.doc.get("order_details", {})
.get("fields", {})
.get("project_bx_email", ""),
"name": self.doc.get("order_details", {})
.get("fields", {})
.get("project_bx_name", ""),
},
"pi": {
"email": self.doc.get("order_details", {})
.get("fields", {})
.get("project_pi_email", ""),
"name": self.doc.get("order_details", {})
.get("fields", {})
.get("project_pi_name", ""),
},
"lab": {
"name": self.doc.get("order_details", {})
.get("fields", {})
.get("project_lab_email", ""),
"email": self.doc.get("order_details", {})
.get("fields", {})
.get("project_lab_name", ""),
},
}
sensitive_str = self.doc.get("details", {}).get("sensitive_data", "").lower()
self.is_sensitive = sensitive_str == "yes"

self.status: str = "ongoing"
self.project_info: dict = {}
self.samples: list = []
Expand All @@ -59,7 +96,13 @@ def initialize_project_in_db(self):
existing_document = self.ydm.check_project_exists(self.project_id)
if existing_document is None:
# Create the project in YggdrasilDB
self.ydm.create_project(self.project_id, self.doc_id, self.method)
self.ydm.create_project(
self.project_id,
self.doc_id,
self.method,
self.user_info,
self.is_sensitive,
)
logging.info(f"Project {self.project_id} created in YggdrasilDB.")
else:
logging.info(f"Project {self.project_id} already exists in YggdrasilDB.")
Expand All @@ -74,6 +117,12 @@ def initialize_project_in_db(self):
f"Project with ID {self.project_id} has status '{self.status}' and will be processed."
)
self.proceed = True
# Update/sync the project in YggdrasilDB
self.ydm.sync_project_metadata(
project_id=self.project_id,
user_info=self.user_info,
is_sensitive=self.is_sensitive,
)

def add_samples_to_project_in_db(self):
"""Add samples to the project in the Yggdrasil database."""
Expand Down

0 comments on commit cb69e2b

Please sign in to comment.