From e16b5f7cdcebdebaf88456549bd5f5321ecefc57 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:37:03 +1000 Subject: [PATCH] feat(backend): deserialize batch session directly If the values from the `session_dict` are invalid, the model instantiation will fail, or if we end up with an invalid `batch_id`, the app will not run. So I think just parsing the dict directly is equivalent. Also the LSP analyser is pleased now - no red squigglies. --- invokeai/app/services/batch_manager_storage.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/invokeai/app/services/batch_manager_storage.py b/invokeai/app/services/batch_manager_storage.py index 76c1664536..14a05a6c23 100644 --- a/invokeai/app/services/batch_manager_storage.py +++ b/invokeai/app/services/batch_manager_storage.py @@ -481,17 +481,7 @@ class SqliteBatchProcessStorage(BatchProcessStorageBase): def _deserialize_batch_session(self, session_dict: dict) -> BatchSession: """Deserializes a batch session.""" - # Retrieve all the values, setting "reasonable" defaults if they are not present. - - batch_id = session_dict.get("batch_id", "unknown") - session_id = session_dict.get("session_id", "unknown") - state = session_dict.get("state", "unknown") - - return BatchSession( - batch_id=batch_id, - session_id=session_id, - state=state, - ) + return BatchSession.parse_obj(session_dict) def get_created_session(self, batch_id: str) -> BatchSession: try: