diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 403e463845d9455cbe4cd3f27caac7b5e73dd16f..2d8c24c0dbcd79053a5c11409daf079905724139 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2018-2021 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". # @@ -16,3 +16,29 @@ check-copyright: script: - curl -o lb-check-copyright "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/SourceTools.py?inline=false" - python lb-check-copyright origin/${TARGET_BRANCH} + +check-formatting: + image: gitlab-registry.cern.ch/lhcb-docker/style-checker + script: + - if [ ! -e .clang-format ] ; then + - curl -o .clang-format "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/data/default.clang-format?inline=false" + - echo '.clang-format' >> .gitignore + - git add .gitignore + - fi + - curl -o lb-format "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/SourceTools.py?inline=false" + - python lb-format --format-patch apply-formatting.patch origin/${TARGET_BRANCH} + artifacts: + paths: + - apply-formatting.patch + when: on_failure + expire_in: 1 week + +python-linting: + tags: + - cvmfs + script: + - . /cvmfs/lhcb.cern.ch/lib/LbEnv.sh + # Only run the pyflakes linter and a few select pycodestyle errors + # Lint a single file because much of the code in DaVinci is yet to be checked whether it will be kept for run 3. + # This one file has been updated to pass the linter checks! + - flake8 --exclude '*.opts.py' --select=F,E71,E9,W1,W6 $(find Phys/DaVinci -name 'ConfigurationUpgrade.py') diff --git a/Phys/DaVinci/python/DaVinci/configurations.py b/Phys/DaVinci/python/DaVinci/configurations.py index fe2b97813f7dbb52f53c031f7396a7f85c0ae197..7048daa80e7eba0f4f7ff293563702bf39af81e3 100644 --- a/Phys/DaVinci/python/DaVinci/configurations.py +++ b/Phys/DaVinci/python/DaVinci/configurations.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2020 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2020-2021 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". # @@ -8,13 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +""" +Define configurations for applications, algorithms and external services. +""" -from GaudiConfig2 import Configurables as C -from DaVinci.configOptions import get_slot_value +from DaVinci.configOptions import get_slot_value, get_default_value -################################################################################ -# Define configurations for applications and algorithms -# def configure_app_mgr(appMgr, slots, config): """ @@ -25,16 +24,18 @@ def configure_app_mgr(appMgr, slots, config): if c.name == 'MessageSvc': messageSvc = c - appMgr.EvtMax = get_slot_value(slots,"EvtMax") + appMgr.EvtMax = get_slot_value(slots, "EvtMax") appMgr.HistogramPersistency = 'ROOT' appMgr.AuditAlgorithms = True - appMgr.ExtSvc = [c for c in config - if c.__component_type__ == 'Service' - and c.name not in ['ApplicationMgr']] - appMgr.TopAlg = [c for c in config - if c.__component_type__ == 'Algorithm' - and c.name not in ['ApplicationMgr']] + appMgr.ExtSvc = [ + c for c in config if c.__component_type__ == 'Service' + and c.name not in ['ApplicationMgr'] + ] + appMgr.TopAlg = [ + c for c in config if c.__component_type__ == 'Algorithm' + and c.name not in ['ApplicationMgr'] + ] def configure_init(dvInit, slots): @@ -44,10 +45,6 @@ def configure_init(dvInit, slots): dvInit.Increment = get_slot_value(slots, "PrintFreq") -################################################################################ -# Define configurations for external services -# - def configure_timing(auditor, timer, sequencer): """ Configuration of timing auditors. @@ -60,15 +57,15 @@ def configure_options_root_ntuples(svc, slots): """ Configuration of output .root ntuples """ - for _line in svc.Output : - if 0 <= _line.find ('FILE1') : + for _line in svc.Output: + if 0 <= _line.find('FILE1'): log = get_slot_value(slots, "Log") - log.warning ('Replace NTuple-LUN FILE1: ' + _line ) - svc.Output.remove ( _line ) + log.warning('Replace NTuple-LUN FILE1: ' + _line) + svc.Output.remove(_line) tupleFile = get_slot_value(slots, "TupleFile") tupleStr = "FILE1 DATAFILE='%s' TYP='ROOT' OPT='NEW'" % tupleFile - svc.Output += [ tupleStr ] - svc.OutputLevel = 1 + svc.Output += [tupleStr] + svc.OutputLevel = 1 def configure_event_persistency(svc): @@ -95,5 +92,5 @@ def configure_event_selector(svc, slots): if printFreq == 0: printFreq = get_default_value("PrintFreq") log = get_slot_value(slots, "Log") - log.warning("Print frequency cannot be 0. Set to %f." %printFreq) + log.warning("Print frequency cannot be 0. Set to %f." % printFreq) svc.PrintFreq = printFreq