fix: fetch dataset scope options from WorldQuant platform
This commit is contained in:
@@ -7,7 +7,6 @@ from fastapi import APIRouter, Depends, Query, Request
|
||||
from ..schemas import JobOutput
|
||||
from ..security import require_auth
|
||||
from .contracts import (
|
||||
UNIVERSES,
|
||||
CatalogFilters,
|
||||
CatalogJobInput,
|
||||
CatalogPage,
|
||||
@@ -19,14 +18,15 @@ from .contracts import (
|
||||
NoteOutput,
|
||||
Scope,
|
||||
)
|
||||
from .platform import platform_options, validate_platform_scope
|
||||
from .service import Catalog
|
||||
|
||||
router = APIRouter(prefix="/api/v1/catalog", tags=["catalog"], dependencies=[Depends(require_auth)])
|
||||
|
||||
|
||||
@router.get("/scopes")
|
||||
async def scopes() -> dict[str, list[str]]:
|
||||
return UNIVERSES
|
||||
async def scopes(request: Request):
|
||||
return await platform_options(request.app.state.runner.client)
|
||||
|
||||
|
||||
@router.get("/datasets", response_model=CatalogPage)
|
||||
@@ -69,6 +69,7 @@ async def field_note(
|
||||
|
||||
@router.post("/sync-jobs", status_code=202, response_model=JobOutput)
|
||||
async def sync(request: Request, body: CatalogJobInput):
|
||||
await validate_platform_scope(request.app.state.runner.client, body.scope)
|
||||
async with request.app.state.sessions.begin() as db:
|
||||
result = await Catalog(db).create_job(body)
|
||||
request.app.state.runner.wake.set()
|
||||
|
||||
Reference in New Issue
Block a user