async def get_memory_tracking(request: Request, session_uuid: str) -> Any: track_data = [] status_code = 404 ans = MemoryAnalysis.get_or_create(session_uuid) if ans: track_data = ans.get_tracking() status_code = 200 response = JSONResponse({'series': track_data, 'insights': []}) response.status_code = status_code return response
async def get_hyper_params_tracking(request: Request, run_uuid: str) -> Any: track_data = [] status_code = 404 ans = HyperParamsAnalysis.get_or_create(run_uuid) if ans: track_data = ans.get_tracking() status_code = 200 response = JSONResponse({'series': track_data, 'insights': []}) response.status_code = status_code return response
async def get_refresh_token(token: str = Depends(oauth2_scheme), auth_service: AuthService = Depends()): tokens = await auth_service.get_refresh_token(token) response = JSONResponse({ 'token_type': tokens.token_type, 'access_token': tokens.access_token }) response.set_cookie('refresh_token', tokens.refresh_token, max_age=settings.JWT_REFRESH_TOKEN_EXPIRES, httponly=True) response.status_code = status.HTTP_201_CREATED return response
async def get_zero_cpu_processes(request: Request, session_uuid: str) -> Any: track_data = [] status_code = 404 ans = ProcessAnalysis.get_or_create(session_uuid) if ans: track_data = ans.get_zero_cpu_processes() status_code = 200 response = JSONResponse({'series': track_data}) response.status_code = status_code return response
async def get_run_status(request: Request, run_uuid: str) -> JSONResponse: status_data = {} status_code = 404 s = run.get_status(run_uuid) if s: status_data = s.get_data() status_code = 200 response = JSONResponse(status_data) response.status_code = status_code return response
async def get_session(request: Request, session_uuid: str) -> JSONResponse: session_data = {} status_code = 404 c = session.get(session_uuid) if c: session_data = c.get_data(request) status_code = 200 response = JSONResponse(session_data) response.status_code = status_code return response
async def get_run(request: Request, run_uuid: str) -> JSONResponse: run_data = {} status_code = 404 r = run.get(run_uuid) if r: run_data = r.get_data(request) status_code = 200 response = JSONResponse(run_data) response.status_code = status_code return response
async def get_process_detail(request: Request, session_uuid: str, process_id: str) -> Any: data = {} status_code = 404 ans = ProcessAnalysis.get_or_create(session_uuid) if ans: data = ans.get_process(process_id) status_code = 200 response = JSONResponse(data) response.status_code = status_code return response
async def sign_up( user_data: schemas.UserCreate, auth_service: AuthService = Depends(), ): tokens = await auth_service.register_new_user(user_data) response = JSONResponse({ 'token_type': tokens.token_type, 'access_token': tokens.access_token }) response.set_cookie('refresh_token', tokens.refresh_token, max_age=settings.JWT_REFRESH_TOKEN_EXPIRES, httponly=True) response.status_code = status.HTTP_201_CREATED return response
async def wrapper(request: Request, *args, **kwargs): token_id = request.headers.get('Authorization', '') at = app_token.get_or_create(token_id) if not settings.IS_LOGIN_REQUIRED: at = _login_not_required() if at.is_auth: if inspect.iscoroutinefunction(func): return await func(request, *args, **kwargs) else: return func(request, *args, **kwargs) else: response = JSONResponse() response.status_code = 403 return response
async def get_process_tracking(request: Request, session_uuid: str) -> Any: track_data = [] summary_data = [] status_code = 404 ans = ProcessAnalysis.get_or_create(session_uuid) if ans: track_data, summary_data = ans.get_tracking() status_code = 200 response = JSONResponse({ 'series': track_data, 'insights': [], 'summary': summary_data }) response.status_code = status_code return response
async def get_modules_tracking(request: Request, run_uuid: str) -> Any: track_data = [] summary_data = [] status_code = 404 ans = OutputsAnalysis.get_or_create(run_uuid) if ans: track_data = ans.get_tracking() summary_data = ans.get_track_summaries() status_code = 200 response = JSONResponse({ 'series': track_data, 'insights': [], 'summary': summary_data }) response.status_code = status_code return response
async def login_token(credentials: HTTPBasicCredentials = Depends(security)): response = JSONResponse() response.content = {'token': 'apptoken'} response.status_code = check_credentials_and_return_status_code( credentials) response.set_cookie('token', 'apptoken')
async def fake_login(): tokens = await create_token({"key": "value"}) res = JSONResponse(tokens) res.status_code = 200 # res.set_cookie(, encoded_jwt, httponly=True) return res