Minor bug fixes.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
'''
|
||||
Constructs main application.
|
||||
TODO: Complete.
|
||||
'''
|
||||
import sys
|
||||
from PyQt6.QtWidgets import (
|
||||
QTabWidget, QWidget, QVBoxLayout,
|
||||
QHBoxLayout, QScrollArea, QMainWindow,
|
||||
@@ -14,14 +12,12 @@ from backend.validators import PydReagent
|
||||
from tools import check_if_app, Settings, Report
|
||||
from .pop_ups import AlertPop
|
||||
from .misc import AddReagentForm, LogParser
|
||||
import logging
|
||||
import logging, webbrowser, sys
|
||||
from datetime import date
|
||||
import webbrowser
|
||||
from .submission_table import SubmissionsSheet
|
||||
from .submission_widget import SubmissionFormContainer
|
||||
from .controls_chart import ControlsViewer
|
||||
from .kit_creator import KitAdder
|
||||
import webbrowser
|
||||
|
||||
logger = logging.getLogger(f'submissions.{__name__}')
|
||||
logger.info("Hello, I am a logger")
|
||||
|
||||
@@ -3,8 +3,8 @@ from PyQt6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QComboBox, QHBoxLayout,
|
||||
QDateEdit, QLabel, QSizePolicy
|
||||
)
|
||||
from PyQt6.QtCore import QSignalBlocker, QLoggingCategory
|
||||
from backend.db import ControlType, Control, get_control_subtypes
|
||||
from PyQt6.QtCore import QSignalBlocker
|
||||
from backend.db import ControlType, Control#, get_control_subtypes
|
||||
from PyQt6.QtCore import QDate, QSize
|
||||
import logging, sys
|
||||
from tools import Report, Result
|
||||
@@ -88,7 +88,8 @@ class ControlsViewer(QWidget):
|
||||
self.mode = self.mode_typer.currentText()
|
||||
self.sub_typer.clear()
|
||||
# lookup subtypes
|
||||
sub_types = get_control_subtypes(type=self.con_type, mode=self.mode)
|
||||
# sub_types = get_control_subtypes(type=self.con_type, mode=self.mode)
|
||||
sub_types = ControlType.query(name=self.con_type).get_subtypes(mode=self.mode)
|
||||
# sub_types = lookup_controls(ctx=obj.ctx, control_type=obj.con_type)
|
||||
if sub_types != []:
|
||||
# block signal that will rerun controls getter and update sub_typer
|
||||
|
||||
@@ -15,7 +15,6 @@ from PyQt6.QtWidgets import (
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtCore import Qt, QAbstractTableModel, QSortFilterProxyModel
|
||||
from PyQt6.QtGui import QAction, QCursor, QPixmap, QPainter
|
||||
from backend.db.functions import submissions_to_df
|
||||
from backend.db.models import BasicSubmission
|
||||
from backend.excel import make_report_html, make_report_xlsx
|
||||
from tools import check_if_app, Report, Result, jinja_template_loading, get_first_blank_df_row, row_map
|
||||
@@ -102,7 +101,8 @@ class SubmissionsSheet(QTableView):
|
||||
"""
|
||||
sets data in model
|
||||
"""
|
||||
self.data = submissions_to_df()
|
||||
# self.data = submissions_to_df()
|
||||
self.data = BasicSubmission.submissions_to_df()
|
||||
try:
|
||||
self.data['id'] = self.data['id'].apply(str)
|
||||
self.data['id'] = self.data['id'].str.zfill(3)
|
||||
|
||||
@@ -5,23 +5,20 @@ from PyQt6.QtWidgets import (
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
from pathlib import Path
|
||||
from . import select_open_file, select_save_file
|
||||
import logging
|
||||
import logging, difflib, inspect, json, sys
|
||||
from pathlib import Path
|
||||
from tools import Report, Result, check_not_nan
|
||||
from backend.excel.parser import SheetParser, PCRParser
|
||||
from backend.validators import PydSubmission, PydReagent
|
||||
from backend.db import (
|
||||
check_kit_integrity, KitType, Organization, SubmissionType, Reagent,
|
||||
KitType, Organization, SubmissionType, Reagent,
|
||||
ReagentType, KitTypeReagentTypeAssociation, BasicSubmission
|
||||
)
|
||||
from pprint import pformat
|
||||
from .pop_ups import QuestionAsker, AlertPop
|
||||
# from .misc import ReagentFormWidget
|
||||
from typing import List, Tuple
|
||||
import difflib
|
||||
from datetime import date
|
||||
import inspect
|
||||
import json
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
@@ -143,14 +140,14 @@ class SubmissionFormContainer(QWidget):
|
||||
return
|
||||
except AttributeError:
|
||||
self.prsr = SheetParser(ctx=self.app.ctx, filepath=fname)
|
||||
try:
|
||||
logger.debug(f"Submission dictionary:\n{pformat(self.prsr.sub)}")
|
||||
self.pyd = self.prsr.to_pydantic()
|
||||
logger.debug(f"Pydantic result: \n\n{pformat(self.pyd)}\n\n")
|
||||
except Exception as e:
|
||||
report.add_result(Result(msg=f"Problem creating pydantic model:\n\n{e}", status="Critical"))
|
||||
self.report.add_result(report)
|
||||
return
|
||||
# try:
|
||||
logger.debug(f"Submission dictionary:\n{pformat(self.prsr.sub)}")
|
||||
self.pyd = self.prsr.to_pydantic()
|
||||
logger.debug(f"Pydantic result: \n\n{pformat(self.pyd)}\n\n")
|
||||
# except Exception as e:
|
||||
# report.add_result(Result(msg=f"Problem creating pydantic model:\n\n{e}", status="Critical"))
|
||||
# self.report.add_result(report)
|
||||
# return
|
||||
self.form = self.pyd.toForm(parent=self)
|
||||
self.layout().addWidget(self.form)
|
||||
kit_widget = self.form.find_widgets(object_name="extraction_kit")[0].input
|
||||
@@ -265,7 +262,8 @@ class SubmissionFormContainer(QWidget):
|
||||
self.pyd: PydSubmission = self.form.parse_form()
|
||||
logger.debug(f"Submission: {pformat(self.pyd)}")
|
||||
logger.debug("Checking kit integrity...")
|
||||
result = check_kit_integrity(sub=self.pyd)
|
||||
# result = check_kit_integrity(sub=self.pyd)
|
||||
result = self.pyd.check_kit_integrity()
|
||||
report.add_result(result)
|
||||
if len(result.results) > 0:
|
||||
self.report.add_result(report)
|
||||
@@ -417,7 +415,8 @@ class SubmissionFormWidget(QWidget):
|
||||
# self.ignore = [None, "", "qt_spinbox_lineedit", "qt_scrollarea_viewport", "qt_scrollarea_hcontainer",
|
||||
# "qt_scrollarea_vcontainer", "submit_btn"
|
||||
# ]
|
||||
self.ignore = ['filepath', 'samples', 'reagents', 'csv', 'ctx']
|
||||
self.ignore = ['filepath', 'samples', 'reagents', 'csv', 'ctx', 'comment']
|
||||
self.recover = ['filepath', 'samples', 'csv', 'comment']
|
||||
layout = QVBoxLayout()
|
||||
for k, v in kwargs.items():
|
||||
if k not in self.ignore:
|
||||
@@ -448,8 +447,6 @@ class SubmissionFormWidget(QWidget):
|
||||
logger.debug(f"Hello from form parser!")
|
||||
info = {}
|
||||
reagents = []
|
||||
if hasattr(self, 'csv'):
|
||||
info['csv'] = self.csv
|
||||
for widget in self.findChildren(QWidget):
|
||||
# logger.debug(f"Parsed widget of type {type(widget)}")
|
||||
match widget:
|
||||
@@ -463,9 +460,13 @@ class SubmissionFormWidget(QWidget):
|
||||
info[field] = value
|
||||
logger.debug(f"Info: {pformat(info)}")
|
||||
logger.debug(f"Reagents: {pformat(reagents)}")
|
||||
# sys.exit()
|
||||
# logger.debug(f"Attrs not in info: {[k for k, v in self.__dict__.items() if k not in info.keys()]}")
|
||||
for item in self.recover:
|
||||
if hasattr(self, item):
|
||||
info[item] = getattr(self, item)
|
||||
# app = self.parent().parent().parent().parent().parent().parent().parent().parent
|
||||
submission = PydSubmission(filepath=self.filepath, reagents=reagents, samples=self.samples, **info)
|
||||
# submission = PydSubmission(filepath=self.filepath, reagents=reagents, samples=self.samples, **info)
|
||||
submission = PydSubmission(reagents=reagents, **info)
|
||||
return submission
|
||||
|
||||
class InfoItem(QWidget):
|
||||
|
||||
Reference in New Issue
Block a user