Commit before bringing in pydantic

This commit is contained in:
Landon Wark
2023-07-05 13:15:42 -05:00
parent ed92fe1157
commit 0c81c74f70
7 changed files with 28 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ from pathlib import Path
# Version of the realpython-reader package
__project__ = "submissions"
__version__ = "202306.3b"
__version__ = "202307.1b"
__author__ = {"name":"Landon Wark", "email":"Landon.Wark@phac-aspc.gc.ca"}
__copyright__ = "2022-2023, Government of Canada"
@@ -25,6 +25,7 @@ class bcolors:
# set out the workflow I've imagined for creating new submission types.
# First of all, you will need to write new parsing methods in backend.excel.parser to pull information out of the submission form
# for the submission itself as well as for any samples you can pull out of that same workbook.
# The workbooks no longer need a sheet map, but they do need their submission type put in the categories metadata of the client excel template.
# Second, you will have to update the model in backend.db.models.submissions and provide a new polymorph to the BasicSubmission object.
# The BSO should hold the majority of the general info.
# You can also update any of the parsers to pull out any custom info you need, like enforcing RSL plate numbers, scraping PCR results, etc.

View File

@@ -2,7 +2,6 @@
contains parser object for pulling values from client generated submission sheets.
'''
from getpass import getuser
import math
import pprint
from typing import Tuple
import pandas as pd
@@ -44,6 +43,7 @@ class SheetParser(object):
except ValueError as e:
logger.error(f"Incorrect value: {e}")
self.xl = None
# TODO: replace OrderedDict with pydantic BaseModel
self.sub = OrderedDict()
# make decision about type of sample we have
self.sub['submission_type'] = self.type_decider()
@@ -58,14 +58,22 @@ class SheetParser(object):
Returns:
str: submission type name
"""
try:
for type in self.ctx['submission_types']:
if self.xl.sheet_names == self.ctx['submission_types'][type]['excel_map']:
return type.title()
return "Unknown"
except Exception as e:
logger.warning(f"We were unable to parse the submission type due to: {e}")
return "Unknown"
# Check metadata for category, return first category
if self.xl.book.properties.category != None:
categories = [item.strip().title() for item in self.xl.book.properties.category.split(";")]
return categories[0].replace(" ", "_")
else:
# This code is going to be depreciated once there is full adoption of the client sheets
# with updated metadata
try:
for type in self.ctx['submission_types']:
# This gets the *first* submission type that matches the sheet names in the workbook
if self.xl.sheet_names == self.ctx['submission_types'][type]['excel_map']:
return type.title()
return "Unknown"
except Exception as e:
logger.warning(f"We were unable to parse the submission type due to: {e}")
return "Unknown"
def parse_unknown(self) -> None:

View File

@@ -9,7 +9,6 @@ import sys
from pathlib import Path
import re
from tools import check_if_app
import asyncio
logger = logging.getLogger(f"submissions.{__name__}")

View File

@@ -18,7 +18,7 @@ from backend.db.models import *
import logging
from PyQt6.QtWidgets import (
QMainWindow, QLabel, QWidget, QPushButton, QFileDialog,
QLineEdit, QMessageBox, QComboBox, QDateEdit
QLineEdit, QComboBox, QDateEdit
)
from .all_window_functions import extract_form_info, select_open_file, select_save_file
from PyQt6.QtCore import QSignalBlocker
@@ -26,16 +26,15 @@ from backend.db.functions import (
lookup_all_orgs, lookup_kittype_by_use, lookup_kittype_by_name,
construct_submission_info, lookup_reagent, store_submission, lookup_submissions_by_date_range,
create_kit_from_yaml, create_org_from_yaml, get_control_subtypes, get_all_controls_by_type,
lookup_all_submissions_by_type, get_all_controls, lookup_submission_by_rsl_num, update_ww_sample, hitpick_plate
lookup_all_submissions_by_type, get_all_controls, lookup_submission_by_rsl_num, update_ww_sample
)
from backend.excel.parser import SheetParser, PCRParser
from backend.excel.reports import make_report_html, make_report_xlsx, convert_data_list_to_df
from tools import RSLNamer, check_not_nan, check_kit_integrity
from .custom_widgets.pop_ups import AlertPop, QuestionAsker
from .custom_widgets import ReportDatePicker, ReagentTypeForm
from .custom_widgets import ReportDatePicker
from .custom_widgets.misc import ImportReagent
from .visualizations.control_charts import create_charts, construct_html
from .visualizations import make_plate_map
logger = logging.getLogger(f"submissions.{__name__}")