Skip to content

Commit

Permalink
Fix typing: SQLAlchemy annotations were incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
hoh committed Apr 9, 2024
1 parent 19b0916 commit 07c34f9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/aleph/vm/orchestrator/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
delete,
select,
)
from sqlalchemy.engine import Engine
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import (
AsyncEngine,
AsyncSession,
async_sessionmaker,
create_async_engine,
)

try:
from sqlalchemy.orm import declarative_base
Expand All @@ -26,7 +29,7 @@

from aleph.vm.conf import make_db_url, settings

AsyncSessionMaker: sessionmaker
AsyncSessionMaker: async_sessionmaker[AsyncSession]

logger = logging.getLogger(__name__)

Expand All @@ -36,11 +39,11 @@
def setup_engine():
global AsyncSessionMaker
engine = create_async_engine(make_db_url(), echo=True)
AsyncSessionMaker = sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
AsyncSessionMaker = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
return engine


async def create_tables(engine: Engine):
async def create_tables(engine: AsyncEngine):
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)

Expand Down

0 comments on commit 07c34f9

Please sign in to comment.