def _make_record(self, record, prog, i, n, calculate_f_only=False): meta_repo = self.meta_repo if prog: prog.change_message('Loading analysis {}. {}/{}'.format( record.record_id, i, n)) expid = record.repository_identifier if not expid: exps = record.repository_ids self.debug('Analysis {} is associated multiple repositories ' '{}'.format(record.record_id, ','.join(exps))) expid = None if self.selected_repositories: rr = [si for si in self.selected_repositories if si in exps] if rr: if len(rr) > 1: expid = self._get_requested_experiment_id(rr) else: expid = rr[0] if expid is None: expid = self._get_requested_experiment_id(exps) if isinstance(record, DVCAnalysis): a = record else: self.debug('use_repo_suffix={} record_id={}'.format( record.use_repository_suffix, record.record_id)) try: rid = record.record_id if record.use_repository_suffix: rid = '-'.join(rid.split('-')[:-1]) a = DVCAnalysis(rid, expid) except AnalysisNotAnvailableError: self.info( 'Analysis {} not available. Trying to clone repository "{}"' .format(rid, expid)) try: self.sync_repo(expid) except CredentialException: self.warning_dialog( 'Invalid credentials for GitHub/GitLab') return try: a = DVCAnalysis(rid, expid) except AnalysisNotAnvailableError: self.warning_dialog( 'Analysis {} not in repository {}'.format(rid, expid)) return # get repository branch a.branch = get_repository_branch( os.path.join(paths.repository_dataset_dir, expid)) # a.set_tag(record.tag) self.debug('Irradiation {}'.format(a.irradiation)) # load irradiation if a.irradiation and a.irradiation not in ('NoIrradiation', ): chronology = meta_repo.get_chronology(a.irradiation) a.set_chronology(chronology) frozen_production = self._get_frozen_production( rid, a.repository_identifier) if frozen_production: pname, prod = frozen_production.name, frozen_production else: pname, prod = meta_repo.get_production( a.irradiation, a.irradiation_level) a.set_production(pname, prod) j, lambda_k = meta_repo.get_flux( record.irradiation, record.irradiation_level, record.irradiation_position_position) a.j = j if lambda_k: a.arar_constants.lambda_k = lambda_k if calculate_f_only: a.calculate_F() else: a.calculate_age() return a
def _make_record(self, record, prog, i, n, calculate_f=False, calculate_f_only=False): # def _make_record(self, record, calculate_f=False): ost = time.time() if prog: prog.change_message('Loading analysis {}. {}/{}'.format(record.record_id, i, n)) expid = record.experiment_identifier if not expid: exps = record.experiment_ids self.debug('Analysis {} is associated multiple experiments ' '{}'.format(record.record_id, ','.join(exps))) expid = None if self.selected_experiments: rr = [si for si in self.selected_experiments if si in exps] if rr: if len(rr) > 1: expid = self._get_requested_experiment_id(rr) else: expid = rr[0] if expid is None: expid = self._get_requested_experiment_id(exps) # func = lambda: DVCAnalysis(record.record_id, expid) # a = timethis(func, ) # st = time.time() if isinstance(record, DVCAnalysis): a = record else: # if isinstance(record, AnalysisTbl): # record = record.record_view st = time.time() a = DVCAnalysis(record.record_id, expid) cot = time.time() - st # cot = time.time() - st # if cot>0.1: # print 'constructor {}'.format(cot) # load irradiation if a.irradiation: st = time.time() meta_repo = self.meta_repo chronology = meta_repo.get_chronology(a.irradiation) a.set_chronology(chronology) ct = time.time() - st st = time.time() pname = self.db.get_production_name(a.irradiation, a.irradiation_level) prod = meta_repo.get_production(pname) a.set_production(pname, prod) pt = time.time() - st st = time.time() j, lambda_k = meta_repo.get_flux(record.irradiation, record.irradiation_level, record.irradiation_position_position) a.j = j if lambda_k: a.arar_constants.lambda_k = lambda_k ft = time.time() - st a.set_tag(record.tag_dict) if calculate_f_only: a.calculate_F() else: a.calculate_age() et = time.time() - ost if et > 0.1: f = '-------' print '{} make run {} {} {}'.format(f, i, record.record_id, et) print 'constructor {}'.format(cot) print 'chronology {}'.format(ct) print 'production {}'.format(pt) print 'flux {}'.format(ft) return a