Skip to content

Commit

Permalink
Merge pull request #2067 from DSD-DBS/move-config
Browse files Browse the repository at this point in the history
refactor: Group configuration-related API routes below `/configurations`
  • Loading branch information
MoritzWeber0 authored Dec 9, 2024
2 parents f251d4c + be00606 commit eb01c8d
Show file tree
Hide file tree
Showing 52 changed files with 95 additions and 95 deletions.
2 changes: 1 addition & 1 deletion backend/capellacollab/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import capellacollab.projects.toolmodels.backups.runs.interface as pipeline_runs_interface

# This import statement is required and should not be removed! (Alembic will not work otherwise)
from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import logging as core_logging
from capellacollab.core.database import engine, migration
from capellacollab.routes import router
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from alembic import context
from sqlalchemy import engine_from_config, pool

from capellacollab.config import config as cfg
from capellacollab.configuration.app import config as cfg

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def write_config() -> None:
"""Write the default configuration to a config file."""

config_path = (
pathlib.Path(__file__).parent.parent.parent / "config" / "config.yaml"
pathlib.Path(__file__).parent.parent.parent.parent
/ "config"
/ "config.yaml"
)

config_path.parent.mkdir(parents=True, exist_ok=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

config_locations: list[pathlib.Path] = [
pathlib.Path(__file__).parents[0] / CONFIG_FILE_NAME,
pathlib.Path(__file__).parents[2] / "config" / CONFIG_FILE_NAME,
pathlib.Path(__file__).parents[3] / "config" / CONFIG_FILE_NAME,
pathlib.Path(appdirs.user_config_dir("capellacollab", "db"))
/ CONFIG_FILE_NAME,
pathlib.Path("/etc/capellacollab") / CONFIG_FILE_NAME,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
tags=["Configuration"],
)

schema_router = fastapi.APIRouter(dependencies=[], tags=["Configuration"])
router_without_authentication = fastapi.APIRouter(
dependencies=[], tags=["Configuration"]
)


@router.get(
@router_without_authentication.get(
"/unified",
)
def get_unified_config(
Expand Down Expand Up @@ -92,7 +94,7 @@ async def update_configuration(
).configuration


@schema_router.get(
@router_without_authentication.get(
f"/{models.GlobalConfiguration._name}/schema", response_model=t.Any
)
async def get_json_schema():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# SPDX-License-Identifier: Apache-2.0

import capellacollab
from capellacollab.config import config
from capellacollab.settings.configuration import models
from capellacollab.configuration.app import config

from . import models


def get_metadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from fastapi import security
from jwt import exceptions as jwt_exceptions

from capellacollab.config import config
from capellacollab.configuration.app import config

from . import exceptions, oidc

Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/authentication/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests
from oauthlib import common, oauth2

from capellacollab.config import config
from capellacollab.configuration.app import config

from . import exceptions, models

Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sqlalchemy import orm
from sqlalchemy.dialects import postgresql

from capellacollab.config import config
from capellacollab.configuration.app import config

engine = sa.create_engine(
config.database.url,
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/database/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sqlalchemy import orm

from capellacollab import core
from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database
from capellacollab.events import crud as events_crud
from capellacollab.projects import crud as projects_crud
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# pylint: disable=unused-import
# These import statements of the models are required and should not be removed! (SQLAlchemy will not load the models otherwise)

import capellacollab.configuration.models
import capellacollab.events.models
import capellacollab.feedback.models
import capellacollab.notices.models
Expand All @@ -18,7 +19,6 @@
import capellacollab.projects.tools.models
import capellacollab.projects.users.models
import capellacollab.sessions.models
import capellacollab.settings.configuration.models
import capellacollab.settings.integrations.purevariants.models
import capellacollab.settings.modelsources.git.models
import capellacollab.settings.modelsources.t4c.instance.models
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/email/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pydantic

from capellacollab.config import config
from capellacollab.configuration.app import config

from . import exceptions, models

Expand Down
4 changes: 2 additions & 2 deletions backend/capellacollab/core/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import fastapi
from starlette.middleware import base

from capellacollab import config
from capellacollab.configuration.app import config
from capellacollab.core.authentication import injectables as auth_injectables

LOGGING_LEVEL = config.config.logging.level
LOGGING_LEVEL = config.logging.level


class CustomFormatter(logging.Formatter):
Expand Down
4 changes: 2 additions & 2 deletions backend/capellacollab/core/logging/loki.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import requests
from requests import auth

from capellacollab.config import config
from capellacollab.config import models as config_models
from capellacollab.configuration.app import config
from capellacollab.configuration.app import models as config_models

from . import exceptions

Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/core/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import fastapi
import pydantic

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import pydantic as core_pydantic
from capellacollab.projects.users import models as projects_users_models
from capellacollab.users import models as users_models
Expand Down
8 changes: 3 additions & 5 deletions backend/capellacollab/feedback/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

from sqlalchemy import orm

from capellacollab.config import config
from capellacollab.configuration import core as config_core
from capellacollab.configuration import models as settings_config_models
from capellacollab.configuration.app import config
from capellacollab.core.email import exceptions as email_exceptions
from capellacollab.core.email import models as email_models
from capellacollab.core.email import send as email_send
from capellacollab.settings.configuration import core as config_core
from capellacollab.settings.configuration import (
models as settings_config_models,
)
from capellacollab.users import models as users_models

from . import exceptions, models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import requests
from sqlalchemy import orm

from capellacollab.configuration import core as configuration_core
from capellacollab.core import credentials, database
from capellacollab.core.authentication import injectables as auth_injectables
from capellacollab.projects.toolmodels import (
Expand All @@ -23,7 +24,6 @@
)
from capellacollab.projects.users import models as projects_users_models
from capellacollab.sessions import operators
from capellacollab.settings.configuration import core as configuration_core
from capellacollab.settings.modelsources.t4c.instance.repositories import (
interface as t4c_repository_interface,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from kubernetes.client import exceptions as k8s_exceptions
from starlette import concurrency as starlette_concurrency

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database
from capellacollab.core.logging import loki
from capellacollab.projects.toolmodels import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import requests

from capellacollab.config import config
from capellacollab.configuration.app import config

from .. import exceptions as git_exceptions
from ..handler import handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import aiohttp
import requests

from capellacollab.config import config
from capellacollab.configuration.app import config

from .. import exceptions as git_exceptions
from ..handler import handler
Expand Down
11 changes: 11 additions & 0 deletions backend/capellacollab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import fastapi

from capellacollab.configuration import routes as configuration_routes
from capellacollab.core import responses as auth_responses
from capellacollab.core.authentication import routes as authentication_routes
from capellacollab.events import routes as events_router
Expand Down Expand Up @@ -77,5 +78,15 @@
settings_routes.router_without_authentication,
prefix="/settings",
)
router.include_router(
configuration_routes.router,
prefix="/configurations",
responses=auth_responses.api_exceptions(include_authentication=True),
)
router.include_router(
configuration_routes.router_without_authentication,
prefix="/configurations",
)


router.include_router(authentication_routes.router, prefix="/authentication")
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/hooks/guacamole.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from requests import auth as requests_auth
from requests import exceptions as requests_exceptions

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import credentials

from . import interface
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/hooks/log_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import yaml

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.sessions import models as sessions_models
from capellacollab.sessions.operators import models as operators_models
from capellacollab.tools import models as tools_models
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/idletimeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import requests
from starlette import concurrency

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database

from . import crud, operators, util
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests

from capellacollab import core
from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.sessions import models2 as sessions_models2

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/sessions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sqlalchemy as sa
from sqlalchemy import orm

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database
from capellacollab.core import models as core_models
from capellacollab.core import pydantic as core_pydantic
Expand Down
4 changes: 2 additions & 2 deletions backend/capellacollab/sessions/operators/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from kubernetes import client
from kubernetes.client import exceptions

from capellacollab.config import config
from capellacollab.config import models as config_models
from capellacollab.configuration.app import config
from capellacollab.configuration.app import models as config_models
from capellacollab.sessions import models as sessions_models
from capellacollab.tools import models as tools_models

Expand Down
4 changes: 1 addition & 3 deletions backend/capellacollab/sessions/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

from sqlalchemy import orm

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import credentials
from capellacollab.core import models as core_models
from capellacollab.sessions import hooks
from capellacollab.sessions.hooks import interface as hooks_interface
from capellacollab.sessions.operators import k8s
from capellacollab.tools import models as tools_models
from capellacollab.users import models as users_models

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
from requests import auth

from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import credentials
from capellacollab.settings.modelsources.t4c.instance import (
models as t4c_models,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import requests

from capellacollab import config
from capellacollab.configuration.app import config
from capellacollab.core import pydantic as core_pydantic

from . import exceptions
Expand All @@ -18,7 +18,7 @@ def get_t4c_license_server_version(usage_api: str) -> str | None:
try:
r = requests.get(
f"{usage_api}/status/json",
timeout=config.config.requests.timeout,
timeout=config.requests.timeout,
)
except requests.Timeout:
return None
Expand All @@ -36,7 +36,7 @@ def get_t4c_license_server_usage(usage_api: str) -> T4CLicenseServerUsage:
try:
r = requests.get(
f"{usage_api}/status/json",
timeout=config.config.requests.timeout,
timeout=config.requests.timeout,
)
except requests.Timeout:
raise exceptions.T4CLicenseServerTimeoutError()
Expand Down
5 changes: 0 additions & 5 deletions backend/capellacollab/settings/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import fastapi

from capellacollab.core.authentication import injectables as auth_injectables
from capellacollab.settings.configuration import routes as configuration_routes
from capellacollab.settings.integrations.purevariants import (
routes as purevariants_routes,
)
Expand All @@ -29,7 +28,3 @@
router.include_router(
purevariants_routes.router, prefix="/integrations/pure-variants"
)
router.include_router(configuration_routes.router, prefix="/configurations")
router_without_authentication.include_router(
configuration_routes.schema_router, prefix="/configurations"
)
2 changes: 1 addition & 1 deletion backend/capellacollab/tools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sqlalchemy import orm

from capellacollab import core
from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database
from capellacollab.core import pydantic as core_pydantic
from capellacollab.core.database import decorator
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/tools/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import capellacollab.projects.toolmodels.crud as projects_models_crud
import capellacollab.settings.modelsources.t4c.instance.crud as settings_t4c_crud
from capellacollab.config import config
from capellacollab.configuration.app import config
from capellacollab.core import database
from capellacollab.core import exceptions as core_exceptions
from capellacollab.core.authentication import injectables as auth_injectables
Expand Down
Loading

0 comments on commit eb01c8d

Please sign in to comment.