Switching to pydantic as primary object for Omni-manager
This commit is contained in:
@@ -53,6 +53,7 @@ class BaseClass(Base):
|
||||
singles = ['id']
|
||||
omni_removes = ["id", 'submissions', "omnigui_class_dict", "omnigui_instance_dict"]
|
||||
omni_sort = ["name"]
|
||||
omni_inheritable = []
|
||||
|
||||
@classproperty
|
||||
def skip_on_edit(cls):
|
||||
@@ -330,7 +331,15 @@ class BaseClass(Base):
|
||||
query_kwargs = {relationship_instance.query_alias: relationship_instance}
|
||||
return cls.query(**query_kwargs)
|
||||
|
||||
def check_all_attributes(self, attributes: dict):
|
||||
def check_all_attributes(self, attributes: dict) -> bool:
|
||||
"""
|
||||
|
||||
Args:
|
||||
attributes (dict): A dictionary of attributes to be check for equivalence
|
||||
|
||||
Returns:
|
||||
bool: If a single unequivocal value is found will be false, else true.
|
||||
"""
|
||||
logger.debug(f"Incoming attributes: {attributes}")
|
||||
for key, value in attributes.items():
|
||||
# print(getattr(self.__class__, key).property)
|
||||
@@ -365,7 +374,11 @@ class BaseClass(Base):
|
||||
return True
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
logger.debug(f"Attempting to set {key} to {pformat(value)}")
|
||||
"""
|
||||
Custom dunder method to handle potential list relationship issues.
|
||||
"""
|
||||
if key != "_sa_instance_state":
|
||||
logger.debug(f"Attempting to set {key} to {pformat(value)}")
|
||||
try:
|
||||
field_type = getattr(self.__class__, key)
|
||||
except AttributeError:
|
||||
@@ -395,8 +408,10 @@ class BaseClass(Base):
|
||||
else:
|
||||
raise ValueError("Object is too long to parse a single value.")
|
||||
return super().__setattr__(key, value)
|
||||
case _:
|
||||
return super().__setattr__(key, value)
|
||||
else:
|
||||
super().__setattr__(key, value)
|
||||
return super().__setattr__(key, value)
|
||||
|
||||
|
||||
class ConfigItem(BaseClass):
|
||||
|
||||
@@ -380,6 +380,9 @@ class KitType(BaseClass):
|
||||
new_process.equipment_roles.append(new_role)
|
||||
return new_kit
|
||||
|
||||
def to_pydantic(self):
|
||||
pass
|
||||
|
||||
|
||||
class ReagentRole(BaseClass):
|
||||
"""
|
||||
@@ -1232,6 +1235,7 @@ class KitTypeReagentRoleAssociation(BaseClass):
|
||||
|
||||
omni_removes = BaseClass.omni_removes + ["submission_type_id", "kits_id", "reagent_roles_id", "last_used"]
|
||||
omni_sort = ["submission_type", "kit_type", "reagent_role", "required", "uses"]
|
||||
omni_inheritable = ["submission_type", "kit_type"]
|
||||
|
||||
reagent_roles_id = Column(INTEGER, ForeignKey("_reagentrole.id"),
|
||||
primary_key=True) #: id of associated reagent type
|
||||
|
||||
@@ -417,9 +417,11 @@ class BasicSubmission(BaseClass, LogMixin):
|
||||
except Exception as e:
|
||||
logger.error(f"Column count error: {e}")
|
||||
# NOTE: Get kit associated with this submission
|
||||
logger.debug(f"Checking associations with submission type: {self.submission_type_name}")
|
||||
assoc = next((item for item in self.extraction_kit.kit_submissiontype_associations if
|
||||
item.submission_type == self.submission_type),
|
||||
None)
|
||||
logger.debug(f"Got association: {assoc}")
|
||||
# NOTE: If every individual cost is 0 this is probably an old plate.
|
||||
if all(item == 0.0 for item in [assoc.constant_cost, assoc.mutable_cost_column, assoc.mutable_cost_sample]):
|
||||
try:
|
||||
@@ -1325,7 +1327,10 @@ class BasicSubmission(BaseClass, LogMixin):
|
||||
if dlg.exec():
|
||||
equipment = dlg.parse_form()
|
||||
for equip in equipment:
|
||||
logger.debug(f"Parsed equipment: {equip}")
|
||||
_, assoc = equip.to_sql(submission=self)
|
||||
logger.debug(f"Got equipment association: {assoc.__dict__}")
|
||||
|
||||
try:
|
||||
assoc.save()
|
||||
except AttributeError as e:
|
||||
|
||||
Reference in New Issue
Block a user