Skip to content

Commit

Permalink
feat: fix problem with isolation_level showed as query param on API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcalvo committed Jul 9, 2024
1 parent 641ee13 commit 29410c4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions argilla-server/src/argilla_server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,17 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
AsyncSessionLocal = async_sessionmaker(autocommit=False, expire_on_commit=False, bind=async_engine)


async def get_async_db(isolation_level: Optional[IsolationLevel] = None) -> AsyncGenerator[AsyncSession, None]:
async def get_async_db() -> AsyncGenerator[AsyncSession, None]:
async for db in _get_async_db():
yield db

Check warning on line 85 in argilla-server/src/argilla_server/database.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/database.py#L84-L85

Added lines #L84 - L85 were not covered by tests


async def get_serializable_async_db() -> AsyncGenerator[AsyncSession, None]:
async for db in _get_async_db(isolation_level="SERIALIZABLE"):
yield db

Check warning on line 90 in argilla-server/src/argilla_server/database.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/database.py#L89-L90

Added lines #L89 - L90 were not covered by tests


async def _get_async_db(isolation_level: Optional[IsolationLevel] = None) -> AsyncGenerator[AsyncSession, None]:
db: AsyncSession = AsyncSessionLocal()

Check warning on line 94 in argilla-server/src/argilla_server/database.py

View check run for this annotation

Codecov / codecov/patch

argilla-server/src/argilla_server/database.py#L94

Added line #L94 was not covered by tests

if isolation_level is not None:
Expand All @@ -92,11 +102,6 @@ async def get_async_db(isolation_level: Optional[IsolationLevel] = None) -> Asyn
await db.close()


async def get_serializable_async_db() -> AsyncGenerator[AsyncSession, None]:
async for db in get_async_db(isolation_level="SERIALIZABLE"):
yield db


def database_url_sync() -> str:
"""
Returns a "sync" version of the configured database URL. This may be useful in cases we don't need
Expand Down

0 comments on commit 29410c4

Please sign in to comment.