Pre-code cleanup.
This commit is contained in:
@@ -56,23 +56,23 @@ class BaseClass(Base):
|
||||
omni_inheritable = []
|
||||
searchables = []
|
||||
|
||||
@classproperty
|
||||
def skip_on_edit(cls):
|
||||
if "association" in cls.__name__.lower() or cls.__name__.lower() == "discount":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
# @classproperty
|
||||
# def skip_on_edit(cls):
|
||||
# if "association" in cls.__name__.lower() or cls.__name__.lower() == "discount":
|
||||
# return True
|
||||
# else:
|
||||
# return False
|
||||
|
||||
@classproperty
|
||||
def aliases(cls):
|
||||
return [cls.query_alias]
|
||||
|
||||
@classproperty
|
||||
def level(cls):
|
||||
if "association" in cls.__name__.lower() or cls.__name__.lower() == "discount":
|
||||
return 2
|
||||
else:
|
||||
return 1
|
||||
# @classproperty
|
||||
# def level(cls):
|
||||
# if "association" in cls.__name__.lower() or cls.__name__.lower() == "discount":
|
||||
# return 2
|
||||
# else:
|
||||
# return 1
|
||||
|
||||
@classproperty
|
||||
def query_alias(cls):
|
||||
@@ -187,8 +187,9 @@ class BaseClass(Base):
|
||||
return query.limit(50).all()
|
||||
|
||||
@classmethod
|
||||
def results_to_df(cls, objects: list, **kwargs) -> DataFrame:
|
||||
def results_to_df(cls, objects: list|None=None, **kwargs) -> DataFrame:
|
||||
"""
|
||||
Converts class sub_dicts into a Dataframe for all instances of the class.
|
||||
|
||||
Args:
|
||||
objects (list): Objects to be converted to dataframe.
|
||||
@@ -197,10 +198,16 @@ class BaseClass(Base):
|
||||
Returns:
|
||||
Dataframe
|
||||
"""
|
||||
try:
|
||||
records = [obj.to_sub_dict(**kwargs) for obj in objects]
|
||||
except AttributeError:
|
||||
records = [{k: v['instance_attr'] for k, v in obj.omnigui_instance_dict.items()} for obj in objects]
|
||||
if not objects:
|
||||
try:
|
||||
records = [obj.to_sub_dict(**kwargs) for obj in cls.query()]
|
||||
except AttributeError:
|
||||
records = [obj.to_dict(**kwargs) for obj in cls.query(page_size=0)]
|
||||
else:
|
||||
try:
|
||||
records = [obj.to_sub_dict(**kwargs) for obj in objects]
|
||||
except AttributeError:
|
||||
records = [{k: v['instance_attr'] for k, v in obj.omnigui_instance_dict.items()} for obj in objects]
|
||||
return DataFrame.from_records(records)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -262,7 +262,7 @@ class Control(BaseClass):
|
||||
try:
|
||||
model = next(subclass for subclass in cls.__subclasses__() if
|
||||
all([hasattr(subclass, attr) for attr in attrs.keys()]))
|
||||
except StopIteration as e:
|
||||
except StopIteration:
|
||||
raise AttributeError(
|
||||
f"Couldn't find existing class/subclass of {cls} with all attributes:\n{pformat(attrs.keys())}")
|
||||
return model
|
||||
@@ -286,6 +286,7 @@ class Control(BaseClass):
|
||||
Dummy operation to be overridden by child classes.
|
||||
|
||||
Args:
|
||||
parent (QWidget): widget to add chart to.
|
||||
chart_settings (dict): settings passed down from chart widget
|
||||
ctx (Settings): settings passed down from gui
|
||||
"""
|
||||
@@ -663,7 +664,7 @@ class IridaControl(Control):
|
||||
return df, previous_dates
|
||||
# NOTE: if date was changed, rerun with new date
|
||||
else:
|
||||
logger.warning(f"Date check failed, running recursion")
|
||||
logger.warning(f"Date check failed, running recursion.")
|
||||
df, previous_dates = cls.check_date(df, item, previous_dates)
|
||||
return df, previous_dates
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ from jinja2.exceptions import TemplateNotFound
|
||||
from jinja2 import Template
|
||||
from PIL import Image
|
||||
|
||||
|
||||
logger = logging.getLogger(f"submissions.{__name__}")
|
||||
|
||||
|
||||
@@ -1584,7 +1583,7 @@ class Wastewater(BasicSubmission):
|
||||
continue
|
||||
thing['tooltip'] = f"Sample Name: {thing['name']}\nWell: {thing['sample_location']}"
|
||||
dummy_samples.append(thing)
|
||||
logger.debug(f"Dummy samples for 24 well: {pformat(dummy_samples)}")
|
||||
# logger.debug(f"Dummy samples for 24 well: {pformat(dummy_samples)}")
|
||||
output['origin_plate'] = self.__class__.make_plate_map(sample_list=dummy_samples, plate_rows=4,
|
||||
plate_columns=6)
|
||||
# logger.debug(f"PCR info: {output['pcr_info']}")
|
||||
@@ -2772,7 +2771,12 @@ class BacterialCultureSample(BasicSample):
|
||||
sample['concentration'] = self.concentration
|
||||
if self.control is not None:
|
||||
sample['colour'] = [0, 128, 0]
|
||||
sample['tooltip'] = f"Control: {self.control.controltype.name} - {self.control.controltype.targets}"
|
||||
target = next((v for k,v in self.control.controltype.targets.items() if k == self.control.subtype), "Not Available")
|
||||
try:
|
||||
target = ", ".join(target)
|
||||
except:
|
||||
target = "None"
|
||||
sample['tooltip'] = f"\nControl: {self.control.controltype.name} - {target}"
|
||||
return sample
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user