Skip to content

Commit

Permalink
Merge pull request #317 from ynput/fix-api-circular-imports
Browse files Browse the repository at this point in the history
Removed exports from ayon_server.api to prevent circular imports
  • Loading branch information
martastain authored Sep 10, 2024
2 parents 8a81d57 + 32071f4 commit d8e04c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 40 deletions.
2 changes: 1 addition & 1 deletion api/addons/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from fastapi import APIRouter

from ayon_server.api import ResponseFactory
from ayon_server.api.responses import ResponseFactory

route_meta: dict[str, Any] = {
"tags": ["Addon settings"],
Expand Down
2 changes: 1 addition & 1 deletion api/users/router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import APIRouter

from ayon_server.api import ResponseFactory
from ayon_server.api.responses import ResponseFactory

router = APIRouter(
prefix="/users",
Expand Down
35 changes: 0 additions & 35 deletions ayon_server/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
__all__ = [
"JSONResponse",
"ResponseFactory",
"dep_access_token",
"dep_attribute_name",
"dep_current_user",
"dep_current_user_optional",
"dep_project_name",
"dep_new_project_name",
"dep_folder_id",
"dep_product_id",
"dep_version_id",
"dep_representation_id",
"dep_task_id",
"dep_thumbnail_id",
"dep_workfile_id",
"app",
]

from ayon_server.api.dependencies import (
dep_access_token,
dep_attribute_name,
dep_current_user,
dep_current_user_optional,
dep_folder_id,
dep_new_project_name,
dep_product_id,
dep_project_name,
dep_representation_id,
dep_task_id,
dep_thumbnail_id,
dep_version_id,
dep_workfile_id,
)
from ayon_server.api.responses import JSONResponse, ResponseFactory
11 changes: 8 additions & 3 deletions ayon_server/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from fastapi.websockets import WebSocket, WebSocketDisconnect
from nxtools import log_to_file, log_traceback, logging, slugify

from ayon_server.access.access_groups import AccessGroups
from ayon_server.addons import AddonLibrary
from ayon_server.api.frontend import init_frontend
from ayon_server.api.messaging import Messaging
Expand Down Expand Up @@ -358,6 +357,13 @@ def init_addon_static(target_app: fastapi.FastAPI) -> None:
#


async def load_access_groups() -> None:
"""Load access groups from the database."""
from ayon_server.access.access_groups import AccessGroups

await AccessGroups.load()


@app.on_event("startup")
async def startup_event() -> None:
"""Startup event.
Expand All @@ -376,8 +382,7 @@ async def startup_event() -> None:
# Connect to the database and load stuff

await ayon_init()

await AccessGroups.load()
await load_access_groups()

# Start background tasks

Expand Down

0 comments on commit d8e04c3

Please sign in to comment.