def init_app(): global _db, _logs_dir, _k8s, _scheduler logger.info('configuration dump\n%s', config.dump_yaml()) if config.httpdb.db_type == 'sqldb': logger.info('using SQLDB') _db = SQLDB(config.httpdb.dsn) else: logger.info('using FileRunDB') _db = FileRunDB(config.httpdb.dirpath) _db.connect() _logs_dir = Path(config.httpdb.logs_path) try: _k8s = K8sHelper() except Exception: pass # @yaronha - Initialize here task = periodic.Task() periodic.schedule(task, 60) _scheduler = Scheduler() for data in _db.list_schedules(): if 'schedule' not in data: logger.warning('bad scheduler data - %s', data) continue _submit(data)
async def startup_event(): logger.info("configuration dump", dumped_config=config.dump_yaml()) await _initialize_singletons() # periodic cleanup is not needed if we're not inside kubernetes cluster if get_k8s_helper(silent=True).is_running_inside_kubernetes_cluster(): _start_periodic_cleanup() _start_periodic_runs_monitoring()
async def startup_event(): logger.info("configuration dump\n%s", config.dump_yaml()) initialize_singletons() task = periodic.Task() periodic.schedule(task, 60) _reschedule_tasks() _start_periodic_cleanup()
def main(): global _file_db from mlrun.config import config logger.info('configuration dump\n%s', config.dump_yaml()) _file_db = FileRunDB(config.httpdb.dirpath, '.yaml') _file_db.connect() app.run( host='0.0.0.0', port=config.httpdb.port, debug=config.httpdb.debug, )
async def startup_event(): logger.info("configuration dump\n%s", config.dump_yaml()) initialize_singletons() # don't fail the app on re-scheduling failure try: task = periodic.Task() periodic.schedule(task, 60) _reschedule_tasks() except Exception as exc: logger.warning(f'Failed rescheduling tasks, err: {exc}') _start_periodic_cleanup()
async def startup_event(): logger.info("configuration dump", dumped_config=config.dump_yaml()) loop = asyncio.get_running_loop() # Using python 3.8 default instead of 3.7 one - max(1, os.cpu_count()) * 5 cause it's causing to high memory # consumption - https://bugs.python.org/issue35279 # TODO: remove when moving to python 3.8 max_workers = config.httpdb.max_workers or min(32, os.cpu_count() + 4) loop.set_default_executor( concurrent.futures.ThreadPoolExecutor(max_workers=max_workers)) await _initialize_singletons() # periodic cleanup is not needed if we're not inside kubernetes cluster if get_k8s_helper(silent=True).is_running_inside_kubernetes_cluster(): _start_periodic_cleanup() _start_periodic_runs_monitoring()
async def startup_event(): logger.info( "configuration dump", dumped_config=config.dump_yaml(), version=mlrun.utils.version.Version().get(), ) loop = asyncio.get_running_loop() # Using python 3.8 default instead of 3.7 one - max(1, os.cpu_count()) * 5 cause it's causing to high memory # consumption - https://bugs.python.org/issue35279 # TODO: remove when moving to python 3.8 max_workers = config.httpdb.max_workers or min(32, os.cpu_count() + 4) loop.set_default_executor( concurrent.futures.ThreadPoolExecutor(max_workers=max_workers)) initialize_logs_dir() initialize_db() if config.httpdb.state == mlrun.api.schemas.APIStates.online: await move_api_to_online()