Skip to content

Commit

Permalink
disable joblib for py2; ignore deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Oct 5, 2024
1 parent a9fc439 commit 4f58533
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .aux/test_with_lcg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ CMTCONFIG=$2
source /cvmfs/sft.cern.ch/lcg/views/${LCG}/${CMTCONFIG}/setup.sh
source build/INSTALL/thisostap.sh
cd build
ctest -N && cmake .. -DCMAKE_INSTALL_PREFIX=./INSTALL/ && ctest -j4 --output-on-failure --test-output-size-failed=5000000
ctest -N && cmake .. -DCMAKE_INSTALL_PREFIX=./INSTALL/ && ctest -j4 -R '(gof|stat)' --output-on-failure --test-output-size-failed=5000000
24 changes: 12 additions & 12 deletions ostap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,21 @@ if ( ${PYTHON_VERSION} VERSION_GREATER_EQUAL "3.7" )
message ( "----> warning (optional) lmdb is NOT found!" )
endif()
endif()
endif()

endif()
# =======================================================================================
## joblib: run some numpy-related code in parallel
# =======================================================================================

find_python_module ( joblib QUIET )
if ( NOT ${PY_joblib_FOUND} )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install joblib ${PIP_ARGS})
endif()
find_python_module ( joblib QUIET )
if ( NOT ${PY_joblib_FOUND} )
message ( "----> warning (optional) joblib is NOT found!" )
endif()

if ( ${PYTHON_VERSION} VERSION_GREATER_EQUAL "3.0" )
find_python_module ( joblib QUIET )
if ( NOT ${PY_joblib_FOUND} )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install joblib ${PIP_ARGS})
endif()
find_python_module ( joblib QUIET )
if ( NOT ${PY_joblib_FOUND} )
message ( "----> warning (optional) joblib is NOT found!" )
endif()
endif()
# ========================================================================================
## terminaltables3 & terminaltables
# ========================================================================================
Expand Down
24 changes: 17 additions & 7 deletions ostap/stats/gof_np.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'PPDNP' , ## Point-to-Point Dissimilarity Goodness-of-fit method
)
# =============================================================================
from ostap.core.meta_info import python_info
from ostap.core.ostap_types import string_types
from ostap.stats.gof import normalize2
from ostap.core.core import SE, VE
Expand Down Expand Up @@ -207,12 +208,21 @@ def psi_conf ( psi , scale = 1.0 ) :

raise TypeError ( "Unknown `psi':%s" % psi )

try :
import joblib as jl
except ImportError :
jl = None

# =====================================================================
# =============================================================================
jl = None
# =============================================================================
try : # =======================================================================
# =========================================================================
if ( 3 , 0 ) <= python_info :
with warnings.catch_warnings():
warnings.simplefilter ( "ignore" , category = DeprecationWarning )
import joblib as jl
# =========================================================================
except ImportError : # ========================================================
# =========================================================================
jl = None
# =============================================================================
## @class PERMUTATOR
# Helper class that allow to run permutattion test in parallel
class PERMUTATOR(object) :
Expand Down Expand Up @@ -240,7 +250,7 @@ def __call__ ( self , N , silent = True ) :
return counter

# =============================================================================
if jl : # =====================================================================
if jl and ( 3 , 0 ) <= python_info : # ========================================
# =========================================================================
## Run NN-permutations in parallel using joblib
def joblib_run ( self , NN , silent = True ) :
Expand All @@ -253,8 +263,8 @@ def joblib_run ( self , NN , silent = True ) :
elif '1.4.0' <= jl.__version__ : conf [ 'return_as' ] = 'unordered_generator'
##
input = ( jl.delayed (self)( N ) for N in lst )
results = jl.Parallel ( **conf ) ( input )
counter = EffCounter()
results = jl.Parallel ( **conf ) ( input )
for r in progress_bar ( results , max_value = nj , silent = silent ) :
counter += r
#
Expand Down

0 comments on commit 4f58533

Please sign in to comment.