Update to add SQL Server support.

This commit is contained in:
lwark
2024-11-01 13:16:16 -05:00
parent ba1b3e5cf3
commit 816a0a45f8
13 changed files with 182 additions and 67 deletions

View File

@@ -52,7 +52,7 @@ class RSLNamer(object):
str: parsed submission type
"""
def st_from_path(filename:Path) -> str:
logger.info(f"Using path method for {filename}.")
# logger.info(f"Using path method for {filename}.")
if filename.exists():
wb = load_workbook(filename)
try:
@@ -60,7 +60,7 @@ class RSLNamer(object):
categories = wb.properties.category.split(";")
submission_type = next(item.strip().title() for item in categories)
except (StopIteration, AttributeError):
sts = {item.name: item.get_template_file_sheets() for item in SubmissionType.query()}
sts = {item.name: item.get_template_file_sheets() for item in SubmissionType.query() if item.template_file}
try:
submission_type = next(k.title() for k,v in sts.items() if wb.sheetnames==v)
except StopIteration:
@@ -70,8 +70,10 @@ class RSLNamer(object):
submission_type = cls.retrieve_submission_type(filename=filename.stem.__str__())
return submission_type
def st_from_str(filename:str) -> str:
if filename.startswith("tmp"):
return "Bacterial Culture"
regex = BasicSubmission.construct_regex()
logger.info(f"Using string method for {filename}.")
# logger.info(f"Using string method for {filename}.")
# logger.debug(f"Using regex: {regex}")
m = regex.search(filename)
try:
@@ -95,7 +97,7 @@ class RSLNamer(object):
check = True
if check:
if "pytest" in sys.modules:
return "Bacterial Culture"
raise ValueError("Submission Type came back as None.")
# logger.debug("Final option, ask the user for submission type")
from frontend.widgets import ObjectSelector
dlg = ObjectSelector(title="Couldn't parse submission type.",

View File

@@ -349,7 +349,7 @@ class PydEquipment(BaseModel, extra='ignore'):
"""
if isinstance(submission, str):
# logger.debug(f"Got string, querying {submission}")
submission = BasicSubmission.query(rsl_number=submission)
submission = BasicSubmission.query(rsl_plate_num=submission)
equipment = Equipment.query(asset_number=self.asset_number)
if equipment is None:
logger.error("No equipment found. Returning None.")
@@ -361,7 +361,8 @@ class PydEquipment(BaseModel, extra='ignore'):
role=self.role, limit=1)
except TypeError as e:
logger.error(f"Couldn't get association due to {e}, returning...")
return equipment, None
# return equipment, None
assoc = None
if assoc is None:
assoc = SubmissionEquipmentAssociation(submission=submission, equipment=equipment)
process = Process.query(name=self.processes[0])
@@ -829,6 +830,7 @@ class PydSubmission(BaseModel, extra='allow'):
equip, association = equip.toSQL(submission=instance)
if association is not None:
instance.submission_equipment_associations.append(association)
logger.debug(f"Equipment associations:\n\n{pformat(instance.submission_equipment_associations)}")
case "tips":
for tips in self.tips:
if tips is None: