def main(config_file_path: str) -> None: """Main procedure. Instantiates the monitor class and then runs forever. Args: config_file_path: The path to the configuration file. """ v = System.get_openadms_version() logger = logging.getLogger('openadms') logger.debug(f'+-----------------------------------------------+') logger.debug(f'| _____ _____ ____ _____ _____ |') logger.debug(f'| | |___ ___ ___| _ | \| | __| |') logger.debug(f'| | | | . | -_| | | | | | | |__ | |') logger.debug(f'| |_____| _|___|_|_|__|__|____/|_|_|_|_____| |') logger.debug(f'| |_| Node v.{v} |') logger.debug(f'| |') logger.debug(f'| Copyright (c) 2018, Hochschule Neubrandenburg |') logger.debug(f'| Distributed under the BSD-2-Clause licence. |') logger.debug(f'+-----------------------------------------------+') # Start the monitoring. global monitor monitor = Monitor(config_file_path) monitor.start() # Run to infinity and beyond (probably not). stay_alive()
def main(): logging.basicConfig(filename=CONFIG['logging']['logfile'], filemode="a", level=CONFIG['logging']['loglevel'], format=CONFIG['logging']['format']) logger = logging.getLogger("elasticsearch-suggester") monitors = [] while True: # Make Elasticsearch Monitor for cluster in CONFIG['clusters']: if not _is_already_started_process(cluster['url'], monitors): monitor = Monitor( cluster, logger, CONFIG['application']['invoke_hour'], CONFIG['application']['query_interval'] ) monitor.start() monitors.append(monitor) logger.info("start to monitor {cluster}".format(cluster=cluster)) time.sleep(1)
class Engine(): def __init__(self): self.logger = get_logger('Core', True) # core moudles share the same logger self.Scheduler = Scheduler(self.logger) self.Downloader = Downloader(self.logger) self.Uploader = Uploader(self.logger) self.Monitor = Monitor(self.logger) def _do_register(self): user = GlobalConfig.Deploy_dict['user'] password = GlobalConfig.Deploy_dict['password'] self.logger.info('registering START: %s' % user) RegisterSuccess = do_register(user, password, self.logger) self.logger.info('registering END: %s' % str(RegisterSuccess)) return RegisterSuccess def start(self): if self._do_register(): self.logger.info('---engine START---') self.Scheduler.start_threads() self.Monitor.start_threads() self.Downloader.start_threads( ) # Downloader uses spiders which uses Status, so Monitor should run in front self.Uploader.start_threads() else: self.logger.info('---engine START failed---') def stop(self): pass
def __init__(self): self.logger = get_logger('Core', True) # core moudles share the same logger self.Scheduler = Scheduler(self.logger) self.Downloader = Downloader(self.logger) self.Uploader = Uploader(self.logger) self.Monitor = Monitor(self.logger)
def __init__(self, env, cluster, task_broker, scheduler, event_file): self.env = env self.cluster = cluster self.task_broker = task_broker self.scheduler = scheduler self.event_file = event_file if event_file is not None: self.monitor = Monitor(self) self.task_broker.attach(self) self.scheduler.attach(self)
def make_mujoco_env(env_id, seed, allow_early_resets=True): """ Create a wrapped, monitored gym.Env for MuJoCo. :param env_id: (str) the environment ID :param seed: (int) the initial seed for RNG :param allow_early_resets: (bool) allows early reset of the environment :return: (Gym Environment) The mujoco environment """ set_global_seeds(seed + 10000 * mpi_rank_or_zero()) env = gym.make(env_id) env = Monitor(env, os.path.join(logger.get_dir(), '0'), allow_early_resets=allow_early_resets) env.seed(seed) return env
class Simulation(object): def __init__(self, env, cluster, task_broker, scheduler, event_file): self.env = env self.cluster = cluster self.task_broker = task_broker self.scheduler = scheduler self.event_file = event_file if event_file is not None: self.monitor = Monitor(self) self.task_broker.attach(self) self.scheduler.attach(self) def run(self): # Starting monitor process before task_broker process # and scheduler process is necessary for log records integrity. if self.event_file is not None: self.env.process(self.monitor.run()) self.env.process(self.task_broker.run()) self.env.process(self.scheduler.run()) @property def finished(self): return self.task_broker.destroyed \ and len(self.cluster.unfinished_jobs) == 0
def _thunk(): env = make_atari(env_id) env.seed(seed + rank) env = Monitor(env, logger.get_dir() and os.path.join(logger.get_dir(), str(rank)), allow_early_resets=allow_early_resets) return wrap_deepmind(env, **wrapper_kwargs)
def cmd_main(siteName): site_config = CONFIG[siteName] website_path = site_config['website_path'] backup_path = site_config['web_backup_path'] mail_receivers = site_config['mail_receivers'].split() monitor_pages = site_config['monitor_pages'] page_suffix = site_config['monitor_suffix'].split() interval = site_config.getint('email_frequency') auto_cure = site_config.getboolean('auto_cure') history_file = "./snapshoot/history/%s" % siteName if not os.path.exists(history_file): build_fingerprint_lib(website_path, siteName) open(history_file, 'wb').close() web_monitor = Monitor(website_path, backup_path, mail_receivers, page_suffix, interval, auto_cure) web_monitor.start_monitor()
def __init__(self, start_monitor=True): self.init() self.number_dict = {core.constant.TOTAL_TASK: 0, core.constant.TOTAL_REQUEST: 0, core.constant.TOTAL_RESPONSE: 0} self.color = core.constant.COLOR self.close = False self.loop = asyncio.get_event_loop() self.filter = core.bloomFilter.bloomFilterContext.get_filter(settings.PROJECT_NAME) self.scheduler = Scheduler(self) self.downloader = Downloader(self, settings.DOWNLOADER_WORKER) self.save = Save(self, settings.SAVE_WORKER) self.monitor = Monitor(self) self.start_monitor = start_monitor
def _thunk(): import vizdoomgym env = make_doom(env_id, episode_life=False, clip_rewards=False, frame_stack=True, scale=False, fire=False) env.seed(seed + rank) env = Monitor(env, filename=monitor_path, allow_early_resets=allow_early_resets) return env
def _init(): if isinstance(env_id, str): env = gym.make(env_id) if len(env_kwargs) > 0: warnings.warn( "No environment class was passed (only an env ID) so `env_kwargs` will be ignored" ) else: env = env_id(**env_kwargs) if seed is not None: env.seed(seed + rank) env.action_space.seed(seed + rank) # Wrap the env in a Monitor wrapper # to have additional training information monitor_path = os.path.join( monitor_dir, str(rank)) if monitor_dir is not None else None # Create the monitor folder if needed if monitor_path is not None: os.makedirs(monitor_dir, exist_ok=True) env = Monitor(env, filename=monitor_path) # Optionally, wrap the environment with the provided wrapper if wrapper_class is not None: env = wrapper_class(env) return env
duration = float(raw_input('Enter duration of experiment in seconds:')) except: pass dirr = os.path.join(dirr,name) side = None while side not in ['l','r']: side = raw_input('Enter correct side (l/r):').lower() raw_input('Hit Enter to acquire baseline.') cam = Camera(0, frame_rate=30, resolution=(640,480), color_mode=BW) for _ in xrange(40): cam.read() #baseline mon = Monitor(cam, show=True, run_name=name+'_BL', duration=15., dirr=dirr) mon.go() _ = raw_input('Hit enter to start recording.') i = 1 cont = True while cont!='q': #test mon = Monitor(cam, show=True, run_name=name+"_%02d_"%i, duration=duration, dirr=dirr, extra={'side':side}) mon.go() cont = raw_input('Run again? (Hit enter to run, type \'q\' + Enter to quit.)') i+=1 cam.release()
def monitorStart(): specID = "purchasingAtBuyer" monitor = Monitor() monitor.start(specID)
pass dirr = os.path.join(dirr, name) side = None while side not in ['l', 'r']: side = raw_input('Enter correct side (l/r):').lower() raw_input('Hit Enter to acquire baseline.') cam = Camera(0, frame_rate=30, resolution=(640, 480), color_mode=BW) for _ in xrange(40): cam.read() #baseline mon = Monitor(cam, show=True, run_name=name + '_BL', duration=15., dirr=dirr) mon.go() _ = raw_input('Hit enter to start recording.') i = 1 cont = True while cont != 'q': #test mon = Monitor(cam, show=True, run_name=name + "_%02d_" % i, duration=duration, dirr=dirr,
from core.monitor import Monitor from core.cameras import Camera, BW, COLOR import numpy as np import os import sys import time if __name__=='__main__': name = None while name==None or name in os.listdir('.'): name = raw_input('Enter name of experiment (will default to date string):') if name in os.listdir('.'): print "Experiment file with this name already exists." duration = None while type(duration) != float: try: duration = float(raw_input('Enter duration of experiment in seconds:')) except: pass dirr = os.path.join('data',name) #baseline cam = Camera(0, frame_rate=50, resolution=(640,480), color_mode=BW) mon = Monitor(cam, show=True, run_name=name, duration=duration, dirr=dirr) mon.go() cam.release()
UpdateStrategies_thread.start() def start_threads(self): # entrence self.start_next_tasks_thread() self.start_update_strategies_thread( ) # the initial strategies is loaded when instantiate the Scheduler if __name__ == '__main__': # start server_service firstly SchedulerIns = Scheduler() SchedulerIns.start_threads() from core.monitor import Monitor MonitorIns = Monitor() MonitorIns.start_threads() from core.downloader import Downloader DownloaderIns = Downloader() DownloaderIns.start_threads() from core.uploader import Uploader UploaderIns = Uploader() UploaderIns.start_threads() while True: sleep(10) print GlobalQueues.UploadResults_queue.qsize()