|
30 | 30 | alert_queue = asyncio.Queue() |
31 | 31 | fim_cache = FimCache() |
32 | 32 |
|
| 33 | + |
33 | 34 | class AlreadyExistsError(Exception): |
34 | 35 | pass |
35 | 36 |
|
| 37 | + |
36 | 38 | class DbCodeGate: |
37 | 39 | _instance = None |
38 | 40 |
|
@@ -266,7 +268,8 @@ async def add_workspace(self, workspace_name: str) -> Optional[Workspace]: |
266 | 268 |
|
267 | 269 | try: |
268 | 270 | added_workspace = await self._execute_update_pydantic_model( |
269 | | - workspace, sql, should_raise=True) |
| 271 | + workspace, sql, should_raise=True |
| 272 | + ) |
270 | 273 | except IntegrityError as e: |
271 | 274 | logger.debug(f"Exception type: {type(e)}") |
272 | 275 | raise AlreadyExistsError(f"Workspace {workspace_name} already exists.") |
@@ -317,8 +320,11 @@ async def _execute_select_pydantic_model( |
317 | 320 | return None |
318 | 321 |
|
319 | 322 | async def _exec_select_conditions_to_pydantic( |
320 | | - self, model_type: Type[BaseModel], sql_command: TextClause, conditions: dict, |
321 | | - should_raise: bool = False |
| 323 | + self, |
| 324 | + model_type: Type[BaseModel], |
| 325 | + sql_command: TextClause, |
| 326 | + conditions: dict, |
| 327 | + should_raise: bool = False, |
322 | 328 | ) -> Optional[List[BaseModel]]: |
323 | 329 | async with self._async_db_engine.begin() as conn: |
324 | 330 | try: |
@@ -397,7 +403,8 @@ async def get_workspace_by_name(self, name: str) -> List[Workspace]: |
397 | 403 | ) |
398 | 404 | conditions = {"name": name} |
399 | 405 | workspaces = await self._exec_select_conditions_to_pydantic( |
400 | | - Workspace, sql, conditions, should_raise=True) |
| 406 | + Workspace, sql, conditions, should_raise=True |
| 407 | + ) |
401 | 408 | return workspaces[0] if workspaces else None |
402 | 409 |
|
403 | 410 | async def get_sessions(self) -> List[Session]: |
|
0 commit comments