Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:16

0001 # Licensed under the Apache License, Version 2.0 (the "License");
0002 # you may not use this file except in compliance with the License.
0003 # You may obtain a copy of the License at
0004 # http://www.apache.org/licenses/LICENSE-2.0
0005 #
0006 # Authors:
0007 # - Alexey Anisenkov, anisyonk@cern.ch, 2018
0008 # - Paul Nilsson, paul.nilsson@cern.ch, 2019
0009 
0010 """
0011 Pilot Information component
0012 
0013 A set of low-level information providers to aggregate, prioritize (overwrite),
0014 hide dependency to external storages and expose (queue, site, storage, etc) details
0015 in a unified structured way to all Pilot modules by providing high-level API
0016 
0017 :author: Alexey Anisenkov
0018 :contact: anisyonk@cern.ch
0019 :date: January 2018
0020 """
0021 
0022 
0023 from .infoservice import InfoService
0024 from .jobinfo import JobInfoProvider  # noqa
0025 from .jobdata import JobData          # noqa
0026 from .filespec import FileSpec        # noqa
0027 
0028 #from .queuedata import QueueData
0029 
0030 from pilot.common.exception import PilotException
0031 
0032 import collections
0033 
0034 import logging
0035 logger = logging.getLogger(__name__)
0036 
0037 
0038 def set_info(args):   ## should be DEPRECATED: use `infosys.init(queuename)`
0039     """
0040     Set up all necessary site information for given PandaQueue name.
0041     Resolve everything from the specified queue name (passed via `args.queue`)
0042     and fill extra lookup structure (Populate `args.info`).
0043 
0044     raise PilotException in case of errors.
0045 
0046     :param args: input (shared) agruments
0047     :return: None
0048     """
0049 
0050     # ## initialize info service
0051     infosys.init(args.queue)
0052 
0053     args.info = collections.namedtuple('info', ['queue', 'infoservice',
0054                                                 # queuedata,
0055                                                 'site', 'storages',
0056                                                 # 'site_info',
0057                                                 'storages_info'])
0058     args.info.queue = args.queue
0059     args.info.infoservice = infosys  # ## THIS is actually for tests and redundant - the pilot.info.infosys should be used
0060     # args.infoservice = infosys  # ??
0061 
0062     # check if queue is ACTIVE
0063     if infosys.queuedata.state != 'ACTIVE':
0064         logger.critical('specified queue is NOT ACTIVE: %s -- aborting' % infosys.queuedata.name)
0065         raise PilotException("Panda Queue is NOT ACTIVE")
0066 
0067     # do we need explicit varible declaration (queuedata)?
0068     # same as args.location.infoservice.queuedata
0069     #args.location.queuedata = infosys.queuedata
0070 
0071     # do we need explicit varible declaration (Experiment site name)?
0072     # same as args.location.infoservice.queuedata.site
0073     #args.location.site = infosys.queuedata.site
0074 
0075     # do we need explicit varible declaration (storages_info)?
0076     # same as args.location.infoservice.storages_info
0077     #args.location.storages_info = infosys.storages_info
0078 
0079     # find all enabled storages at site
0080     try:
0081         args.info.storages = [ddm for ddm, dat in infosys.storages_info.iteritems() if dat.site == infosys.queuedata.site]  # Python 2
0082     except Exception:
0083         args.info.storages = [ddm for ddm, dat in list(infosys.storages_info.items()) if dat.site == infosys.queuedata.site]  # Python 3
0084 
0085     #args.info.sites_info = infosys.sites_info
0086 
0087     logger.info('queue: %s' % args.info.queue)
0088     #logger.info('site: %s' % args.info.site)
0089     #logger.info('storages: %s' % args.info.storages)
0090     #logger.info('queuedata: %s' % args.info.infoservice.queuedata)
0091 
0092 
0093 # global InfoService Instance without Job specific settings applied (singleton shared object)
0094 # normally we should create such instance for each job to properly consider overwrites coming from JonInfoProvider
0095 # Initialization required to access the data
0096 infosys = InfoService()