refactor: standardize runtime annotation types across multiple files
This commit is contained in:
@@ -9,11 +9,11 @@ from pathlib import Path
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app.main import app # noqa: E402
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Generate `openapi.json` from the FastAPI app definition."""
|
||||
from app.main import app
|
||||
|
||||
# Importing the FastAPI app does not run lifespan hooks,
|
||||
# so this does not require a DB.
|
||||
out_path = BACKEND_ROOT / "openapi.json"
|
||||
|
||||
@@ -10,15 +10,15 @@ from uuid import uuid4
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app.db.session import async_session_maker, init_db # noqa: E402
|
||||
from app.models.agents import Agent # noqa: E402
|
||||
from app.models.boards import Board # noqa: E402
|
||||
from app.models.gateways import Gateway # noqa: E402
|
||||
from app.models.users import User # noqa: E402
|
||||
|
||||
|
||||
async def run() -> None:
|
||||
"""Populate the local database with a demo gateway, board, user, and agent."""
|
||||
from app.db.session import async_session_maker, init_db
|
||||
from app.models.agents import Agent
|
||||
from app.models.boards import Board
|
||||
from app.models.gateways import Gateway
|
||||
from app.models.users import User
|
||||
|
||||
await init_db()
|
||||
async with async_session_maker() as session:
|
||||
demo_workspace_root = BACKEND_ROOT / ".tmp" / "openclaw-demo"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# ruff: noqa: INP001
|
||||
"""CLI script to sync template files into gateway agent workspaces."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,10 +11,6 @@ from uuid import UUID
|
||||
BACKEND_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(BACKEND_ROOT))
|
||||
|
||||
from app.db.session import async_session_maker # noqa: E402
|
||||
from app.models.gateways import Gateway # noqa: E402
|
||||
from app.services.template_sync import sync_gateway_templates # noqa: E402
|
||||
|
||||
|
||||
def _parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -59,6 +54,13 @@ def _parse_args() -> argparse.Namespace:
|
||||
|
||||
|
||||
async def _run() -> int:
|
||||
from app.db.session import async_session_maker
|
||||
from app.models.gateways import Gateway
|
||||
from app.services.template_sync import (
|
||||
GatewayTemplateSyncOptions,
|
||||
sync_gateway_templates,
|
||||
)
|
||||
|
||||
args = _parse_args()
|
||||
gateway_id = UUID(args.gateway_id)
|
||||
board_id = UUID(args.board_id) if args.board_id else None
|
||||
@@ -72,12 +74,14 @@ async def _run() -> int:
|
||||
result = await sync_gateway_templates(
|
||||
session,
|
||||
gateway,
|
||||
user=None,
|
||||
include_main=bool(args.include_main),
|
||||
reset_sessions=bool(args.reset_sessions),
|
||||
rotate_tokens=bool(args.rotate_tokens),
|
||||
force_bootstrap=bool(args.force_bootstrap),
|
||||
board_id=board_id,
|
||||
options=GatewayTemplateSyncOptions(
|
||||
user=None,
|
||||
include_main=bool(args.include_main),
|
||||
reset_sessions=bool(args.reset_sessions),
|
||||
rotate_tokens=bool(args.rotate_tokens),
|
||||
force_bootstrap=bool(args.force_bootstrap),
|
||||
board_id=board_id,
|
||||
),
|
||||
)
|
||||
|
||||
sys.stdout.write(f"gateway_id={result.gateway_id}\n")
|
||||
|
||||
Reference in New Issue
Block a user