Skip to content
Snippets Groups Projects
Commit 70370756 authored by Patrick Koppenburg's avatar Patrick Koppenburg :leaves:
Browse files

Merge branch 'erodrigu-simplify-2022-09-22' into 'master'

Fix a cyclic import among 2 config related files

See merge request !755
parents 52f4f10e b46fee3a
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!755Fix a cyclic import among 2 config related files
Pipeline #4528607 passed
###############################################################################
# (c) Copyright 2020-2022 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
"""
High level configuration tools for DaVinci.
"""
from PyConf.application import configure, configure_input, configured_ann_svc
from PyConf.Algorithms import EventAccounting
from DaVinci.algorithms import (define_fsr_writer, apply_filters_and_unpacking)
from DaVinci.config import davinci_control_flow, prepare_davinci_nodes
from PyConf.application import metainfo_repos
from Configurables import ApplicationMgr
def add_davinci_configurables(options, user_algorithms, public_tools):
"""
Run the job adding the specific Davinci configurables to the standard PyConf ones.
Algorithms developed by users are also included.
Args:
options (DaVinci.Options): lbexec provided options object
Returns:
ComponentConfig instance, a dict of configured Gaudi and DaVinci Configurable instances and user algorithms.
"""
if not public_tools:
public_tools = []
unpack_only_mc = options.unpack_only_mc
config = configure_input(options)
if options.input_manifest_file:
if options.metainfo_additional_tags:
metainfo_repos.global_bind(
extra_central_tags=options.metainfo_additional_tags)
ApplicationMgr().ExtSvc += [
configured_ann_svc(json_file=options.input_manifest_file)
]
elif options.annsvc_config: # this should be renamed to input_manifest_file
# distinguish between configuring the ANNSvc for decoding, and getting
# the manifest to configure the unpacking (the latter has _NOTHING_ to
# do with the ANNSvc)
# Here we only do the decoding part. The unpacking manifest part we
# do in apply_filters_and_unpacking...
config.add(configured_ann_svc(json_file=options.annsvc_config))
dvMainFlow = apply_filters_and_unpacking(options, user_algorithms,
unpack_only_mc)
fsrAlgs = {}
if options.write_fsr:
if options.simulation:
fsrAlgs.update({"GenFSR": define_fsr_writer(options)})
if options.lumi:
fsrAlgs.update({"Lumi": [EventAccounting(name='EventAccount')]})
# this should be modified to reflect LumiAlgsConf (configured separately?)
dvMainNode = davinci_control_flow(options,
prepare_davinci_nodes(dvMainFlow),
prepare_davinci_nodes(fsrAlgs))
config.update(configure(options, dvMainNode, public_tools=public_tools))
return config
###############################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration #
# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
......@@ -12,10 +12,14 @@
DaVinci configured using PyConf components.
"""
from __future__ import absolute_import
import logging
from collections import namedtuple, OrderedDict
from Configurables import ApplicationMgr
from PyConf.application import configure, configure_input, configured_ann_svc
from PyConf.application import metainfo_repos
from PyConf.control_flow import CompositeNode, NodeLogic
from PyConf.Algorithms import EventAccounting
from DaVinci.algorithms import (define_fsr_writer, apply_filters_and_unpacking)
log = logging.getLogger(__name__)
......@@ -139,9 +143,63 @@ def prepare_davinci_nodes(user_algs):
return dv_nodes
def make_config(options, user_algorithms, *, public_tools=None):
from DaVinci.Configuration import add_davinci_configurables
def add_davinci_configurables(options, user_algorithms, public_tools):
"""
Run the job adding the specific Davinci configurables to the standard PyConf ones.
Algorithms developed by users are also included.
Args:
options (DaVinci.Options): lbexec provided options object
Returns:
ComponentConfig instance, a dict of configured Gaudi and DaVinci Configurable instances and user algorithms.
"""
if not public_tools:
public_tools = []
unpack_only_mc = options.unpack_only_mc
config = configure_input(options)
if options.input_manifest_file:
if options.metainfo_additional_tags:
metainfo_repos.global_bind(
extra_central_tags=options.metainfo_additional_tags)
ApplicationMgr().ExtSvc += [
configured_ann_svc(json_file=options.input_manifest_file)
]
elif options.annsvc_config: # this should be renamed to input_manifest_file
# distinguish between configuring the ANNSvc for decoding, and getting
# the manifest to configure the unpacking (the latter has _NOTHING_ to
# do with the ANNSvc)
# Here we only do the decoding part. The unpacking manifest part we
# do in apply_filters_and_unpacking...
config.add(configured_ann_svc(json_file=options.annsvc_config))
dvMainFlow = apply_filters_and_unpacking(options, user_algorithms,
unpack_only_mc)
fsrAlgs = {}
if options.write_fsr:
if options.simulation:
fsrAlgs.update({"GenFSR": define_fsr_writer(options)})
if options.lumi:
fsrAlgs.update({"Lumi": [EventAccounting(name='EventAccount')]})
# this should be modified to reflect LumiAlgsConf (configured separately?)
dvMainNode = davinci_control_flow(options,
prepare_davinci_nodes(dvMainFlow),
prepare_davinci_nodes(fsrAlgs))
config.update(configure(options, dvMainNode, public_tools=public_tools))
return config
def make_config(options, user_algorithms, *, public_tools=None):
if isinstance(user_algorithms, list):
user_algorithms = {"default": user_algorithms}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment