Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hyperforge/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
"lru-dict",
"sentry_sdk",
"fastapi",
"starlette>1.0.0",
]


Expand Down
11 changes: 8 additions & 3 deletions hyperforge/src/hyperforge/api/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from contextlib import asynccontextmanager
from typing import Any, Optional, Tuple

import prometheus_client # type: ignore
Expand Down Expand Up @@ -62,7 +63,13 @@ def __init__(
*args,
**kwargs,
):
super().__init__(*args, **kwargs)
@asynccontextmanager
async def lifespan(app: "HTTPApplication"):
await app.startup()
yield
await app.shutdown()

super().__init__(*args, lifespan=lifespan, **kwargs)
self.settings = settings
self.data_manager_settings = data_manager_settings
self.include_router(internal.router)
Expand All @@ -76,8 +83,6 @@ def __init__(
if self.extra_middlewares is not None:
for extra_middleware in self.extra_middlewares:
self.add_middleware(extra_middleware)
self.add_event_handler("startup", self.startup)
self.add_event_handler("shutdown", self.shutdown)

async def startup(self) -> None:
GLOBAL_REGISTRY.clear()
Expand Down
2 changes: 1 addition & 1 deletion hyperforge/src/hyperforge/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
drop_database,
)

import hyperforge # noqa: F401
from hyperforge.api.app import HTTPApplication
from hyperforge.api.settings import Settings
from hyperforge.broker.redis import RedisBroker
Expand All @@ -43,7 +44,6 @@
from hyperforge.server.session import SessionManager
from hyperforge.server.settings import Settings as ServerSettings
from hyperforge.utils.http import SafeTransport
import hyperforge # noqa: F401

_package_path = pathlib.Path(hyperforge.__file__).parent.absolute()

Expand Down
12 changes: 9 additions & 3 deletions hyperforge/src/hyperforge/standalone/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
NucliaDB required.
"""

from contextlib import asynccontextmanager
from pathlib import Path
from typing import Any, Tuple

Expand Down Expand Up @@ -137,9 +138,17 @@ def __init__(
settings: StandaloneSettings,
**kwargs: Any,
) -> None:

@asynccontextmanager
async def lifespan(app: "StandaloneApplication"):
await app._startup()
yield
await app._shutdown()

super().__init__(
title="arag standalone",
description="Single-process agent RAG — interaction and MCP only",
lifespan=lifespan,
**kwargs,
)
self._agents_cfg = agents_cfg
Expand Down Expand Up @@ -173,9 +182,6 @@ def __init__(
allow_headers=["*"],
)

self.add_event_handler("startup", self._startup)
self.add_event_handler("shutdown", self._shutdown)

# ------------------------------------------------------------------
# Property used by interaction.py / oauth.py to read answers_subject
# and oauth_subject without knowing about StandaloneSettings.
Expand Down
8 changes: 5 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading