Skip to content

Commit

Permalink
fix(LIMS) Remove hard-coded user (#3005)(patch)
Browse files Browse the repository at this point in the history
### Changed
- Researcher ID changed from 3, to whatever is provided in the .env file
  • Loading branch information
Vince-janv authored Feb 29, 2024
1 parent 1139653 commit 04350d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 5 additions & 1 deletion cg/apps/lims/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from dateutil.parser import parse as parse_date
from genologics.entities import Artifact, Process, Sample
from genologics.entities import Artifact, Process, Researcher, Sample
from genologics.lims import Lims
from requests.exceptions import HTTPError

Expand Down Expand Up @@ -49,6 +49,10 @@ def __init__(self, config):
lconf = config["lims"]
super(LimsAPI, self).__init__(lconf["host"], lconf["username"], lconf["password"])

@property
def user(self) -> Researcher:
return self.get_researchers(username=self.username)[0]

def sample(self, lims_id: str):
"""Fetch a sample from the LIMS database."""
lims_sample = Sample(self, id=lims_id)
Expand Down
8 changes: 3 additions & 5 deletions cg/apps/lims/order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from genologics.entities import Container, Containertype, Project, Researcher, Sample
from genologics.entities import Container, Containertype, Project, Sample
from lxml import etree
from lxml.objectify import ObjectifiedElement

Expand Down Expand Up @@ -48,13 +48,11 @@ def update_artifacts(self, artifact_details: ObjectifiedElement):
results = self.save_xml(artifact_uri, artifact_details)
return results

def submit_project(self, project_name: str, samples: list[dict], researcher_id: str = "3"):
def submit_project(self, project_name: str, samples: list[dict]):
"""Parse Scout project."""
containers = self.prepare(samples)

lims_project = Project.create(
self, researcher=Researcher(self, id=researcher_id), name=project_name
)
lims_project = Project.create(self, researcher=self.user, name=project_name)
LOG.info(f"{lims_project.id}: created new LIMS project")

containers_data = [
Expand Down

0 comments on commit 04350d0

Please sign in to comment.