Post code-cleanup, moments before disaster.
This commit is contained in:
@@ -19,10 +19,6 @@ class IridaFigure(CustomFigure):
|
||||
|
||||
super().__init__(df=df, modes=modes, settings=settings)
|
||||
self.df = df
|
||||
# try:
|
||||
# months = int(settings['months'])
|
||||
# except KeyError:
|
||||
# months = 6
|
||||
self.construct_chart(df=df, modes=modes, start_date=settings['start_date'], end_date=settings['end_date'])
|
||||
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@ Functions for constructing irida controls graphs using plotly.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from . import CustomFigure
|
||||
import plotly.express as px
|
||||
import pandas as pd
|
||||
from PyQt6.QtWidgets import QWidget
|
||||
import logging
|
||||
import logging, plotly.express as px, pandas as pd
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
@@ -17,10 +15,6 @@ class PCRFigure(CustomFigure):
|
||||
months: int = 6):
|
||||
super().__init__(df=df, modes=modes, settings=settings)
|
||||
self.df = df
|
||||
# try:
|
||||
# months = int(settings['months'])
|
||||
# except KeyError:
|
||||
# months = 6
|
||||
self.construct_chart(df=df)
|
||||
|
||||
def construct_chart(self, df: pd.DataFrame):
|
||||
|
||||
@@ -3,10 +3,8 @@ Construct turnaround time charts
|
||||
"""
|
||||
from pprint import pformat
|
||||
from . import CustomFigure
|
||||
import plotly.express as px
|
||||
import pandas as pd
|
||||
from PyQt6.QtWidgets import QWidget
|
||||
import logging
|
||||
import logging, plotly.express as px, pandas as pd
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
|
||||
@@ -230,7 +230,9 @@ class App(QMainWindow):
|
||||
def update_data(self):
|
||||
self.table_widget.sub_wid.setData(page=self.table_widget.pager.page_anchor, page_size=page_size)
|
||||
|
||||
# TODO: Change this to the Pydantic version.
|
||||
def manage_orgs(self):
|
||||
from frontend.widgets.omni_manager_pydant import ManagerWindow as ManagerWindowPyd
|
||||
dlg = ManagerWindow(parent=self, object_type=Organization, extras=[], add_edit='edit', managers=set())
|
||||
if dlg.exec():
|
||||
new_org = dlg.parse_form()
|
||||
@@ -245,13 +247,9 @@ class App(QMainWindow):
|
||||
logger.debug("\n\nBeginning parsing\n\n")
|
||||
output = dlg.parse_form()
|
||||
logger.debug(f"Kit output: {pformat(output.__dict__)}")
|
||||
# with open(f"{output.name}.obj", "wb") as f:
|
||||
# pickle.dump(output, f)
|
||||
logger.debug("\n\nBeginning transformation\n\n")
|
||||
sql = output.to_sql()
|
||||
assert isinstance(sql, KitType)
|
||||
# with open(f"{output.name}.sql", "wb") as f:
|
||||
# pickle.dump(sql, f)
|
||||
sql.save()
|
||||
|
||||
|
||||
|
||||
@@ -113,10 +113,6 @@ class ControlsViewer(InfoPane):
|
||||
if issubclass(self.fig.__class__, CustomFigure):
|
||||
self.save_button.setEnabled(True)
|
||||
# NOTE: construct html for webview
|
||||
# try:
|
||||
# html = self.fig.html
|
||||
# except AttributeError:
|
||||
# html = ""
|
||||
self.webview.setHtml(self.fig.html)
|
||||
self.webview.update()
|
||||
return report
|
||||
|
||||
@@ -28,12 +28,12 @@ class AddEdit(QDialog):
|
||||
self.object_type = instance.__class__
|
||||
# self.managers = deepcopy(managers)
|
||||
self.managers = managers
|
||||
if instance.level < 2:
|
||||
try:
|
||||
logger.debug(f"Parent instance: {self.parent().instance}")
|
||||
self.managers.add(self.parent().instance)
|
||||
except AttributeError:
|
||||
pass
|
||||
# if instance.level < 2:
|
||||
# try:
|
||||
# logger.debug(f"Parent instance: {self.parent().instance}")
|
||||
# self.managers.add(self.parent().instance)
|
||||
# except AttributeError:
|
||||
# pass
|
||||
logger.debug(f"Managers: {managers}")
|
||||
self.layout = QGridLayout(self)
|
||||
QBtn = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
@@ -111,14 +111,13 @@ class EditProperty(QWidget):
|
||||
case _:
|
||||
logger.error(f"{column_type} not a supported type.")
|
||||
return
|
||||
# if not self.is_list:
|
||||
self.layout.addWidget(self.label, 0, 0, 1, 1)
|
||||
self.layout.addWidget(self.widget, 0, 1, 1, 3)
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def relationship_property_set(self, relationship, value=None):
|
||||
self.widget = QComboBox()
|
||||
logger.debug(self.parent().managers)
|
||||
# logger.debug(self.parent().managers)
|
||||
for manager in self.parent().managers:
|
||||
if self.name in manager.aliases:
|
||||
logger.debug(f"Name: {self.name} is in aliases: {manager.aliases}")
|
||||
|
||||
@@ -47,7 +47,6 @@ class ManagerWindow(QDialog):
|
||||
self.manager = None
|
||||
else:
|
||||
self.manager = manager
|
||||
|
||||
# logger.debug(f"Managers: {managers}")
|
||||
self.extras = extras
|
||||
self.context = kwargs
|
||||
@@ -104,7 +103,6 @@ class ManagerWindow(QDialog):
|
||||
self.options.setEditable(False)
|
||||
self.options.setMinimumWidth(self.minimumWidth())
|
||||
self.layout.addWidget(self.options, 1, 0, 1, 1)
|
||||
# if len(options) > 0:
|
||||
self.add_button = QPushButton("Add New")
|
||||
self.layout.addWidget(self.add_button, 1, 1, 1, 1)
|
||||
self.add_button.clicked.connect(self.add_new)
|
||||
@@ -126,12 +124,6 @@ class ManagerWindow(QDialog):
|
||||
for item in deletes:
|
||||
item.setParent(None)
|
||||
# logger.debug(f"Current options text lower: {self.options.currentText().lower()}")
|
||||
# NOTE: Find the instance this manager will update
|
||||
# try:
|
||||
# check = "blank" not in self.options.currentText().lower() and self.options.currentText() != ""
|
||||
# except AttributeError:
|
||||
# check = False
|
||||
# if check:
|
||||
if self.add_edit == "edit" and initial:
|
||||
# logger.debug(f"Querying with {self.options.currentText()}")
|
||||
self.instance = self.class_object.query(name=self.options.currentText(), limit=1)
|
||||
@@ -173,7 +165,6 @@ class ManagerWindow(QDialog):
|
||||
Returns:
|
||||
Any: The instance with updated fields.
|
||||
"""
|
||||
# TODO: Need Relationship property here too?
|
||||
results = [item.parse_form() for item in self.findChildren(EditProperty)]
|
||||
for result in results:
|
||||
# logger.debug(f"Incoming result: {result}")
|
||||
@@ -211,7 +202,6 @@ class ManagerWindow(QDialog):
|
||||
else:
|
||||
value = current_value + [data]
|
||||
setattr(self.instance, name, value)
|
||||
# self.instance.save()
|
||||
|
||||
def toggle_textedit(self, caller_child=None):
|
||||
already_exists = self.findChildren(LargeTextEdit)
|
||||
@@ -305,7 +295,6 @@ class EditRelationship(QWidget):
|
||||
# logger.debug(f"self.relationship: {self.relationship}")
|
||||
# logger.debug(f"Relationship uses list: {self.relationship.property.uselist}")
|
||||
# NOTE: value is a database object in this case.
|
||||
|
||||
# logger.debug(f"Data for edit relationship: {self.data}")
|
||||
self.widget = QTableView()
|
||||
self.add_button = QPushButton("Add New")
|
||||
@@ -319,7 +308,6 @@ class EditRelationship(QWidget):
|
||||
else:
|
||||
value = []
|
||||
self.data = value
|
||||
# self.update_buttons()
|
||||
checked_manager, is_primary = check_object_in_manager(self.parent().manager, self.objectName())
|
||||
if checked_manager:
|
||||
logger.debug(f"Checked manager for {self.objectName()}: {checked_manager}")
|
||||
@@ -369,7 +357,6 @@ class EditRelationship(QWidget):
|
||||
new_instance = dlg.parse_form()
|
||||
# NOTE: My custom __setattr__ should take care of any list problems.
|
||||
self.parent().instance.__setattr__(self.objectName(), new_instance)
|
||||
# self.parent().instance.save()
|
||||
self.parent().update_data()
|
||||
|
||||
def add_existing(self):
|
||||
@@ -381,7 +368,6 @@ class EditRelationship(QWidget):
|
||||
instance = self.class_object.query(**row)
|
||||
# NOTE: My custom __setattr__ should take care of any list problems.
|
||||
self.parent().instance.__setattr__(self.objectName(), instance)
|
||||
# self.parent().instance.save()
|
||||
self.parent().update_data()
|
||||
|
||||
def set_data(self) -> None:
|
||||
@@ -420,7 +406,6 @@ class EditRelationship(QWidget):
|
||||
Args:
|
||||
event (_type_): the item of interest
|
||||
"""
|
||||
# print(self.widget.isEnabled())
|
||||
if not self.widget.isEnabled():
|
||||
logger.warning(f"{self.objectName()} is disabled.")
|
||||
return
|
||||
@@ -471,7 +456,6 @@ class EditRelationship(QWidget):
|
||||
except ValueError as e:
|
||||
logger.error(f"Remove failed for {self.objectName().lower()} due to {e}.")
|
||||
self.parent().instance.save()
|
||||
# self.parent().update_data()
|
||||
self.set_data()
|
||||
|
||||
def parse_form(self):
|
||||
@@ -555,7 +539,6 @@ class JsonEditScreen(QDialog):
|
||||
output.append(value)
|
||||
else:
|
||||
raise ValueError(f"Inappropriate data type: {type(self.json_field)}")
|
||||
# output[key] = value
|
||||
return output
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ class ManagerWindow(QDialog):
|
||||
# logger.debug(f"Querying with {self.options.currentText()}")
|
||||
self.instance = self.class_object.query(name=self.options.currentText(), limit=1)
|
||||
except AttributeError:
|
||||
# self.instance = None
|
||||
pass
|
||||
# logger.debug(f"Instance: {self.instance}")
|
||||
if not self.instance:
|
||||
@@ -164,11 +163,6 @@ class ManagerWindow(QDialog):
|
||||
# NOTE: RelationshipDeclareds will be given a list of existing related objects.
|
||||
case "relationship":
|
||||
# NOTE: field.comparator.class_object.class_ gives the relationship class
|
||||
# try:
|
||||
# logger.debug(
|
||||
# f"Creating relationship widget with value: {[pformat(item.__dict__) for item in value]}")
|
||||
# except AttributeError:
|
||||
# logger.debug(f"Creating relationship widget with value: {value}")
|
||||
widget = EditRelationship(self, key=key, class_object=info.title, value=value)
|
||||
case _:
|
||||
continue
|
||||
@@ -294,7 +288,6 @@ class EditRelationship(QWidget):
|
||||
value = []
|
||||
self.data = value
|
||||
# logger.debug(f"Set data: {self.data}")
|
||||
# self.update_buttons()
|
||||
# logger.debug(f"Parent manager: {self.parent().manager}")
|
||||
checked_manager, is_primary = check_object_in_manager(self.parent().manager, self.objectName())
|
||||
if checked_manager:
|
||||
@@ -374,8 +367,6 @@ class EditRelationship(QWidget):
|
||||
return
|
||||
logger.debug(f"Updating \n{pformat(obj)} with \n{pformat(new_instance.__dict__)}")
|
||||
obj.__dict__.update(new_instance.__dict__)
|
||||
# # self.parent().omni_object.__setattr__(self.objectName(), obj)
|
||||
# # instance.__dict__.update(new_instance.__dict__)
|
||||
logger.debug(f"Final instance: {pformat(self.parent().omni_object.__dict__)}")
|
||||
# NOTE: somewhere in the update_data I'm losing changes.
|
||||
self.parent().update_data()
|
||||
|
||||
@@ -45,7 +45,6 @@ class SearchBox(QDialog):
|
||||
self.setLayout(self.layout)
|
||||
self.setWindowTitle(f"Search {self.object_type.__name__}")
|
||||
self.update_widgets()
|
||||
# self.update_data()
|
||||
if returnable:
|
||||
QBtn = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
self.buttonBox = QDialogButtonBox(QBtn)
|
||||
@@ -60,7 +59,6 @@ class SearchBox(QDialog):
|
||||
Changes form inputs based on sample type
|
||||
"""
|
||||
search_fields = []
|
||||
# search_fields = self.object_type.searchables
|
||||
logger.debug(f"Search fields: {search_fields}")
|
||||
deletes = [item for item in self.findChildren(FieldSearch)]
|
||||
for item in deletes:
|
||||
@@ -69,7 +67,6 @@ class SearchBox(QDialog):
|
||||
if not self.sub_class:
|
||||
logger.warning(f"No subclass selected.")
|
||||
self.update_data()
|
||||
# return
|
||||
else:
|
||||
if self.sub_class.currentText() == "Any":
|
||||
self.object_type = self.original_type
|
||||
|
||||
@@ -315,8 +315,6 @@ class SubmissionFormWidget(QWidget):
|
||||
query = self.findChildren(QWidget, name=object_name)
|
||||
else:
|
||||
query = self.findChildren(QWidget)
|
||||
# if object_name is not None:
|
||||
# query = [widget for widget in query if widget.objectName() == object_name]
|
||||
return query
|
||||
|
||||
@report_result
|
||||
@@ -338,7 +336,6 @@ class SubmissionFormWidget(QWidget):
|
||||
if self.disabler.checkbox.isChecked():
|
||||
_, result, _ = self.pyd.check_kit_integrity(exempt=exempt)
|
||||
report.add_result(result)
|
||||
# result = self.pyd.check_reagent_expiries(exempt=exempt)
|
||||
if len(result.results) > 0:
|
||||
return report
|
||||
base_submission = self.pyd.to_sql()
|
||||
@@ -372,7 +369,6 @@ class SubmissionFormWidget(QWidget):
|
||||
pass
|
||||
# NOTE: add reagents to submission object
|
||||
if base_submission is None:
|
||||
# self.app.table_widget.sub_wid.setData()
|
||||
return
|
||||
for reagent in base_submission.reagents:
|
||||
reagent.update_last_used(kit=base_submission.extraction_kit)
|
||||
@@ -752,11 +748,9 @@ class SubmissionFormWidget(QWidget):
|
||||
looked_up_reg = None
|
||||
if looked_up_reg:
|
||||
try:
|
||||
# relevant_reagents.remove(str(looked_up_reg.lot))
|
||||
relevant_reagents.insert(0, relevant_reagents.pop(relevant_reagents.index(looked_up_reg.lot)))
|
||||
except ValueError as e:
|
||||
logger.error(f"Error reordering relevant reagents: {e}")
|
||||
# relevant_reagents.insert(0, str(looked_up_reg.lot))
|
||||
else:
|
||||
if len(relevant_reagents) > 1:
|
||||
idx = relevant_reagents.index(str(reagent.lot))
|
||||
|
||||
Reference in New Issue
Block a user