def __init__( self, username: str = Form(...), password: str = Form(...), ): self.username = username self.password = password
def __init__( self, grant_type: str = Form(None), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): self.grant_type = grant_type self.scopes = scope.split() self.client_id = client_id self.client_secret = client_secret
def __init__( self, grant_type: str = Form( None, regex="^(client_credentials|refresh_token)$"), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): self.grant_type = grant_type self.scopes = scope.split() self.client_id = client_id self.client_secret = client_secret
async def create_token_files(ttl: int = Form(...), links_number: int = Form(...), file: UploadFile = File(...)): meta = {'filename': file.filename} content = await file.read() tokens, used = token_handler.set_bytes( content, ttl, nb_tokens=links_number, expires=ttl != 0, meta=meta, ) return { 'tokens': tokens, 'used': used, }
def __init__( self, username: str = Form(..., max_length=MAX_LENGTH_USERNAME), password: str = Form(..., max_length=MAX_LENGTH_PASSWORD) ): """ 初期処理 Args: username (str): ・ユーザー名 ・必須パラメータ password (str): ・パスワード ・必須パラメータ """ self.username = username self.password = password
def __init__( self, grant_type: str = Form(None, regex="password"), username: str = Form(...), password: str = Form(...), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): self.grant_type = grant_type self.username = username self.password = password self.scopes = scope.split() self.client_id = client_id self.client_secret = client_secret
def __init__( self, email: str = Form(...), password: str = Form(...), re_password: str = Form(...), first_name: Optional[str] = Form(None), last_name: Optional[str] = Form(None), phone: Optional[str] = Form(None), ): self.email = email self.password = password self.re_password = re_password self.first_name = first_name self.last_name = last_name self.phone = phone
def __init__( self, grant_type: str = Form(..., regex="password"), username: str = Form(...), password: str = Form(...), scope: str = Form(""), client_id: Optional[str] = Form(None), client_secret: Optional[str] = Form(None), ): super().__init__( grant_type=grant_type, username=username, password=password, scope=scope, client_id=client_id, client_secret=client_secret, )
async def run_inference(task: Task, background_tasks: BackgroundTasks, id: int = Form(...), file: UploadFile = File(...), user_data: dict = Depends(get_current_user), db: Session = Depends(get_db)): username = user_data['username'] network: Network = await networkRepository.get_network_by_id(db, network_id=id) user: User = await userRepository.get_by_username(db, username) if network is None: raise HTTPException( status_code=400, detail="The requested model is no longer available!") if network.owner_id != user.id and not network.public_access: raise HTTPException(status_code=401, detail="User does not have access to this model") if network.task != task: raise HTTPException( status_code=400, detail= f"You have requested for {task} to be run, but the selected model is for {network.task}!" ) known_classes: List[str] = list(set(network.known_classes.split(","))) engine.set_classes(known_classes) image = await img_util.decode(file) output_image = engine.run(image, task) result = await img_util.encode(output_image, file.content_type) background_tasks.add_task(img_util.store_file_and_metadata, [file], user.id, db) return StreamingResponse(io.BytesIO(result.tobytes()), media_type=file.content_type)