Skip to content

Commit 7fe961d

Browse files
committed
ok done now
1 parent 5f0ad99 commit 7fe961d

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

src/cool_seq_tool/sources/uta_database.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
True
1515
1616
The class breakdown in this module is intended to reflect a *repository pattern*, where
17-
query/data transformation logic is defined in :py:class:`~cool_seq_tool.uta_database.UtaRepository`,
18-
and connection management/state/etc is defined in :py:class:`~cool_seq_tool.uta_database.UtaDatabase`.
17+
query/data transformation logic is defined in :py:class:`~cool_seq_tool.sources.uta_database.UtaRepository`,
18+
and connection management/state/etc is constructed with :py:meth:`~cool_seq_tool.sources.uta_database.create_uta_connection_pool`.
1919
2020
The following is an example of how you might employ this in a FastAPI app:
2121
@@ -54,14 +54,30 @@ async def check_gene_exists(
5454
):
5555
return await uta.gene_exists(gene)
5656
57-
The connection class also provides a ``repository()`` method, which returns a context
58-
manager, for convenience:
57+
To reflect the old pattern of constructing/managing connection state, the :py:class:`~cool_seq_tool.sources.uta_database.UtaDatabase`
58+
class is provided. Its construction will look more like our previous UTA access patterns did,
59+
but individual queries should still be issued within a context manager. The
60+
:py:meth:`~cool_seq_tool.sources.uta_database.UtaDatabase.repository` method is provided as
61+
a convenient means of doing so.
5962
6063
.. code-block:: python
6164
62-
uta_db: UtaDatabase # assume this exists
63-
async with uta_db.repository() as uta:
64-
print(await uta.gene_exists("BRAF"))
65+
import asyncio
66+
67+
from cool_seq_tool.sources.uta_database import (
68+
create_uta_connection_pool,
69+
UtaDatabase,
70+
)
71+
72+
73+
async def example(gene: str):
74+
uta_db = UtaDatabase(connection)
75+
async with uta_db.repository() as uta:
76+
print(await uta.gene_exists("BRAF"))
77+
await uta_db.close()
78+
79+
80+
asyncio.run(example("BRAF"))
6581
6682
"""
6783

0 commit comments

Comments
 (0)