Пример #1
0
def initial_startup():
    """
    Calls the init() method in the model and prepares the model to receive predictions. The init
    task may take a long time to complete, so the settings field ready_to_predict will be updated
    asynchronously when init() completes. This will also begin the background registration task
    to the server.

    :return: {"status": "success"} upon startup completion. No guarantee that init() is done processing.
    """
    # Run startup task async
    load_dotenv()

    # Register the model to the server in a separate thread to avoid meddling with
    # initializing the service which might be used directly by other client later on
    # We will only run the registration once the model init is complete.
    def init_model_helper():
        logger.debug('Beginning Model Initialization Process.')
        init()
        model_settings.ready_to_predict = True
        logger.debug('Finishing Model Initialization Process.')
        pool.submit(register_model_to_server, os.getenv('SERVER_PORT'),
                    os.getenv('PORT'), os.getenv('NAME'))

    pool.submit(init_model_helper)
    return {"status": "success", 'detail': 'server startup in progress'}
Пример #2
0
 def init_model_helper():
     logger.debug('Beginning Model Initialization Process.')
     init()
     model_settings.ready_to_predict = True
     logger.debug('Finishing Model Initialization Process.')
     pool.submit(register_model_to_server, os.getenv('SERVER_PORT'),
                 os.getenv('PORT'), os.getenv('NAME'))
Пример #3
0
 def init_dataset_helper():
     logger.debug('Beginning Dataset Initialization Process.')
     setup_dataset()
     dataset_settings.ready_to_train = True
     logger.debug('Finishing Dataset Initialization Process.')
     pool.submit(register_model_to_server, os.getenv('SERVER_PORT'),
                 os.getenv('PORT'), os.getenv('DATASET_NAME'))