Beispiel #1
0
 def main(argv):
    client = AMIClient()
    if not os.path.exists(AMI_CONFIG):
       create_auth_config()
    client.read_config(AMI_CONFIG)
    datasetNamePattern=argv[0] 
    
    res =  get_datasets(client,datasetNamePattern,fields='events,nfiles', flatten=True)
    print_table( res )           
Beispiel #2
0
 def instance(self):
     if Client._instance is None:
         c = PyAmi.AMI()
         import os.path as osp
         if not osp.exists(PyAmiAuth.AMI_CONFIG):
             PyAmiAuth.create_auth_config()
             pass
         c.read_config(PyAmiAuth.AMI_CONFIG)
         Client._instance = c
     return Client._instance
Beispiel #3
0
 def instance(self):
     if Client._instance is None:
         c = PyAmi.AMI()
         import os.path as osp
         if not osp.exists(PyAmiAuth.AMI_CONFIG):
             PyAmiAuth.create_auth_config()
             pass
         c.read_config(PyAmiAuth.AMI_CONFIG)
         Client._instance = c
     return Client._instance
Beispiel #4
0
 def __init__(self, certAuth=True, dry_run=False):
     self._client = PyAmi.AMI()
     import os.path as osp
     if not osp.exists(PyAmiAuth.AMI_CONFIG):
         PyAmiAuth.create_auth_config()
         pass
     self._client.read_config(PyAmiAuth.AMI_CONFIG)
     import PyUtils.Logging as L
     self.msg = L.logging.getLogger('ami-client')
     self.msg.setLevel(L.logging.INFO)
     self.dry_run = dry_run
     return
Beispiel #5
0
 def __init__(self, certAuth=True, dry_run=False):
     self._client = PyAmi.AMI()
     import os.path as osp
     if not osp.exists(PyAmiAuth.AMI_CONFIG):
         PyAmiAuth.create_auth_config()
         pass
     self._client.read_config(PyAmiAuth.AMI_CONFIG)
     import PyUtils.Logging as L
     self.msg = L.logging.getLogger('ami-client')
     self.msg.setLevel(L.logging.INFO)
     self.dry_run = dry_run
     return
Beispiel #6
0
 def _setup_ami_client(self):
     self.client = AMIClient()
     if not os.path.exists(AMI_CONFIG):
         create_auth_config()
     self.client.read_config(AMI_CONFIG)
Beispiel #7
0
HERE = os.path.dirname(os.path.abspath(__file__))

# Any datasets which don't have the provenance stored properly in AMI
# should be hardcoded here (it happens)
DS_NOPROV = {}

# Cross-sections are cached so that we don't need to keep asking AMI
# for them over and over
XSEC_CACHE_FILE = os.path.join(HERE, 'xsec', 'cache.pickle')
XSEC_CACHE_MODIFIED = False
XSEC_CACHE = {}

if USE_PYAMI:
    amiclient = AMIClient()
    if not os.path.exists(AMI_CONFIG):
        create_auth_config()
    amiclient.read_config(AMI_CONFIG)


class NoMatchingDatasetsFound(Exception):
    pass


class Database(dict):

    @classmethod
    def match_to_ds(cls, match):
        """
        Construct the original NTUP dataset name from a skim match object
        """
        if match.group('year') == '11':
Beispiel #8
0
HERE = os.path.dirname(os.path.abspath(__file__))

# Any datasets which don't have the provenance stored properly in AMI
# should be hardcoded here (it happens)
DS_NOPROV = {}

# Cross-sections are cached so that we don't need to keep asking AMI
# for them over and over
XSEC_CACHE_FILE = os.path.join(HERE, 'xsec', 'cache.pickle')
XSEC_CACHE_MODIFIED = False
XSEC_CACHE = {}

if USE_PYAMI:
    amiclient = AMIClient()
    if not os.path.exists(AMI_CONFIG):
        create_auth_config()
    amiclient.read_config(AMI_CONFIG)


class NoMatchingDatasetsFound(Exception):
    pass


class Database(dict):
    @classmethod
    def match_to_ds(cls, match):
        """
        Construct the original NTUP dataset name from a skim match object
        """
        if match.group('year') == '11':
            ntup = 'merge.NTUP_TAUMEDIUM'
Beispiel #9
0
def get_tag_diffs(mon, ref, g, mon_task, ref_task):

    client = AMIClient()
    if not os.path.exists(AMI_CONFIG):
        create_auth_config()
        client.read_config(AMI_CONFIG)

    mon_release = ''
    ref_release = ''
    mon_taginfo = get_configtags(client, mon.rtag)
    ref_taginfo = get_configtags(client, ref.rtag)
    configtags = [
        'SWReleaseCache', 'lvl1ps', 'hltps', 'smk', 'enlvl1prescales'
    ]
    configcomp = {}
    for n, info in enumerate(mon_taginfo):
        ref_info = ref_taginfo[n]
        for xinfo in info.keys():
            if xinfo in configtags:
                if xinfo == 'SWReleaseCache': mon_rel = info[xinfo]
                configcomp[xinfo] = [info[xinfo], ref_info[xinfo]]

    for info in ref_taginfo:
        for xinfo in info.keys():
            if xinfo == 'SWReleaseCache': ref_rel = info[xinfo]
    mon_release = mon_rel.replace('_', ',')
    ref_release = ref_rel.replace('_', ',')
    import PyCmt.Cmt as Cmt
    diffs = Cmt.get_tag_diff(ref=ref_release, chk=mon_release, verbose=False)

    g.write('<table>\n')
    g.write('<tr><td width="250"></td><td width="250"><b>Reprocessing</b></td>'
            '<td width="250"><b>Reference</b></tr>')
    ami_link = '<a href ="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormListConfigurationTag+-configTag=%s">%s</a></td>'
    sav_link = '<a href="https://savannah.cern.ch/task/?%s"> Task #%s </a></td>'
    g.write('<tr><td>AMI Tag </td>')
    for tag in (mon.rtag, ref.rtag):
        g.write(
            '<td><a href ="https://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?Converter=/AMIXmlToAMIProdHtml.xsl&Command=FormListConfigurationTag+-configTag=%s">%s</a></td>'
            % (tag, tag))
    g.write('</tr>')
    g.write('<tr><td> Savannah Task </td>')
    for task in (mon_task, ref_task):
        if task == None:
            g.write(
                '<td><a href="https://savannah.cern.ch/task/index.php?go_report=Apply&group=atlas-trig&func=browse&category_id=107&status_id=0"> Search Tasks </a></td>'
            )
        else:
            g.write(
                '<td><a href="https://savannah.cern.ch/task/?%s"> Task #%s </a></td>'
                % (task, task))
    g.write('</tr>\n')
    g.write('<tr><td> Run </td>')
    for run in (mon.run, ref.run):
        g.write('<td> %s </td>' % str(run))
    g.write('</tr><tr></tr>\n')
    g.write('<tr><td><b>Tag Configuration </b></td></tr>\n')
    for field in configtags:
        g.write('<tr><td>%s</td><td>%s</td><td>%s</td>' %
                (field, configcomp[field][0], configcomp[field][1]))
        g.write('</tr>\n')
    g.write('<tr></tr>')
    g.write('</table>')

    g.write('<h3> Release Tag Differences </h3>')
    g.write('<p> Found [%i] differences </p>\n' % len(diffs))

    if len(diffs):
        g.write('<table>\n')
        g.write(
            '<tr><td width = "150"><b>Reprocessing</b></td><td width="250"><b>mon-project</b></td>'
        )
        g.write(
            '<td width = "150"><b>Reference</b></td><td width="250"><b>ref-project</b></td>'
        )
        g.write('<td width = "500"><b>package name</b></td></tr>')
        for diff in diffs:
            g.write('<tr>')
            g.write('<td> %s </td>' % diff['chk'])
            g.write('<td> %s </td>' % diff['chk_proj'])
            g.write('<td> %s </td>' % diff['ref'])
            g.write('<td> %s </td>' % diff['ref_proj'])
            g.write('<td> %s </td>' % diff['full_name'])
            g.write('</tr>\n')
        g.write('</table>')

    return 0
Beispiel #10
0
def ami():

    args = parser.parse_args()

    from pyAMI import endpoint
    # this must be done before an import of webservices anywhere
    endpoint.TYPE = args.server

    from pyAMI.auth import AMI_CONFIG, create_auth_config
    from pyAMI.client import AMIClient, AMIResult
    from pyAMI.exceptions import AMI_Error

    if args.op == 'exec':
        args.op = AMIClient.execute

    try:
        if args.op == 'auth':
            create_auth_config()
        elif args.op == userdata.reset:
            userdata.reset()
        else:
            amiclient = AMIClient(verbose=args.verbose,
                                  verbose_format=args.output)
            cmd_args = dict(args._get_kwargs())
            del cmd_args['op']
            del cmd_args['pr']
            del cmd_args['verbose']
            del cmd_args['debug']
            del cmd_args['output']
            del cmd_args['server']
            if 'help' in cmd_args:
                del cmd_args['help']
            if 'amiCommand' in cmd_args:
                cmd_args['args'] = cmd_args['amiCommand'] + cmd_args['args']
                del cmd_args['amiCommand']
            result = args.op(amiclient, **cmd_args)
            if args.op == get_periods:
                print_periods(result)
            elif isinstance(result, AMIResult):
                print result.output(xslt=args.output)
            elif args.pr and result:
                if args.pr == print_table:
                    args.pr(result)
                elif isinstance(result, (list, tuple)):
                    for thing in result:
                        rep = args.pr(thing)
                        if rep:
                            print rep
                else:
                    rep = args.pr(result)
                    if rep is not None:
                        print rep

    except KeyboardInterrupt:
        sys.exit('\n')

    except Exception, e:
        if args.debug:
            # If in debug mode show full stack trace
            import traceback
            traceback.print_exception(*sys.exc_info())
        elif isinstance(e, AMI_Error):
            sys.exit(str(e))
        else:
            sys.exit("%s: %s" % (e.__class__.__name__, e))