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

@@ -1,3 +1,7 @@
## 202307.01
- Moved parser to metadata based recognition of submission type.
## 202306.03 ## 202306.03
- Improve WW plate mapping by using layout in submission forms rather than PCR. - Improve WW plate mapping by using layout in submission forms rather than PCR.

View File

@@ -1,4 +1,5 @@
- [ ] Move submission types from config.yml into database. - [ ] Migrate the parser.sub dictionary to pydantic models.
- [x] Move type_decider to metadata based method rather than excel map.
- [x] Solve bug for plate mapping when two samples of same name are in different rows. - [x] Solve bug for plate mapping when two samples of same name are in different rows.
- Try importing "L:\Robotics Laboratory Support\Submissions\Wastewater\2023\2023-06-21\RSL-WW-20230621-1.xlsx" for example. - Try importing "L:\Robotics Laboratory Support\Submissions\Wastewater\2023\2023-06-21\RSL-WW-20230621-1.xlsx" for example.
- [x] Improve plate mapping by using layout in submission forms rather than PCR. - [x] Improve plate mapping by using layout in submission forms rather than PCR.

Binary file not shown.

View File

@@ -4,7 +4,7 @@ from pathlib import Path
# Version of the realpython-reader package # Version of the realpython-reader package
__project__ = "submissions" __project__ = "submissions"
__version__ = "202306.3b" __version__ = "202307.1b"
__author__ = {"name":"Landon Wark", "email":"Landon.Wark@phac-aspc.gc.ca"} __author__ = {"name":"Landon Wark", "email":"Landon.Wark@phac-aspc.gc.ca"}
__copyright__ = "2022-2023, Government of Canada" __copyright__ = "2022-2023, Government of Canada"
@@ -25,6 +25,7 @@ class bcolors:
# set out the workflow I've imagined for creating new submission types. # 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 # 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. # 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. # 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. # 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. # 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. contains parser object for pulling values from client generated submission sheets.
''' '''
from getpass import getuser from getpass import getuser
import math
import pprint import pprint
from typing import Tuple from typing import Tuple
import pandas as pd import pandas as pd
@@ -44,6 +43,7 @@ class SheetParser(object):
except ValueError as e: except ValueError as e:
logger.error(f"Incorrect value: {e}") logger.error(f"Incorrect value: {e}")
self.xl = None self.xl = None
# TODO: replace OrderedDict with pydantic BaseModel
self.sub = OrderedDict() self.sub = OrderedDict()
# make decision about type of sample we have # make decision about type of sample we have
self.sub['submission_type'] = self.type_decider() self.sub['submission_type'] = self.type_decider()
@@ -58,8 +58,16 @@ class SheetParser(object):
Returns: Returns:
str: submission type name str: submission type name
""" """
# 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: try:
for type in self.ctx['submission_types']: 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']: if self.xl.sheet_names == self.ctx['submission_types'][type]['excel_map']:
return type.title() return type.title()
return "Unknown" return "Unknown"

View File

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

View File

@@ -18,7 +18,7 @@ from backend.db.models import *
import logging import logging
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QMainWindow, QLabel, QWidget, QPushButton, QFileDialog, 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 .all_window_functions import extract_form_info, select_open_file, select_save_file
from PyQt6.QtCore import QSignalBlocker 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, lookup_all_orgs, lookup_kittype_by_use, lookup_kittype_by_name,
construct_submission_info, lookup_reagent, store_submission, lookup_submissions_by_date_range, 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, 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.parser import SheetParser, PCRParser
from backend.excel.reports import make_report_html, make_report_xlsx, convert_data_list_to_df 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 tools import RSLNamer, check_not_nan, check_kit_integrity
from .custom_widgets.pop_ups import AlertPop, QuestionAsker 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 .custom_widgets.misc import ImportReagent
from .visualizations.control_charts import create_charts, construct_html from .visualizations.control_charts import create_charts, construct_html
from .visualizations import make_plate_map
logger = logging.getLogger(f"submissions.{__name__}") logger = logging.getLogger(f"submissions.{__name__}")