def __init__(self, db=None, currently_executing=None): """ db: if a string, it is used as path for the DB currently_executing: str, job currently executing defaults to ['root'] """ if currently_executing is None: currently_executing = ['root'] from compmake import StorageFilesystem if db is None: prog, _ = os.path.splitext(os.path.basename(sys.argv[0])) # logger.info('Context(): Using default storage dir %r.' % prog) dirname = 'out-%s' % prog db = StorageFilesystem(dirname, compress=True) if isinstance(db, six.string_types): db = StorageFilesystem(db, compress=True) assert db is not None self.compmake_db = db self._jobs_defined_in_this_session = set() self.currently_executing = currently_executing self._job_prefix = None # RC files read self.rc_files_read = [] # counters for prefixes (generate_job_id) self.generate_job_id_counters = {}
def run_second(self, root): info('run_second()') db = StorageFilesystem(root, compress=True) cc = Context(db=db) # cc.comp_dynamic(f2, job_id='f') cc.batch_command('clean;make recurse=1')
def run_first(self, root): db = StorageFilesystem(root, compress=True) cc = Context(db=db) # cc.comp(g, job_id='g') cc.comp(h, job_id='h') cc.batch_command('make')
def run_second(self, root): print('run_second()') db = StorageFilesystem(root, compress=True) cc = Context(db=db) # cc.comp_dynamic(e2, job_id='e') cc.batch_command('details e;clean;ls;make recurse=1')
def run_first(self, root): print('run_first()') db = StorageFilesystem(root, compress=True) cc = Context(db=db) # cc.comp_dynamic(e1, job_id='e') cc.batch_command('make recurse=1; ls')
def go(self): # check that if we have a parent who is a quickapp, # then use its context qapp_parent = self.get_qapp_parent() if qapp_parent is not None: # self.info('Found parent: %s' % qapp_parent) qc = qapp_parent.child_context self.define_jobs_context(qc) return else: # self.info('Parent not found') pass # if False: # import resource # gbs = 5 # max_mem = long(gbs * 1000 * 1048576) # resource.setrlimit(resource.RLIMIT_AS, (max_mem, -1)) # resource.setrlimit(resource.RLIMIT_DATA, (max_mem, -1)) options = self.get_options() # if self.get_qapp_parent() is None: # only do this if somebody didn't do it before if not options.contracts: msg = ('PyContracts disabled for speed. ' 'Use --contracts to activate.') self.logger.warning(msg) contracts.disable_all() output_dir = options.output if options.reset: if os.path.exists(output_dir): self.logger.info('Removing output dir %r.' % output_dir) try: shutil.rmtree(output_dir) except OSError as e: # Directory not empty -- common enough on NFS filesystems # print('errno: %r' % e.errno) if e.errno == 39: pass else: raise # Compmake storage for results storage = os.path.join(output_dir, 'compmake') logger.debug('Creating storage in %s (compress = %s)' % (storage, options.compress)) db = StorageFilesystem(storage, compress=options.compress) currently_executing = ['root'] # The original Compmake context oc = Context(db=db, currently_executing=currently_executing) # Our wrapper qc = CompmakeContext(cc=oc, parent=None, qapp=self, job_prefix=None, output_dir=output_dir) read_rc_files(oc) original = oc.get_comp_prefix() self.define_jobs_context(qc) oc.comp_prefix(original) merged = context_get_merge_data(qc) # Only create the index job if we have reports defined # or some branched context (which might create reports) has_reports = len(qc.get_report_manager().allreports) > 0 has_branched = qc.has_branched() if has_reports or has_branched: # self.info('Creating reports') oc.comp_dynamic(_dynreports_create_index, merged) else: pass # self.info('Not creating reports.') ndefined = len(oc.get_jobs_defined_in_this_session()) if ndefined == 0: # self.comp was never called msg = 'No jobs defined.' raise ValueError(msg) else: if options.console: oc.compmake_console() return 0 else: cq = CacheQueryDB(oc.get_compmake_db()) targets = cq.all_jobs() todo, done, ready = cq.list_todo_targets(targets) if not todo and options.command is None: msg = "Note: there is nothing for me to do. " msg += '\n(Jobs todo: %s done: %s ready: %s)' % ( len(todo), len(done), len(ready)) msg += """\ This application uses a cache system for the results. This means that if you call it second time with the same arguments, and if you do not change any input, it will not do anything.""" self.warn(msg) return 0 if options.command is None: command = 'make recurse=1' else: command = options.command try: _ = oc.batch_command(command) # print('qapp: ret0 = %s' % ret0) except CommandFailed: # print('qapp: CommandFailed') ret = QUICKAPP_COMPUTATION_ERROR except ShellExitRequested: # print('qapp: ShellExitRequested') ret = 0 else: # print('qapp: else ret = 0') ret = 0 return ret
def all_jobs(self, root): """ Returns the list of jobs corresponding to the given expression. """ db = StorageFilesystem(root, compress=True) return sorted(list(all_jobs(db)))