Beginning prelim code cleanup.
This commit is contained in:
@@ -8,7 +8,7 @@ from pydantic import BaseModel
|
||||
from sqlalchemy import Column, INTEGER, String, JSON
|
||||
from sqlalchemy.orm import DeclarativeMeta, declarative_base, Query, Session, InstrumentedAttribute, ColumnProperty
|
||||
from sqlalchemy.ext.declarative import declared_attr
|
||||
from sqlalchemy.exc import ArgumentError, InvalidRequestError
|
||||
from sqlalchemy.exc import ArgumentError
|
||||
from typing import Any, List
|
||||
from pathlib import Path
|
||||
|
||||
@@ -156,9 +156,6 @@ class BaseClass(Base):
|
||||
Any: Subclass of this object
|
||||
|
||||
"""
|
||||
# if not name:
|
||||
# logger.warning("You need to include a name of what you're looking for.")
|
||||
# return cls
|
||||
if " " in name:
|
||||
search = name.title().replace(" ", "")
|
||||
else:
|
||||
@@ -343,7 +340,6 @@ class BaseClass(Base):
|
||||
"""
|
||||
logger.debug(f"Incoming attributes: {attributes}")
|
||||
for key, value in attributes.items():
|
||||
# print(getattr(self.__class__, key).property)
|
||||
if value.lower() == "none":
|
||||
value = None
|
||||
logger.debug(f"Attempting to grab attribute: {key}")
|
||||
@@ -355,7 +351,6 @@ class BaseClass(Base):
|
||||
else:
|
||||
filter = class_attr.property
|
||||
match filter:
|
||||
# match class_attr:
|
||||
case ColumnProperty():
|
||||
match class_attr.type:
|
||||
case INTEGER():
|
||||
@@ -397,8 +392,6 @@ class BaseClass(Base):
|
||||
"""
|
||||
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:
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from __future__ import annotations
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import logging, sys
|
||||
from pydantic import BaseModel, field_validator, Field
|
||||
from typing import List, ClassVar
|
||||
from backend.db.models import *
|
||||
@@ -37,7 +35,6 @@ class BaseOmni(BaseModel):
|
||||
"""
|
||||
logger.debug(f"Incoming attributes: {attributes}")
|
||||
for key, value in attributes.items():
|
||||
# print(getattr(self.__class__, key).property)
|
||||
if value.lower() == "none":
|
||||
value = None
|
||||
logger.debug(f"Attempting to grab attribute: {key}")
|
||||
@@ -127,7 +124,6 @@ class BaseOmni(BaseModel):
|
||||
if issubclass(value.__class__, self.__class__):
|
||||
value = value.to_sql()
|
||||
value = [value]
|
||||
# value = list(set(value))
|
||||
logger.debug(f"Final value for {key}: {value}")
|
||||
return super().__setattr__(key, value)
|
||||
else:
|
||||
@@ -243,7 +239,6 @@ class OmniSubmissionTypeKitTypeAssociation(BaseOmni):
|
||||
mutable_cost_column: float = Field(default=0.0, description="property")
|
||||
mutable_cost_sample: float = Field(default=0.0, description="property")
|
||||
constant_cost: float = Field(default=0.0, description="property")
|
||||
# processes: List[OmniProcess] | List[str] = Field(default=[], description="relationship", title="Process")
|
||||
|
||||
def __repr__(self):
|
||||
if isinstance(self.submissiontype, str):
|
||||
@@ -313,7 +308,6 @@ class OmniSubmissionTypeKitTypeAssociation(BaseOmni):
|
||||
else:
|
||||
kittype = KitType.query(name=self.kittype)
|
||||
# logger.debug(f"Self kittype: {self.kittype}")
|
||||
# kittype = KitType.query(name=self.kittype)
|
||||
logger.debug(f"Query or create with {kittype}, {submissiontype}")
|
||||
instance, is_new = self.class_object.query_or_create(kittype=kittype, submissiontype=submissiontype)
|
||||
instance.mutable_cost_column = self.mutable_cost_column
|
||||
@@ -352,7 +346,6 @@ class OmniKitTypeReagentRoleAssociation(BaseOmni):
|
||||
kit_type = self.kit_type.name
|
||||
else:
|
||||
kit_type = self.kit_type
|
||||
# name = f"{kit_type} -> {self.reagent_role}"
|
||||
# logger.debug(f"Using name: {name}")
|
||||
if isinstance(self.reagent_role, OmniReagentRole):
|
||||
reagent_role = self.reagent_role.name
|
||||
@@ -360,7 +353,6 @@ class OmniKitTypeReagentRoleAssociation(BaseOmni):
|
||||
reagent_role = self.reagent_role
|
||||
return dict(
|
||||
reagent_role=reagent_role,
|
||||
# name=self.reagent_role.name,
|
||||
submission_type=submission_type,
|
||||
kit_type=kit_type
|
||||
)
|
||||
@@ -381,7 +373,6 @@ class OmniKitTypeReagentRoleAssociation(BaseOmni):
|
||||
logger.debug(f"KTRRAssoc uses: {self.uses}")
|
||||
instance.uses = self.uses
|
||||
logger.debug(f"KitTypeReagentRoleAssociation: {pformat(instance.__dict__)}")
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
@@ -464,8 +455,6 @@ class OmniTipRole(BaseOmni):
|
||||
instance, new = self.class_object.query_or_create(name=self.name)
|
||||
for tips in self.tips:
|
||||
tips.to_sql()
|
||||
# if new_assoc not in instance.instances:
|
||||
# instance.instances.append(new_assoc)
|
||||
return instance
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user