Example #1
0
    def startup(self):
        if gs.MEMORY_PROFILE_LOG:
            if tools.tracemalloc:
                self.mem_profile = tools.MemoryProfiler(open(gs.MEMORY_PROFILE_LOG, 'w'))
            else:
                logging.warning('Could not load tracemalloc, continue without memory profiling')
        else:
            self.mem_profile = None

        self.job_engine.reset_cache()
        self.check_output(write_output=False, update_all_outputs=True)
        self.update_jobs()
        self.update_state_overview()

        toolkit.check_for_exceptions()

        # Skip first part if there is nothing todo
        if toolkit.config_reader_running() and not self.jobs and not self.ui:
            answer = self.input('All calculations are done, print verbose overview (v), update outputs and alias (u), '
                                'cancel (c)? ')
            if answer.lower() in ('y', 'v'):
                self.print_state_overview(verbose=True)
            elif answer.lower() in ('u'):
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs, update_all_outputs=True)
            return

        self.print_state_overview()

        answer = None
        if gs.STATE_ERROR in self.jobs:
            if self.clear_errors_once:
                self.clear_states(state=gs.STATE_ERROR)
                self.clear_errors_once = False
            elif self.ignore_once:
                pass
            else:
                answer = self.input('Clear jobs in error state? [y/N] ')
                if answer.lower() == 'y':
                    self.clear_states(state=gs.STATE_ERROR)
                    self.clear_errors_once = False
                    self.print_state_overview(verbose=False)
                answer = None
        if (gs.STATE_INTERRUPTED in self.jobs) and self.clear_interrupts_once:
            self.clear_states(state=gs.STATE_INTERRUPTED)
            self.clear_interrupts_once = False

        if self.start_computations:
            answer = 'y'

        while True and not self.ui:
            if answer is None:
                pass
            elif answer.lower() == 'v':
                self.print_state_overview(verbose=True)
            elif answer.lower() == 'y':
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs, update_all_outputs=True)
                break
            elif answer.lower() == 'u':
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs, update_all_outputs=True)
            elif answer.lower() == 'n':
                self.stop()
                break
            else:
                logging.warning('Unknown command: %s' % answer)
            answer = self.input('Print verbose overview (v), update aliases and outputs (u), '
                                'start manager (y), or exit (n)? ')

        if (not self._stop_loop) and (gs.CLEAR_ERROR or self.clear_errors_once):
            self.clear_states(state=gs.STATE_ERROR)
            self.clear_errors_once = False
Example #2
0
    def startup(self):
        if gs.MEMORY_PROFILE_LOG:
            if tools.tracemalloc:
                self.mem_profile = tools.MemoryProfiler(
                    open(gs.MEMORY_PROFILE_LOG, 'w'))
            else:
                logging.warning(
                    'Could not load tracemalloc, continue without memory profiling'
                )
        else:
            self.mem_profile = None

        config_manager.continue_readers()

        self.job_engine.reset_cache()
        self.check_output(write_output=False, update_all_outputs=True)
        self.update_jobs()

        # Ensure at least one async reader head the chance to continue until he added his jobs to the list
        config_manager.continue_readers()

        self.update_jobs()
        self.update_state_overview()
        logging.info("Finished updating job states")
        finished_results_cache.write_to_file()

        # Start job cleaner after updating the graph the first time
        if gs.JOB_AUTO_CLEANUP:
            self.job_cleaner = JobCleaner(sis_graph=self.sis_graph)

        # Skip first part if there is nothing todo
        if not (config_manager.reader_running() or self.jobs or self.ui):
            answer = self.input(
                'All calculations are done, print verbose overview (v), update outputs and alias (u), '
                'cancel (c)? ')
            if answer.lower() in ('y', 'v'):
                self.print_state_overview(verbose=True)
            elif answer.lower() in ('u'):
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs,
                                  update_all_outputs=True)
            return False

        self.print_state_overview()
        config_manager.print_config_reader()

        answer = None
        if gs.STATE_ERROR in self.jobs:
            if self.clear_errors_once:
                self.clear_states(state=gs.STATE_ERROR)
                self.clear_errors_once = False
            elif self.ignore_once:
                pass
            else:
                answer = self.input('Clear jobs in error state? [y/N] ')
                if answer.lower() == 'y':
                    self.clear_states(state=gs.STATE_ERROR)
                    self.clear_errors_once = False
                    self.print_state_overview(verbose=False)
                answer = None
        if (gs.STATE_INTERRUPTED in self.jobs) and self.clear_interrupts_once:
            self.clear_states(state=gs.STATE_INTERRUPTED)
            self.clear_interrupts_once = False

        if self.start_computations:
            answer = 'y'

        while True and not self.ui:
            if answer is None:
                pass
            elif answer.lower() == 'v':
                self.print_state_overview(verbose=True)
            elif answer.lower() == 'y':
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs,
                                  update_all_outputs=True)
                break
            elif answer.lower() == 'u':
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs,
                                  update_all_outputs=True)
            elif answer.lower() == 'n':
                self.stop()
                return False
            else:
                logging.warning('Unknown command: %s' % answer)
            answer = self.input(
                'Print verbose overview (v), update aliases and outputs (u), '
                'start manager (y), or exit (n)? ')

        if (not self._stop_loop) and (gs.CLEAR_ERROR
                                      or self.clear_errors_once):
            self.clear_states(state=gs.STATE_ERROR)
            self.clear_errors_once = False

        if self.job_cleaner:
            self.job_cleaner.start()
        return True
Example #3
0
    def startup(self):
        if gs.MEMORY_PROFILE_LOG:
            self.mem_profile = tools.MemoryProfiler(
                open(gs.MEMORY_PROFILE_LOG, 'w'))
        else:
            self.mem_profile = None

        self.job_engine.reset_cache()
        self.check_output(write_output=False, update_all_outputs=True)
        self.update_jobs()
        self.update_state_overview()

        # Skip first part if there is nothing todo
        if not self.jobs:
            answer = input(
                'All calculations are done, print verbose overview (v), update outputs and alias (u), '
                'cancel (c)? ')
            if answer.lower() in ('y', 'v'):
                self.print_state_overview(verbose=True)
            elif answer.lower() in ('u'):
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs,
                                  update_all_outputs=True)
            return

        self.print_state_overview()

        answer = None
        if gs.STATE_ERROR in self.jobs:
            if self.clear_once:
                self.clear_errors()
            else:
                answer = input('Clear jobs in error state? [y/N] ')
                if answer.lower() == 'y':
                    self.clear_once = True
                    self.clear_errors()
                    self.print_state_overview(verbose=False)
                answer = None

        if self.start_computations:
            answer = 'y'

        while True:
            if answer is None:
                pass
            elif answer.lower() == 'v':
                self.print_state_overview(verbose=True)
            elif answer.lower() == 'y':
                self.link_outputs = True
                create_aliases(self.sis_graph.jobs())
                self.check_output(write_output=self.link_outputs,
                                  update_all_outputs=True)
                break
            elif answer.lower() == 'n':
                self.stop()
                break
            else:
                logging.warning('Unknown command: %s' % answer)
            answer = input(
                'Print verbose overview (v), start manager (y), or exit (n)? ')

        if not self._stop_loop:
            self.clear_errors()