def GetAMIClient(useReplica=False):
    # This version uses AMI4
    from pyAMI.exceptions import AMI_Error
    from pyAMI.client import AMIClient

    if useReplica:
        print "INFO: Using CERN AMI replica"
        from pyAMI import endpoint
        endpoint.TYPE = "replica"
    else:
        print "INFO: Using primary AMI"

    amiclient=AMIClient()
    
    return amiclient
Example #2
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
        """
Example #3
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
Example #4
0
    #        print ("Will manually add ZSI and 4suite, then try again...")
    #        import sys
    #        sys.path.insert(0,'/afs/cern.ch/atlas/offline/external/ZSI/2.1-a1/lib/python')
    #        sys.path.insert(0,'/afs/cern.ch/sw/lcg/external/4suite/1.0.2_python2.5/slc4_ia32_gcc34/lib/python2.5/site-packages')
    #        from pyAMI.pyAMI import AMI
    #    print ("import pyAMI was succesful")
    #    amiclient=AMI(False)

    #    import setup_pyAMI
    #    from pyAMI.pyAMI import AMI
    try:
        from pyAMI.client import AMIClient
    except ImportError:
        print("WARNING unable to import AMIClient from pyAMI")
    print("import pyAMI4 was successful")
    amiclient = AMIClient(False)

    #------------------------
    #Build final AMI tag info
    s = {}  #stable values
    s['configTag'] = amiTag
    s['AMIUser'] = login
    s['AMIPass'] = password

    c = {}  #changing values
    c['phconfig'] = str(processConfigs[process]['phconfig'].__str__())
    c['inputs'] = str(processConfigs[process]['inputs'].__str__())
    c['outputs'] = str(processConfigs[process]['outputs'].__str__())
    if humanReadableOutputs:
        c['Human-readable outputs'] = str(humanReadableOutputs)
    c['SWReleaseCache'] = str(release)