示例#1
0
from fastapi import APIRouter, HTTPException
from typing import Dict
from domain.models.api_response import ApiResponse
from domain.models.configuration_content import ConfigurationContent
from domain.models.hyper_parameter_information import HyperParameterInformation
from containers import Services
from domain.models.network_information import NetworkInformation
from domain.exceptions.application_error import ApplicationError
from application.configuration.services.configuration_factory import ConfigurationFactory

configuration_service = Services.configuration_service()
configuration_content_service = Services.configuration_content_service()
configuration_writer_service = Services.configuration_writer_service()
router = APIRouter()
"""
Get the default configuration  content with number of classes generated 
Parameters
----------
network_info: NetworkInformation
                object of type NetworkInformation containing the network architecture name 

Returns
-------
Dict
    Configuration content
"""


@router.post('/default')
async def get_configuration_content(network_info: NetworkInformation):
    try:
from fastapi import APIRouter, HTTPException

from containers import Services
from domain.exceptions.application_error import ApplicationError
from domain.models.api_response import ApiResponse
from domain.models.container_info import ContainerInfo

router = APIRouter()

tensorboard_service = Services.tensorboard_service()
tensorboard_refresh_service = Services.tensorboard_refresh_service()
"""
Refresh the tensorboard of certain container

Parameters
----------
container_info: ContainerInfo
             object of type ContainerInfo containing the container's name

Returns
-------
ApiResponse
        Success Message
"""


@router.post('/refresh')
async def refresh_tensorboard(container_info: ContainerInfo):
    try:
        tensorboard_refresh_service.tensorboard_refresh(container_info)
        return ApiResponse(success=True)
示例#3
0
文件: blueping.py 项目: HF0/blueping
fileHandler.setFormatter(logFormatter)
Core.logger().addHandler(fileHandler)

# configure presence logger
Core.presence_logger().setLevel(logging.INFO)
presenceFileHandler = logging.FileHandler(Core.config.presence.filename())
presenceFileHandler.setFormatter(logFormatter)
Core.presence_logger().addHandler(presenceFileHandler)

# scan identities from bluetooth
Services.identity_scanner.override(
    providers.Singleton(BluetoothTinySineScanner,
                        logger=Core.logger(),
                        port=Core.config.bluetoothtinysinescanner.port,
                        baudrate=Core.config.bluetoothtinysinescanner.baudrate,
                        serial_timeout_seconds=Core.config.
                        bluetoothtinysinescanner.serial_timeout_seconds))

try:

    while True:

        identities = Services.identity_scanner().scan()
        Services.presence_processor().process_scan(identities,
                                                   Core.config.target())
        time.sleep(Core.config.period())

except Exception as e:
    Core.logger().debug("Error:" + str(e))
    traceback.print_exc(file=sys.stdout)
示例#4
0
from fastapi import APIRouter, HTTPException

from application.infrastructure.services.gpu_service import GpuService
from application.infrastructure.services.port_scanner_service import PortScannerService
from containers import Services
from domain.exceptions.application_error import ApplicationError
from domain.models.container_info import ContainerInfo

tensorboard_port_service = Services.tensorboard_port_scanner_service()
router = APIRouter()
"""
Gets the available gpus.

Returns
-------
list of str
    a list of gpu names wuth less than 25% memory consumption

"""


@router.get("/gpu/info")
async def get_gpu_info():
    try:
        return GpuService().get_gpu_info()
    except ApplicationError as e:
        raise HTTPException(status_code=400, detail=e.__str__())
    except Exception as e:
        raise HTTPException(status_code=500, detail=e.__str__())

示例#5
0
from fastapi import APIRouter, HTTPException
from containers import Services
from domain.models.api_response import ApiResponse
from domain.models.dataset_name import DatasetName
from domain.models.dataset_info import DatasetInfo
from domain.exceptions.application_error import ApplicationError

dataset_service = Services.dataset_service()
dataset_validator_service = Services.dataset_validator_service()
dataset_label_type_service = Services.dataset_label_type_service()

router = APIRouter()
"""
Get all datasets

Returns
-------
list of str
    datasets
"""


@router.get("/")
async def get_datasets():
    try:
        return dataset_service.get_datasets()
    except ApplicationError as e:
        raise HTTPException(status_code=400, detail=e.__str__())
    except Exception as e:
        raise HTTPException(status_code=500, detail=e.__str__())
from fastapi import APIRouter, HTTPException

from containers import Services
from domain.exceptions.application_error import ApplicationError
from domain.models.api_response import ApiResponse
from domain.models.container_info import ContainerInfo
from domain.models.container_settings import ContainerSettings

router = APIRouter()
job_management_service = Services.job_management_service()
job_utility_service = Services.job_utility_service()
"""
Starts a job

Parameters
----------
containerSettings: ContainerSettings
                   object of type ContainerSettings containing all the necessary info to start a job
Returns
-------
str
    Success Message
"""


@router.post("/start")
async def start_container(container_settings: ContainerSettings):
    try:
        job_management_service.start_container(
            container_settings=container_settings)
        return ApiResponse(success=True, data="Container Started")
from fastapi import APIRouter, HTTPException

from containers import Services
from domain.exceptions.application_error import ApplicationError
from domain.models.api_response import ApiResponse
from domain.models.network_info import NetworkInfo

router = APIRouter()

models_architecture_service = Services.models_architecture_service()
checkpoint_service = Services.checkpoint_service()
download_models_service = Services.download_models_service()
"""
Get all models architectures

Returns
-------
list of str
    models architectures
"""


@router.get("/architecture")
async def get_all_architecture():
    try:
        return models_architecture_service.get_architecture()
    except ApplicationError as e:
        raise HTTPException(status_code=400, detail=e.__str__())
    except Exception as e:
        raise HTTPException(status_code=500, detail=e.__str__())
示例#8
0
from fastapi import APIRouter, HTTPException, BackgroundTasks
from domain.models.hyper_parameter_information import HyperParameterInformation
from containers import Services, Manager
from domain.models.network_information import NetworkInformation
from domain.exceptions.application_error import ApplicationError
from domain.models.api_response import ApiResponse
import threading

model_trainer_service = Services.model_trainer_service()
tensorboard_service = Services.tensorboard_service()
export_manager = Manager.export_manager()
train_eval_continuously_manager = Manager.train_eval_continuously_manager()
router = APIRouter()
"""
Starts the training in the background and export the resulting model

Parameters
----------
hyper_params: HyperParameterInformation
                object of type HyperParameterInformation containing the hyper parameters for the training

Returns
-------
str
    Success Message
"""


@router.post('/')
async def start_training(hyper_params: HyperParameterInformation,
                         background_tasks: BackgroundTasks):
示例#9
0
from fastapi import APIRouter, HTTPException
from containers import Services
from domain.exceptions.application_error import ApplicationError
from domain.models.api_response import ApiResponse

router = APIRouter()

tensorboard_service = Services.tensorboard_service()
"""
Refresh the tensorboard 


Returns
-------
ApiResponse
        Success Message
"""


@router.get('/refresh')
async def refresh_tensorboard():
    try:
        tensorboard_service.tensorboard_stop()
        tensorboard_service.tensorboard_start()
        return ApiResponse(success=True)
    except ApplicationError as e:
        raise HTTPException(status_code=400, detail=e.__str__())
    except Exception as e:
        raise HTTPException(status_code=500, detail=e.__str__())