feat!: UTA access class separation of concerns, postgres lib fixes#465
Open
jsstevenson wants to merge 12 commits intomainfrom
Open
feat!: UTA access class separation of concerns, postgres lib fixes#465jsstevenson wants to merge 12 commits intomainfrom
jsstevenson wants to merge 12 commits intomainfrom
Conversation
Member
|
Will review this tomorrow |
korikuzma
requested changes
Apr 2, 2026
| return f"postgresql://{username}{':' + password if password else ''}@{host}:{port}/{database}?options=-csearch_path%3D{schema},public" | ||
|
|
||
|
|
||
| DEFAULT_UTA_DB_URL = "postgresql://uta_admin@localhost:5432/uta?options=-csearch_path%3Duta_20241220,public" |
Member
There was a problem hiding this comment.
Trying this out with docker install, needed to set to this. I think since we are expecting people to use our docker instructions, we should update
Suggested change
| DEFAULT_UTA_DB_URL = "postgresql://uta_admin@localhost:5432/uta?options=-csearch_path%3Duta_20241220,public" | |
| DEFAULT_UTA_DB_URL = "postgresql://anonymous@localhost:5432/uta?options=-csearch_path%3Duta_20241220,public" |
Member
There was a problem hiding this comment.
Looks like usage was updated correctly, but forgot to update here
Comment on lines
+999
to
+1007
| if initialize_genomic_table: | ||
| try: | ||
| async with pool.connection() as conn: | ||
| await UtaRepository(conn).create_genomic_table() | ||
| # catch all exceptions -- this is probably a critical error, it's good to | ||
| # close the pool first | ||
| except: | ||
| await pool.close() | ||
| raise |
Member
There was a problem hiding this comment.
So I think we can actually remove this since Docker compose handles this. Or we can have the default set to False
Suggested change
| if initialize_genomic_table: | |
| try: | |
| async with pool.connection() as conn: | |
| await UtaRepository(conn).create_genomic_table() | |
| # catch all exceptions -- this is probably a critical error, it's good to | |
| # close the pool first | |
| except: | |
| await pool.close() | |
| raise |
| resp = await uta_repo.get_alt_ac_start_or_end("NM_152263.3", 822, 892, None) | ||
| assert resp == tpm3_1_8_end_genomic | ||
|
|
||
| with pytest.raises(NoMatchingAlignmentError): |
Member
There was a problem hiding this comment.
Consistency?
Suggested change
| with pytest.raises(NoMatchingAlignmentError): | |
| with pytest.raises( | |
| NoMatchingAlignmentError, | |
| match=re.escape( | |
| "Unable to find a result where NM_152263.63 has transcript coordinates (tx_exon_start=822, tx_exon_end=892) between an exon's start and end coordinates on gene=None" | |
| ), | |
| ): |
Comment on lines
-172
to
-175
| async def test_data_from_result(test_db, tx_exon_aln_data, data_from_result): | ||
| """Test that data_from_result works correctly.""" | ||
| resp = test_db.data_from_result(tx_exon_aln_data) | ||
| assert resp == data_from_result |
Member
There was a problem hiding this comment.
Should this be added back? If not, remove the data_from_result test fixture
Co-authored-by: Kori Kuzma <korikuzma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basically a lot of tech debt fixes
asyncpgtopsycopg. Honestly, asyncpg might be faster but we are generally using psycopg elsewhere so might as well stick with one thing.UtaDatabaseclass that basically retains this behavior so we can minimize needed changes in the short term (+ less work for me to update tests)postgresql://uta_admin@localhost:5432/uta?options=-csearch_path%3Duta_20241220,publicrather than/uta/uta_20241220postgresql://stuff/(db_name)/(schema_name)thing is nonstandard (I think it was basically invented for the hgvs library) and not in keeping with more typical postgres access patterns. In general, there are two standards for describing postgres connections -- as a key-value string and as a URI. So, I think if we're gonna have users go with the URI way, we should adhere to the standard.uta_20241220by default, but this is set at connection pool creation via the connection string)%(argname)ssyntax(result, failure_description)tuple where the result and the failure values were mutually exclusive into a function that returned the result value, and raised an exception in case of failure.genomictable initializer method, and also make it optional for the pool factory function to attempt creation of thegenomictable (I think this addresses UTA database recreates schema on startup #430)basically I think the ideal FastAPI usage for just UTA should look like
and within coolseqtool itself, or in other contexts where you might want to pass around the entire coolseqtool god class instance, you can do something like
A few misc engineering notes I thought about while working on this