def __init__( self, name: str, module: str, parent: str, params: dict, inputs: Optional[Dict[str, str]] = None, storage: Optional[Storage] = None, ): """ :param name: Task name. :param module: Task module. :param parent: Parent task id. """ self.name = name self.module = module self.parent = parent self.params = params # inputs if not inputs: inputs = {} self.inputs = inputs # storage if not storage: _storage = get_available_storage() storage = _storage(bucket_name=self.parent, folder_name=self.name) self.storage = storage self.storage.setup() # logging self.logger = get_logger(__name__) self.logging_file = tempfile.NamedTemporaryFile(dir=storage.temp_dir)
def __init__( self, name: str, module: str, parent: str, params: dict, inputs: Optional[Dict[str, str]] = None, storage: Optional[Storage] = None, ): super().__init__(name, module, parent, params, inputs, storage) self.logger = get_logger(__name__, name=name)
def run_server(): logger = get_logger(__name__) logger.info( f"🚀 Deploying server at http://{settings.API_HOST}:{settings.API_PORT}" ) uvicorn.run( app, host=settings.API_HOST, port=settings.API_PORT, root_path=settings.ROOT_PATH, log_level="trace" if settings.API_DEBUG else "info", )
import os import shutil from abc import ABC, abstractmethod from pathlib import Path from typing import List, Optional, Union from pydantic import BaseModel, validator from drama.config import settings from drama.logger import get_logger logger = get_logger(__name__) class NotValidScheme(Exception): """ Raised when scheme is not present. """ pass class Resource(BaseModel): scheme: str = "" resource: str @validator("resource") def resource_must_have_scheme(cls, v, values, **kwargs): assert str(v).startswith(values.get("scheme", "")), "invalid resource" return v