コード例 #1
0
def postprocessor_filter(value, item):
    from Ganga.GPIDev.Lib.Job.Job import Job
    from Ganga.GPIDev.Lib.Tasks.ITransform import ITransform
    from Ganga.GPIDev.Base.Objects import ObjectMetaclass

    #from Ganga.GPIDev.Base.Proxy import stripProxy

    from Ganga.GPIDev.Base.Proxy import getProxyInterface

    valid_jobtypes = [stripProxy(i)._schema.datadict['postprocessors'] for i in getProxyInterface().__dict__.values()
                      if isinstance(stripProxy(i), ObjectMetaclass)
                      and (issubclass(stripProxy(i), Job) or issubclass(stripProxy(i), ITransform))
                      and 'postprocessors' in stripProxy(i)._schema.datadict]

    # Alex modified this line to that from above to allow for arbitrary dynamic LHCbJobTemplate etc types
#    if item is Job._schema['postprocessors']:
    if item in valid_jobtypes:
        ds = MultiPostProcessor()
        if isinstance(value, list) or isType(value, GangaList):
            for item_ in value:
            	ds.append(item_)
        else:
            ds.append(value)
        return ds
    else:
        raise PostProcessException("j.postprocessors only takes objects of category 'postprocessor'")
コード例 #2
0
ファイル: GaudiDataset.py プロジェクト: Erni1619/ganga
def string_dataset_shortcut(files, item):
    from Ganga.GPIDev.Base.Objects import ObjectMetaclass
    from Ganga.GPIDev.Base.Proxy import stripProxy
    from Ganga.GPIDev.Base.Proxy import getProxyInterface
    filterList = [stripProxy(i)._schema.datadict['inputdata'] for i in getProxyInterface().__dict__.values()
                  if isinstance(stripProxy(i), ObjectMetaclass)
                  and issubclass(stripProxy(i), Job)
                  and 'inputdata' in stripProxy(i)._schema.datadict]

    # job.outputdata not used any more, use job.outputfiles
    #filterList  = [Job._schema['inputdata'], Job._schema['outputdata']]
    if type(files) is not type([]):
        return None
    if item in filterList:  # inputdataList:
        ds = GaudiDataset(files)
        return ds
    else:
        return None  # used to be c'tors, but shouldn't happen now
コード例 #3
0
ファイル: LHCbDataset.py プロジェクト: ganga-devs/ganga
def string_dataset_shortcut(files, item):
    from GangaLHCb.Lib.Tasks.LHCbTransform import LHCbTransform
    from Ganga.GPIDev.Base.Objects import ObjectMetaclass
    # This clever change mirrors that in IPostprocessor (see there)
    # essentially allows for dynamic extensions to JobTemplate
    # such as LHCbJobTemplate etc.
    from Ganga.GPIDev.Base.Proxy import getProxyInterface
    inputdataList = [stripProxy(i)._schema.datadict['inputdata'] for i in getProxyInterface().__dict__.values()
                     if isinstance(stripProxy(i), ObjectMetaclass)
                     and (issubclass(stripProxy(i), Job) or issubclass(stripProxy(i), LHCbTransform))
                     and 'inputdata' in stripProxy(i)._schema.datadict]
    if type(files) not in [list, tuple, GangaList]:
        return None
    if item in inputdataList:
        ds = LHCbDataset()
        ds.extend(files)
        return ds
    else:
        return None  # used to be c'tors, but shouldn't happen now
コード例 #4
0
def string_dataset_shortcut(files, item):
    from GangaLHCb.Lib.Tasks.LHCbTransform import LHCbTransform
    from Ganga.GPIDev.Base.Objects import ObjectMetaclass
    # This clever change mirrors that in IPostprocessor (see there)
    # essentially allows for dynamic extensions to JobTemplate
    # such as LHCbJobTemplate etc.
    from Ganga.GPIDev.Base.Proxy import getProxyInterface
    inputdataList = [stripProxy(i)._schema.datadict['inputdata'] for i in getProxyInterface().__dict__.values()
                     if isinstance(stripProxy(i), ObjectMetaclass)
                     and (issubclass(stripProxy(i), Job) or issubclass(stripProxy(i), LHCbTransform))
                     and 'inputdata' in stripProxy(i)._schema.datadict]
    if type(files) not in [list, tuple, GangaList]:
        return None
    if item in inputdataList:
        ds = LHCbDataset()
        ds.extend(files)
        return ds
    else:
        return None  # used to be c'tors, but shouldn't happen now
コード例 #5
0
ファイル: GaudiDataset.py プロジェクト: wireshark10/ganga
def string_dataset_shortcut(files, item):
    from Ganga.GPIDev.Base.Objects import ObjectMetaclass
    from Ganga.GPIDev.Base.Proxy import stripProxy
    from Ganga.GPIDev.Base.Proxy import getProxyInterface
    filterList = [
        stripProxy(i)._schema.datadict['inputdata']
        for i in getProxyInterface().__dict__.values()
        if isinstance(stripProxy(i), ObjectMetaclass)
        and issubclass(stripProxy(i), Job)
        and 'inputdata' in stripProxy(i)._schema.datadict
    ]

    # job.outputdata not used any more, use job.outputfiles
    #filterList  = [Job._schema['inputdata'], Job._schema['outputdata']]
    if type(files) is not type([]):
        return None
    if item in filterList:  # inputdataList:
        ds = GaudiDataset(files)
        return ds
    else:
        return None  # used to be c'tors, but shouldn't happen now
コード例 #6
0
ファイル: __init__.py プロジェクト: mesmith75/ganga
def load(filename="", returnList=True):
    """Function to load previously exported Ganga objects

       Arguments:
          filename   - String [default ''] giving path to a file containing
                       definitions of Ganga objects, such as produced with 
                       the 'export' function
                       => The path can be absolute, relative, or relative
                          to a directory in the search path LOAD_SCRIPTS,
                          defined in [Configuration] section of
                          Ganga configuration
          returnList - Switch [default True] defining the return type:
                       => True  : List of loaded objects is returned
                       => False : None returned - job and template objects
                                  stored in job repository

       Return value: List of Ganga objects or None, as determined by value
                     of argument returnList
    """

    #logger.info("Loading: %s" % str(filename))

    if returnList:
        returnValue = []
    else:
        returnValue = None

    if not filename:
        logger.info("Usage:")
        logger.info("load( '<filename>', [ <returnList> ] )")
        logger.info("See also: 'help( load )'")
        return returnValue

    searchPath = getSearchPath("LOAD_PATH")
    filepath = getScriptPath(filename, searchPath)
    try:
        with open(filepath) as inFile:
            lineList = []
            for line in inFile:
                if (line.strip().startswith("#Ganga#")):
                    lineList.append("#Ganga#")
                else:
                    lineList.append(line)
            itemList = ("".join(lineList)).split("#Ganga#")
    except IOError:
        logger.error("Unable to open file %s" % (str(filename)))
        logger.error("No objects loaded")
        return returnValue

    objectList = []
    for item in itemList:
        item = item.strip()
        if item:
            try:
                from Ganga.GPIDev.Base.Proxy import getProxyInterface
                this_object = eval(str(item), getProxyInterface().__dict__)
                objectList.append(this_object)
            except NameError as x:
                logger.exception(x)
                logger.warning("Unable to load object with definition %s" % item)
                logger.warning("Required plug-ins may not be available")

    if not objectList:
        logger.warning("Unable to load any objects from file %s" % filename)

    if returnList:
        returnValue = objectList

    return returnValue
コード例 #7
0
ファイル: __init__.py プロジェクト: wireshark10/ganga
def load(filename="", returnList=True):
    """Function to load previously exported Ganga objects

       Arguments:
          filename   - String [default ''] giving path to a file containing
                       definitions of Ganga objects, such as produced with 
                       the 'export' function
                       => The path can be absolute, relative, or relative
                          to a directory in the search path LOAD_SCRIPTS,
                          defined in [Configuration] section of
                          Ganga configuration
          returnList - Switch [default True] defining the return type:
                       => True  : List of loaded objects is returned
                       => False : None returned - job and template objects
                                  stored in job repository

       Return value: List of Ganga objects or None, as determined by value
                     of argument returnList
    """

    #logger.info("Loading: %s" % str(filename))

    if returnList:
        returnValue = []
    else:
        returnValue = None

    if not filename:
        logger.info("Usage:")
        logger.info("load( '<filename>', [ <returnList> ] )")
        logger.info("See also: 'help( load )'")
        return returnValue

    searchPath = getSearchPath("LOAD_PATH")
    filepath = getScriptPath(filename, searchPath)
    try:
        with open(filepath) as inFile:
            lineList = []
            for line in inFile:
                if (line.strip().startswith("#Ganga#")):
                    lineList.append("#Ganga#")
                else:
                    lineList.append(line)
            itemList = ("".join(lineList)).split("#Ganga#")
    except IOError:
        logger.error("Unable to open file %s" % (str(filename)))
        logger.error("No objects loaded")
        return returnValue

    objectList = []
    for item in itemList:
        item = item.strip()
        if item:
            try:
                from Ganga.GPIDev.Base.Proxy import getProxyInterface
                this_object = eval(str(item), getProxyInterface().__dict__)
                objectList.append(this_object)
            except NameError as x:
                logger.exception(x)
                logger.warning("Unable to load object with definition %s" %
                               item)
                logger.warning("Required plug-ins may not be available")

    if not objectList:
        logger.warning("Unable to load any objects from file %s" % filename)

    if returnList:
        returnValue = objectList

    return returnValue