Skip to content

Commit

Permalink
Merge pull request #27 from qua-platform/clarify_import_error
Browse files Browse the repository at this point in the history
Clarify import errors
  • Loading branch information
nulinspiratie authored Dec 18, 2024
2 parents e16bc25 + 4b8a055 commit 9cf48c6
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions qualibrate_composite/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@
from qualibrate_composite.api.routes import base_router
from qualibrate_composite.config import get_config_path, get_settings

try:
from qualibrate_app.app import app as qualibrate_app_app
except ImportError:
qualibrate_app_app = None
try:
from json_timeline_database.app import app as json_timeline_db_app
except ImportError:
json_timeline_db_app = None
try:
from qualibrate_runner.app import app as runner_app
except ImportError:
runner_app = None


app = FastAPI(title="Qualibrate")
Expand All @@ -43,20 +35,26 @@
app.include_router(base_router)

if _settings.runner.spawn:
if runner_app is None:
try:
from qualibrate_runner.app import app as runner_app
except ImportError as ex:
raise ImportError(
"Can't import qualibrate_runner instance. "
"Check that you have installed it."
)
) from ex

runner_app.add_middleware(RunnerAuthMiddleware)
app.mount("/execution", runner_app, name="qualibrate_runner")

if _settings.app.spawn:
if qualibrate_app_app is None:
try:
from qualibrate_app.app import app as qualibrate_app_app
except ImportError as ex:
raise ImportError(
"Can't import qualibrate_runner instance. "
"Can't import qualibrate_app instance. "
"Check that you have installed it."
)
) from ex

qualibrate_app_app.add_middleware(QualibrateAppAuthMiddleware)
app.mount("/", qualibrate_app_app, name="qualibrate_runner")

Expand Down

0 comments on commit 9cf48c6

Please sign in to comment.