-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ensure_package_and_question_state_exist
- Loading branch information
Showing
18 changed files
with
372 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
__version__ = "0.1.0" | ||
|
||
# This file is part of the QuestionPy Server. (https://questionpy.org) | ||
# The QuestionPy Server is free software released under terms of the MIT license. See LICENSE.md. | ||
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
|
||
from questionpy_server.worker.pool import WorkerPool | ||
|
||
__all__ = ["WorkerPool"] | ||
__version__ = "0.1.0" | ||
|
||
__all__ = ["WorkerPool", "__version__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,20 @@ | |
# The QuestionPy Server is free software released under terms of the MIT license. See LICENSE.md. | ||
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from aiohttp import web | ||
|
||
from questionpy_server import __version__ | ||
from questionpy_server.api.models import ServerStatus, Usage | ||
from questionpy_server.app import QPyServer | ||
from questionpy_server.web import json_response | ||
|
||
if TYPE_CHECKING: | ||
from questionpy_server.app import QPyServer | ||
|
||
|
||
status_routes = web.RouteTableDef() | ||
|
||
|
||
@status_routes.get(r"/status") | ||
async def get_server_status(request: web.Request) -> web.Response: | ||
"""Get server status.""" | ||
qpyserver: QPyServer = request.app["qpy_server_app"] | ||
qpyserver = request.app[QPyServer.APP_KEY] | ||
status = ServerStatus( | ||
version=__version__, | ||
allow_lms_packages=qpyserver.settings.webservice.allow_lms_packages, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,24 +3,28 @@ | |
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
|
||
from asyncio import create_task | ||
from typing import Any | ||
from typing import Any, ClassVar | ||
|
||
from aiohttp import web | ||
|
||
from . import __version__ | ||
from .api.routes import routes | ||
from .cache import FileLimitLRU | ||
from .collector import PackageCollection | ||
from .settings import Settings | ||
from .worker.pool import WorkerPool | ||
|
||
|
||
class QPyServer: | ||
class QPyServer(web.AppKey["QPyServer"]): | ||
APP_KEY: ClassVar[web.AppKey["QPyServer"]] = web.AppKey("qpy_server_app") | ||
|
||
def __init__(self, settings: Settings): | ||
# We import here, so we don't have to work around circular imports. | ||
from .api.routes import routes # noqa: PLC0415 | ||
|
||
self.settings: Settings = settings | ||
self.web_app = web.Application(client_max_size=settings.webservice.max_main_size) | ||
self.web_app.add_routes(routes) | ||
self.web_app["qpy_server_app"] = self | ||
self.web_app[self.APP_KEY] = self | ||
|
||
self.worker_pool = WorkerPool( | ||
settings.worker.max_workers, settings.worker.max_memory, worker_type=settings.worker.type | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# The QuestionPy Server is free software released under terms of the MIT license. See LICENSE.md. | ||
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
|
||
from questionpy_server.collector.package_collection import PackageCollection | ||
from questionpy_server.collector._package_collection import PackageCollection | ||
|
||
__all__ = [ | ||
"PackageCollection", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.