Better flexibility with parsers pulling methods from database objects.

This commit is contained in:
Landon Wark
2023-10-17 15:16:34 -05:00
parent 0a90542e8e
commit 39b94405e5
14 changed files with 296 additions and 610 deletions

View File

@@ -17,11 +17,11 @@ from backend.db.functions import construct_kit_from_yaml, \
lookup_reagent_types, lookup_reagents, lookup_submission_type, lookup_reagenttype_kittype_association, \
lookup_submissions
from backend.db.models import SubmissionTypeKitTypeAssociation
from sqlalchemy import FLOAT, INTEGER, String
from sqlalchemy import FLOAT, INTEGER
import logging
import numpy as np
from .pop_ups import AlertPop
from backend.pydant import PydReagent
from backend.validators import PydSheetReagent
from typing import Tuple
logger = logging.getLogger(f"submissions.{__name__}")
@@ -386,11 +386,11 @@ class ControlsDatePicker(QWidget):
class ImportReagent(QComboBox):
def __init__(self, ctx:Settings, reagent:dict|PydReagent, extraction_kit:str):
def __init__(self, ctx:Settings, reagent:dict|PydSheetReagent, extraction_kit:str):
super().__init__()
self.setEditable(True)
if isinstance(reagent, dict):
reagent = PydReagent(**reagent)
reagent = PydSheetReagent(**reagent)
# Ensure that all reagenttypes have a name that matches the items in the excel parser
query_var = reagent.type
logger.debug(f"Import Reagent is looking at: {reagent.lot} for {query_var}")

View File

@@ -96,5 +96,5 @@ class SubmissionTypeSelector(QDialog):
self.layout.addWidget(self.buttonBox)
self.setLayout(self.layout)
def getValues(self):
def parse_form(self):
return self.widget.currentText()

View File

@@ -27,7 +27,6 @@ from backend.db.functions import (
construct_submission_info, lookup_reagents, construct_kit_from_yaml, construct_org_from_yaml, get_control_subtypes,
update_subsampassoc_with_pcr, check_kit_integrity, update_last_used, lookup_organizations, lookup_kit_types,
lookup_submissions, lookup_controls, lookup_samples, lookup_submission_sample_association, store_object, lookup_submission_type,
get_polymorphic_subclass
)
from backend.excel.parser import SheetParser, PCRParser, SampleParser
from backend.excel.reports import make_report_html, make_report_xlsx, convert_data_list_to_df
@@ -56,9 +55,7 @@ def import_submission_function(obj:QMainWindow, fname:Path|None=None) -> Tuple[Q
logger.debug(obj.ctx)
# initialize samples
obj.samples = []
obj.missing_info = []
# set file dialog
if isinstance(fname, bool) or fname == None:
fname = select_open_file(obj, file_extension="xlsx")