Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework python import tests to test each package separately #22460

Merged
merged 2 commits into from Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 32 additions & 15 deletions PhysicsTools/PythonAnalysis/test/imports.py
@@ -1,6 +1,21 @@
#!/usr/bin/env python
import traceback
import os, sys
#import gc

#class Importer:
# def __init__(self,name):
# self.error=0
# try:
# importlib.import_module(i)
# print "Done"
# except Exception as e:
# print "Fail"
# print traceback.format_exc()
# self.error = 1
#
# def err(self):
# return self.error

baseDirs=[]
from subprocess import Popen,PIPE
Expand All @@ -23,26 +38,28 @@
l.append(file)
break

print l

#print l
skipIt=['pytest','climate','theanets','hyperopt','thriftpy']
# climate misses plac
# pytest misses py
# theanets misses plac
# xrootdpyfs misses from fs.errors import DestinationExistsError, DirectoryNotEmptyError, \
#ImportError: cannot import name DestinationExistsError
#hyperopt misses builtins
#thriftpy misses ply
import importlib
err = 0
#unless the llvm version in cmssw matches that of root, uproot needs to be
#tested separately (https://github.com/scikit-hep/uproot/issues/58)


#import importlib
#err = 0
for i in l:
if i in skipIt: continue
print "Importing",i,".....",
try:
importlib.import_module(i)
print "Done"
except Exception as e:
print "Fail"
print traceback.format_exc()
err += 1
sys.exit(err)
print i
#
# if i in skipIt: continue
# print "Importing",i,".....",
# d=Importer(i)
# err+=d.err()
# del d
# gc.collect()
#
#sys.exit(err)
6 changes: 5 additions & 1 deletion PhysicsTools/PythonAnalysis/test/imports.sh
Expand Up @@ -15,7 +15,11 @@ python -c 'import theano; print(theano.config)'
echo ">>> Cleaning compile cache"
theano-cache clear

python ${CMSSW_BASE}/src/PhysicsTools/PythonAnalysis/test/imports.py
for i in $(python ${CMSSW_BASE}/src/PhysicsTools/PythonAnalysis/test/imports.py)
do
echo "importing $i"
python -c "import $i"
done

echo ">>> Cleaning compile cache"
theano-cache clear
Expand Down