Improved generic submissions to replace viral culture addition.
This commit is contained in:
@@ -26,11 +26,11 @@ class RSLNamer(object):
|
||||
if self.submission_type is None:
|
||||
# logger.debug("Creating submission type because none exists")
|
||||
self.submission_type = self.retrieve_submission_type(filename=filename)
|
||||
# logger.debug(f"got submission type: {self.submission_type}")
|
||||
logger.debug(f"got submission type: {self.submission_type}")
|
||||
if self.submission_type is not None:
|
||||
# logger.debug("Retrieving BasicSubmission subclass")
|
||||
self.sub_object = BasicSubmission.find_polymorphic_subclass(polymorphic_identity=self.submission_type)
|
||||
self.parsed_name = self.retrieve_rsl_number(filename=filename, regex=self.sub_object.get_regex())
|
||||
self.parsed_name = self.retrieve_rsl_number(filename=filename, regex=self.sub_object.get_regex(submission_type=sub_type))
|
||||
if data is None:
|
||||
data = dict(submission_type=self.submission_type)
|
||||
if "submission_type" not in data.keys():
|
||||
@@ -50,7 +50,7 @@ class RSLNamer(object):
|
||||
"""
|
||||
match filename:
|
||||
case Path():
|
||||
# logger.debug(f"Using path method for {filename}.")
|
||||
logger.debug(f"Using path method for {filename}.")
|
||||
if filename.exists():
|
||||
wb = load_workbook(filename)
|
||||
try:
|
||||
@@ -70,12 +70,14 @@ class RSLNamer(object):
|
||||
submission_type = cls.retrieve_submission_type(filename=filename.stem.__str__())
|
||||
case str():
|
||||
regex = BasicSubmission.construct_regex()
|
||||
# logger.debug(f"Using string method for {filename}.")
|
||||
logger.debug(f"Using string method for {filename}.")
|
||||
logger.debug(f"Using regex: {regex}")
|
||||
m = regex.search(filename)
|
||||
try:
|
||||
submission_type = m.lastgroup
|
||||
logger.debug(f"Got submission type: {submission_type}")
|
||||
except AttributeError as e:
|
||||
logger.critical(f"No RSL plate number found or submission type found!: {e}")
|
||||
logger.critical(f"No submission type found or submission type found!: {e}")
|
||||
case _:
|
||||
submission_type = None
|
||||
try:
|
||||
@@ -112,7 +114,7 @@ class RSLNamer(object):
|
||||
regex = re.compile(rf'{regex}', re.IGNORECASE | re.VERBOSE)
|
||||
except re.error as e:
|
||||
regex = BasicSubmission.construct_regex()
|
||||
# logger.debug(f"Using regex: {regex}")
|
||||
logger.debug(f"Using regex: {regex}")
|
||||
match filename:
|
||||
case Path():
|
||||
m = regex.search(filename.stem)
|
||||
|
||||
@@ -509,7 +509,7 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
if check_not_nan(value['value']):
|
||||
return value
|
||||
else:
|
||||
# logger.debug("Constructing plate name.")
|
||||
# logger.debug("Constructing plate sub_type.")
|
||||
if "pytest" in sys.modules and sub_type.replace(" ", "") == "BasicSubmission":
|
||||
output = "RSL-BS-Test001"
|
||||
else:
|
||||
@@ -642,7 +642,7 @@ class PydSubmission(BaseModel, extra='allow'):
|
||||
# this could also be done with default_factory
|
||||
self.submission_object = BasicSubmission.find_polymorphic_subclass(
|
||||
polymorphic_identity=self.submission_type['value'])
|
||||
self.namer = RSLNamer(self.rsl_plate_num['value'])
|
||||
self.namer = RSLNamer(self.rsl_plate_num['value'], sub_type=self.submission_type['value'])
|
||||
|
||||
def set_attribute(self, key: str, value):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user