mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Lint and spelling fixes.
This commit is contained in:
@@ -34,7 +34,7 @@ class RoleModel(BaseModel):
|
||||
model_class: str = Field(title="Model class", description="Database model class (Role)")
|
||||
|
||||
|
||||
class RoleDefeinitionModel(BaseModel):
|
||||
class RoleDefinitionModel(BaseModel):
|
||||
name: str = RoleNameField
|
||||
description: str = RoleDescriptionField
|
||||
user_ids: Optional[List[EncodedDatabaseIdField]] = Field(title="User IDs", default=[])
|
||||
|
||||
@@ -19,24 +19,26 @@ from galaxy import web
|
||||
from galaxy.app import UniverseApplication
|
||||
from galaxy.managers.base import decode_id
|
||||
from galaxy.managers.roles import (
|
||||
RoleDefinitionModel,
|
||||
RoleManager,
|
||||
RoleDefeinitionModel,
|
||||
RoleModel,
|
||||
)
|
||||
from galaxy.schema.fields import EncodedDatabaseIdField
|
||||
from galaxy.webapps.base.controller import BaseAPIController, url_for
|
||||
from galaxy.work.context import (
|
||||
SessionRequestContext,
|
||||
)
|
||||
from . import (
|
||||
get_admin_user,
|
||||
get_app,
|
||||
get_trans,
|
||||
)
|
||||
from galaxy.work.context import (
|
||||
SessionRequestContext,
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Empty paths (e.g. /api/roles) only work if a prefix is defined right here.
|
||||
# https://github.com/tiangolo/fastapi/pull/415/files
|
||||
router = APIRouter(tags=["roles"])
|
||||
|
||||
|
||||
@@ -58,7 +60,6 @@ def get_role_manager(app: UniverseApplication = Depends(get_app)) -> RoleManager
|
||||
return app.role_manager
|
||||
|
||||
|
||||
|
||||
@cbv(router)
|
||||
class FastAPIRoles:
|
||||
role_manager: RoleManager = Depends(get_role_manager)
|
||||
@@ -75,7 +76,7 @@ class FastAPIRoles:
|
||||
return role_to_model(trans, role)
|
||||
|
||||
@router.post("/api/roles")
|
||||
def create(self, trans: SessionRequestContext = Depends(get_trans), admin_user=Depends(get_admin_user), role_definition_model: RoleDefeinitionModel = Body(...)) -> RoleModel:
|
||||
def create(self, trans: SessionRequestContext = Depends(get_trans), admin_user=Depends(get_admin_user), role_definition_model: RoleDefinitionModel = Body(...)) -> RoleModel:
|
||||
role = self.role_manager.create(trans, role_definition_model)
|
||||
return role_to_model(trans, role)
|
||||
|
||||
@@ -109,7 +110,7 @@ class RoleAPIController(BaseAPIController):
|
||||
Creates a new role.
|
||||
"""
|
||||
expand_json_keys(payload, ["user_ids", "group_ids"])
|
||||
role_definition_model = RoleDefeinitionModel(**payload)
|
||||
role_definition_model = RoleDefinitionModel(**payload)
|
||||
role = self._role_manager.create(trans, role_definition_model)
|
||||
return role_to_model(trans, role)
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.middleware.wsgi import WSGIMiddleware
|
||||
from fastapi.responses import JSONResponse
|
||||
from pydantic.error_wrappers import ValidationError
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from starlette.middleware.base import RequestResponseEndpoint
|
||||
from starlette.responses import Response
|
||||
|
||||
from galaxy.exceptions import MessageException
|
||||
@@ -15,7 +13,7 @@ def add_exception_handler(
|
||||
) -> None:
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def exception_middleware(request: Request, exc: MessageException) -> Response:
|
||||
async def validate_exception_middleware(request: Request, exc: MessageException) -> Response:
|
||||
exc = validation_error_to_message_exception(exc)
|
||||
error_dict = api_error_message(None, exception=exc)
|
||||
return JSONResponse(
|
||||
@@ -24,7 +22,7 @@ def add_exception_handler(
|
||||
)
|
||||
|
||||
@app.exception_handler(MessageException)
|
||||
async def exception_middleware(request: Request, exc: MessageException) -> Response:
|
||||
async def message_exception_middleware(request: Request, exc: MessageException) -> Response:
|
||||
error_dict = api_error_message(None, exception=exc)
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import json
|
||||
|
||||
from galaxy.exceptions import error_codes
|
||||
from galaxy_test.base.api_asserts import (
|
||||
assert_error_code_is,
|
||||
|
||||
@@ -859,7 +859,6 @@ def launch_uvicorn_multi(kwargs, tempdir, prefix=DEFAULT_CONFIG_PREFIX, config_o
|
||||
def launch_uvicorn(gx_app, webapp_factory, kwargs, prefix=DEFAULT_CONFIG_PREFIX, config_object=None):
|
||||
name = prefix.lower()
|
||||
|
||||
from fastapi.middleware.wsgi import WSGIMiddleware
|
||||
host, port = explicitly_configured_host_and_port(prefix, config_object)
|
||||
|
||||
gx = webapp_factory(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from galaxy_main import (
|
||||
GalaxyConfigBuilder,
|
||||
main,
|
||||
|
||||
Reference in New Issue
Block a user