def create_timeline_plots(self, dst, name, run_statuses=None, invoke_statuses=None): """ Creates timeline and histogram of the current execution in dst. :param dst: destination folder to save .png plots. :param name: name of the file. :param run_statuses: run statuses timestamps. :param invoke_statuses: invocation statuses timestamps. """ from pywren_ibm_cloud.plots import create_timeline, create_histogram if self.futures and not run_statuses and not invoke_statuses: run_statuses = [f.run_status for f in self.futures] invoke_statuses = [f.invoke_status for f in self.futures] if not run_statuses and not invoke_statuses: raise Exception( 'You must provide run_statuses and invoke_statuses') create_timeline(dst, name, run_statuses, invoke_statuses) create_histogram(dst, name, run_statuses, x_lim=150)
def create_execution_plots(self, dst_dir, dst_file_name, fs=None): """ Creates timeline and histogram of the current execution in dst_dir. :param dst_dir: destination folder to save .png plots. :param dst_file_name: prefix name of the file. :param fs: list of futures. """ ftrs = self.futures if not fs else fs if type(ftrs) != list: ftrs = [ftrs] ftrs_to_plot = [f for f in ftrs if f.ready or f.done] if not ftrs_to_plot: logger.debug('ExecutorID {} - No futures ready to plot'.format( self.executor_id)) return logging.getLogger('matplotlib').setLevel(logging.WARNING) from pywren_ibm_cloud.plots import create_timeline, create_histogram msg = 'ExecutorID {} - Creating execution plots'.format( self.executor_id) logger.info(msg) if not self.log_level: print(msg) call_status = [f._call_status for f in ftrs_to_plot] call_metadata = [f._call_metadata for f in ftrs_to_plot] create_timeline(dst_dir, dst_file_name, self.start_time, call_status, call_metadata, self.config['ibm_cos']) create_histogram(dst_dir, dst_file_name, self.start_time, call_status, self.config['ibm_cos'])
def plot(self, fs=None, dst=None): """ Creates timeline and histogram of the current execution in dst_dir. :param dst_dir: destination folder to save .png plots. :param dst_file_name: prefix name of the file. :param fs: list of futures. """ ftrs = self.futures if not fs else fs if type(ftrs) != list: ftrs = [ftrs] ftrs_to_plot = [f for f in ftrs if (f.ready or f.done) and not f.error] if not ftrs_to_plot: logger.debug('ExecutorID {} - No futures ready to plot'.format(self.executor_id)) return logging.getLogger('matplotlib').setLevel(logging.WARNING) from pywren_ibm_cloud.plots import create_timeline, create_histogram msg = 'ExecutorID {} - Creating execution plots'.format(self.executor_id) print(msg) if not self.log_level else logger.info(msg) create_timeline(ftrs_to_plot, dst) create_histogram(ftrs_to_plot, dst)
def create_timeline_plots(self, dst_dir, dst_file_name, futures=None): """ Creates timeline and histogram of the current execution in dst. :param dst: destination folder to save .png plots. :param name: name of the file. :param run_statuses: run statuses timestamps. :param invoke_statuses: invocation statuses timestamps. """ if futures: ftrs = futures else: ftrs = self.futures if not ftrs or self._state == ExecutorState.new: raise Exception( 'You must run pw.call_async(), pw.map() or pw.map_reduce()' ' before call pw.create_timeline_plots()') logging.getLogger('matplotlib').setLevel(logging.WARNING) from pywren_ibm_cloud.plots import create_timeline, create_histogram msg = 'Executor ID {} Creating timeline plots'.format(self.executor_id) logger.info(msg) if not self.log_level: print(msg) if self.data_cleaner: print() if self.rabbitmq_monitor and not futures: ftrs_to_plot = self.futures self.monitor(futures=ftrs_to_plot) else: ftrs_to_plot = [f for f in ftrs if f.ready or f.done] if not ftrs_to_plot: return run_statuses = [f.run_status for f in ftrs_to_plot] invoke_statuses = [f.invoke_status for f in ftrs_to_plot] if self.rabbitmq_monitor and invoke_statuses: for in_stat in invoke_statuses: del in_stat['status_done_timestamp'] create_timeline(dst_dir, dst_file_name, self.start_time, run_statuses, invoke_statuses, self.config['ibm_cos']) create_histogram(dst_dir, dst_file_name, self.start_time, run_statuses, self.config['ibm_cos'])
def create_execution_plots(self, dst_dir, dst_file_name, futures=None): """ Creates timeline and histogram of the current execution in dst_dir. :param futures: list of futures. :param dst_dir: destination folder to save .png plots. :param dst_file_name: name of the file. """ if not futures: futures = [] for job in self.jobs: if self.jobs[job]['state'] == JobState.Ready or \ self.jobs[job]['state'] == JobState.Done: futures.extend(self.jobs[job]['futures']) self.jobs[job]['state'] = JobState.Finished if type(futures) != list: ftrs = [futures] else: ftrs = futures ftrs_to_plot = [f for f in ftrs if f.ready or f.done] if not ftrs_to_plot: msg = ('You must run call_async(), map() or map_reduce()' ' followed by monitor() or get_results()' ' before calling create_timeline_plots() method') logger.debug(msg) return logging.getLogger('matplotlib').setLevel(logging.WARNING) from pywren_ibm_cloud.plots import create_timeline, create_histogram msg = 'ExecutorID {} - Creating execution plots'.format( self.executor_id) logger.info(msg) if not self.log_level: print(msg) call_status = [f._call_status for f in ftrs_to_plot] call_metadata = [f._call_metadata for f in ftrs_to_plot] create_timeline(dst_dir, dst_file_name, self.start_time, call_status, call_metadata, self.config['ibm_cos']) create_histogram(dst_dir, dst_file_name, self.start_time, call_status, self.config['ibm_cos'])
def create_timeline_plots(self, futures, dst_dir, dst_file_name): """ Creates timeline and histogram of the current execution in dst_dir. :param futures: list of futures. :param dst_dir: destination folder to save .png plots. :param dst_file_name: name of the file. """ if self._state == ExecutorState.new: raise Exception( 'You must run pw.call_async(), pw.map() or pw.map_reduce()' ' before call pw.create_timeline_plots()') if type(futures) != list: ftrs = [futures] else: ftrs = futures ftrs_to_plot = [f for f in ftrs if f.ready or f.done] if not ftrs_to_plot: return logging.getLogger('matplotlib').setLevel(logging.WARNING) from pywren_ibm_cloud.plots import create_timeline, create_histogram msg = 'Executor ID {} Creating timeline plots'.format(self.executor_id) logger.info(msg) if not self.log_level: print(msg) if self.data_cleaner: print() run_statuses = [f.run_status for f in ftrs_to_plot] invoke_statuses = [f.invoke_status for f in ftrs_to_plot] create_timeline(dst_dir, dst_file_name, self.start_time, run_statuses, invoke_statuses, self.config['ibm_cos']) create_histogram(dst_dir, dst_file_name, self.start_time, run_statuses, self.config['ibm_cos'])