1212from cool_seq_tool .handlers .seqrepo_access import SEQREPO_ROOT_DIR , SeqRepoAccess
1313from cool_seq_tool .mappers .liftover import LiftOver
1414from cool_seq_tool .resources .data_files import DataFile , get_data_file
15- from cool_seq_tool .sources .uta_database import UTA_DB_URL , ParseResult , UtaDatabase
15+ from cool_seq_tool .sources .uta_database import (
16+ DEFAULT_UTA_DB_URL ,
17+ ParseResult ,
18+ UtaDatabase ,
19+ create_uta_connection_pool ,
20+ )
1621
1722_logger = logging .getLogger (__name__ )
1823
@@ -35,7 +40,7 @@ async def check_status(
3540 transcript_file_path : Path | None = None ,
3641 lrg_refseqgene_path : Path | None = None ,
3742 mane_data_path : Path | None = None ,
38- db_url : str = UTA_DB_URL ,
43+ db_url : str | None = None ,
3944 sr : SeqRepo | None = None ,
4045 chain_file_37_to_38 : str | None = None ,
4146 chain_file_38_to_37 : str | None = None ,
@@ -120,24 +125,31 @@ async def check_status(
120125 else :
121126 status ["liftover" ] = True
122127
123- parsed_result = ParseResult (urlparse (db_url ))
124- sanitized_url = parsed_result .sanitized_url
125- try :
126- await UtaDatabase .create (db_url )
127- except ValueError :
128- _logger .exception ("Database URL is not valid" )
129- except (OSError , InvalidCatalogNameError , UndefinedTableError ):
130- _logger .exception (
131- "Encountered error instantiating UTA at URI %s" , sanitized_url
132- )
133- except Exception as e :
134- _logger .critical (
135- "Encountered unexpected error instantiating UTA from URI %s: %s" ,
136- sanitized_url ,
137- e ,
138- )
128+ uta_pool = await create_uta_connection_pool (db_url )
129+ uta_db = UtaDatabase (uta_pool )
130+ if db_url :
131+ sanitized_url = ParseResult (urlparse (db_url )).sanitized_url
139132 else :
140- status ["uta" ] = True
133+ sanitized_url = DEFAULT_UTA_DB_URL
134+
135+ async with uta_db .repository () as uta :
136+ try :
137+ cursor = await uta .execute_query ("SELECT 1 FROM transcript LIMIT 1;" )
138+ await cursor .fetchone ()
139+ except ValueError :
140+ _logger .exception ("Database URL is not valid: %s" , sanitized_url )
141+ except (OSError , InvalidCatalogNameError , UndefinedTableError ):
142+ _logger .exception (
143+ "Encountered error instantiating UTA at URI %s" , sanitized_url
144+ )
145+ except Exception as e :
146+ _logger .critical (
147+ "Encountered unexpected error instantiating UTA from URI %s: %s" ,
148+ sanitized_url ,
149+ e ,
150+ )
151+ else :
152+ status ["uta" ] = True
141153
142154 try :
143155 if not sr :
0 commit comments