Skip to content

Commit

Permalink
Clean up __init__ in librarian_server.
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Jan 11, 2024
1 parent 4e20617 commit 3e3aa3e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
7 changes: 2 additions & 5 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
config = context.config
fileConfig(config.config_file_name)

from librarian_server import app, engine

from librarian_server.settings import server_settings
from librarian_server.database import Base, engine

Expand All @@ -37,9 +35,8 @@ def run_migrations_offline():
render_as_batch=True,
)

with app.app_context():
with context.begin_transaction():
context.run_migrations()
with context.begin_transaction():
context.run_migrations()


def run_migrations_online():
Expand Down
26 changes: 13 additions & 13 deletions librarian_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
asynchronously, and that background tasks can work on any available ASGI server.
"""

import os

from .settings import server_settings
from .logger import log
from .database import engine, session

from fastapi import FastAPI

log.info("Starting Librarian v2.0 server.")
log.debug("Creating FastAPI app instance.")
def main() -> FastAPI:
from .logger import log

log.info("Starting Librarian v2.0 server.")
log.debug("Creating FastAPI app instance.")

app = FastAPI()

app = FastAPI()
log.debug("Adding API router.")

log.debug("Adding API router.")
from .api import upload_router, ping_router, clone_router

from .api import upload_router, ping_router, clone_router
app.include_router(upload_router)
app.include_router(ping_router)
app.include_router(clone_router)

app.include_router(upload_router)
app.include_router(ping_router)
app.include_router(clone_router)
return app
2 changes: 1 addition & 1 deletion librarian_server_scripts/librarian_server_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main():
import uvicorn

uvicorn.run(
"librarian_server:app",
"librarian_server:main",
port=server_settings.port,
log_level=server_settings.log_level.lower(),
)
Expand Down
7 changes: 3 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ def test_server(tmp_path_factory):
import importlib

import librarian_server
import librarian_server.database

importlib.reload(librarian_server)

app = librarian_server.app
session = librarian_server.session
app = librarian_server.main()
session = librarian_server.database.session

# Need to add our stores...
from librarian_server.orm import StoreMetadata
Expand Down

0 comments on commit 3e3aa3e

Please sign in to comment.