From c21fd876601ea75ac4b2a351df6ea0f7a7ae5e1c Mon Sep 17 00:00:00 2001 From: amete <serhanmete@gmail.com> Date: Tue, 1 Dec 2020 13:30:49 +0100 Subject: [PATCH] PerfMonVTune: Update python files and enable flake8 --- .../PerfMonVTune/CMakeLists.txt | 8 ++--- .../PerfMonVTune/scripts/vtune_athena.py | 34 ++++++++----------- .../share/VTuneProfileEventLoop_preInclude.py | 4 ++- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Control/PerformanceMonitoring/PerfMonVTune/CMakeLists.txt b/Control/PerformanceMonitoring/PerfMonVTune/CMakeLists.txt index 51ae73f5f861..dc7d818ad525 100644 --- a/Control/PerformanceMonitoring/PerfMonVTune/CMakeLists.txt +++ b/Control/PerformanceMonitoring/PerfMonVTune/CMakeLists.txt @@ -5,7 +5,7 @@ atlas_subdir( PerfMonVTune ) #### # VTune hack for the time-being -find_program( VTUNE_EXECUTABLE amplxe-cl ) +find_program( VTUNE_EXECUTABLE vtune ) get_filename_component( VTUNE_DIR ${VTUNE_EXECUTABLE} PATH ) set( ITT_PREFIX ${VTUNE_DIR}/.. ) @@ -22,6 +22,6 @@ atlas_add_component( PerfMonVTune LINK_LIBRARIES GaudiKernel AthenaBaseComps AthenaKernel ${ITT_LIBRARY} ${CMAKE_DL_LIBS} ) # Install files from the package: -atlas_install_python_modules( python/*.py ) -atlas_install_joboptions( share/*.py ) -atlas_install_scripts( scripts/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) +atlas_install_joboptions( share/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) +atlas_install_scripts( scripts/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Control/PerformanceMonitoring/PerfMonVTune/scripts/vtune_athena.py b/Control/PerformanceMonitoring/PerfMonVTune/scripts/vtune_athena.py index 673ebba0b9e5..8306d0c46486 100755 --- a/Control/PerformanceMonitoring/PerfMonVTune/scripts/vtune_athena.py +++ b/Control/PerformanceMonitoring/PerfMonVTune/scripts/vtune_athena.py @@ -1,14 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 -# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -import glob import logging -import multiprocessing -import os import subprocess import sys -import uuid # Setting logging options fmt = '%(asctime)s :: %(levelname)-8s :: %(message)s' @@ -25,32 +21,32 @@ console.setFormatter(formatter) logger.addHandler(console) #### -## Check Athena Setup +## Check Athena Setup #### def checkAthenaSetup(): try: - a = subprocess.check_output(['athena','--version']) + a = subprocess.check_output(['athena','--version']) logger.debug('Athena version information \n %s',a) - except: + except Exception: logger.fatal('Athena is not setup!') - sys.exit(-1) + sys.exit(-1) #### ## Check VTune Setup #### def checkVTuneSetup(): try: - a = subprocess.check_output(['amplxe-cl','--version']) + a = subprocess.check_output(['vtune','--version']) logger.debug('VTune version information \n %s',a) - except: + except Exception: logger.fatal('VTune is not setup!') - sys.exit(-1) + sys.exit(-1) #### -## AutoGen a jobOptions fragment +## AutoGen a jobOptions fragment #### def generateJOFragment(fileName,firstEvent,lastEvent): - logger.info('Creating jOptions fragment %s', fileName) + logger.info('Creating jOptions fragment %s', fileName) with open('{}'.format(fileName),'w') as f: f.write('# Auto generated jobOptions fragment to setup Athena VTune profiler') f.write('\ninclude(\'PerfMonVTune/VTuneProfileEventLoop_preInclude.py\')') @@ -122,11 +118,11 @@ def main(): checkAthenaSetup() checkVTuneSetup() - # Perpare the JO fragment + # Perpare the JO fragment joFragment = 'PerfMonVTune_autoSetup.py' - generateJOFragment(joFragment, options.start, options.stop) + generateJOFragment(joFragment, options.start, options.stop) - # Prepare the transformation command to execute + # Prepare the transformation command to execute if not options.tf: logger.fatal('The transformation command is empty, quitting...') sys.exit(-1) @@ -139,7 +135,7 @@ def main(): args.extend(['--preInclude',joFragment]) # Run the command - cmd = ( 'amplxe-cl' + + cmd = ( 'vtune' + ' -collect ' + options.collect + ' -strategy ' + options.strategy + ' -start-paused -- ' ) diff --git a/Control/PerformanceMonitoring/PerfMonVTune/share/VTuneProfileEventLoop_preInclude.py b/Control/PerformanceMonitoring/PerfMonVTune/share/VTuneProfileEventLoop_preInclude.py index 4240d9f37e01..88d01d7a86a1 100644 --- a/Control/PerformanceMonitoring/PerfMonVTune/share/VTuneProfileEventLoop_preInclude.py +++ b/Control/PerformanceMonitoring/PerfMonVTune/share/VTuneProfileEventLoop_preInclude.py @@ -1,3 +1,5 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + # Set up the profiler service: from AthenaCommon.AppMgr import ServiceMgr from PerfMonVTune.PerfMonVTuneConf import VTuneProfilerService @@ -6,7 +8,7 @@ ServiceMgr += VTuneProfilerService("VTuneProfilerService") ServiceMgr.VTuneProfilerService.ResumeEvent = 10 # Set up the profiler service as the first service to be created: -theApp.CreateSvc.insert( 0, "VTuneProfilerService/VTuneProfilerService" ) +theApp.CreateSvc.insert( 0, "VTuneProfilerService/VTuneProfilerService" ) # noqa: F821 # Print a message with what happened: from AthenaCommon.Logging import logging -- GitLab