예제 #1
0
 def get_nevents_per_file(self, dataset):
     dataset = dataset.split(':')[-1].strip('/')
     tid_pattern = r'(?P<tid>_tid\d+_\d{2})'
     if re.match(r"^.*%s$" % tid_pattern, dataset):
         dataset = re.sub(tid_pattern, '', dataset)
     AtlasAPI.init()
     result = AtlasAPI.get_dataset_info(self.ami_client, dataset)
     round_up = lambda num: int(num + 1) if int(num) != num else int(num)
     return round_up(float(result[0]['totalEvents']) / float(result[0]['nFiles']))
예제 #2
0
 def sync_ami_types(self):
     try:
         AtlasAPI.init()
         ami_types = AtlasAPI.list_types(self.ami_client,
                                         fields=['description', 'write_status'])
         format_names = [e.name for e in TDataFormat.objects.all()]
         for ami_type in ami_types:
             if ami_type['write_status'] != 'valid':
                 continue
             if not ami_type['name'] in format_names:
                 description = None
                 if str(ami_type['description']) != 'NULL':
                     description = str(ami_type['description'])
                 new_format = TDataFormat(name=ami_type['name'],
                                          description=description)
                 new_format.save()
                 logger.info("The data format \"%s\" is registered" % new_format.name)
     except Exception as ex:
         logger.exception("Exception: %s" % str(ex))
예제 #3
0
 def sync_ami_projects(self):
     try:
         AtlasAPI.init()
         ami_projects = AtlasAPI.list_projects(self.ami_client,
                                               patterns=['valid%', 'data%', 'mc%', 'user%'],
                                               fields=['description', 'write_status'])
         project_names = [e.project for e in TProject.objects.all()]
         for ami_project in ami_projects:
             if ami_project['write_status'] != 'valid':
                 continue
             if not ami_project['tag'] in project_names:
                 description = None
                 if str(ami_project['description']) != 'NULL':
                     description = str(ami_project['description'])
                 timestamp = int(time.time())
                 new_project = TProject(project=ami_project['tag'],
                                        status='active',
                                        description=description,
                                        timestamp=timestamp)
                 new_project.save()
                 logger.info("The project \"%s\" is registered (timestamp = %d)" % (new_project.project, timestamp))
     except Exception as ex:
         logger.exception("Exception: %s" % str(ex))