Skip to content

Commit

Permalink
suppress ipyparalell warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Sep 26, 2024
1 parent f50b4c4 commit ff7bd61
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
33 changes: 16 additions & 17 deletions ostap/parallel/parallel_ipyparallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__( self ,
# - no summary printout
# - no merging of results
def iexecute ( self , job , jobs_args , progress = False ) :
"""Process the bare `executor` function
""" Process the bare `executor` function
>>> mgr = WorkManager ( .... )
>>> job = ...
>>> args = ...
Expand All @@ -127,23 +127,22 @@ def iexecute ( self , job , jobs_args , progress = False ) :
silent = self.silent or not progress
with warnings.catch_warnings() :
warnings.simplefilter('ignore', category=UserWarning)
cluster = ipp.Cluster ( **self.__kwargs )
with cluster :
with ipp.Cluster ( **self.__kwargs ) as cluster :

if self.__use_dill :
view = cluster[:]
view.use_dill()
elif self.__balanced :
view = cluster.load_balanced_view()
else :
view = cluster[:]

results = view.map_async ( job , jobs_args )

for result in progress_bar ( results ,
description = "# Jobs execution" ,
silent = silent ) :
yield result
if self.__use_dill :
view = cluster[:]
view.use_dill ()
elif self.__balanced :
view = cluster.load_balanced_view()
else :
view = cluster[:]
results = view.map_async ( job , jobs_args )
for result in progress_bar ( results ,
description = "# Jobs execution" ,
silent = silent ) :
yield result

# ========================================================================-
## get PP-statistics if/when possible
Expand Down
36 changes: 17 additions & 19 deletions ostap/parallel/tests/test_parallel_ipyparallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ def test_ipyparallel_function () :
result = None
with warnings.catch_warnings() :
warnings.simplefilter('ignore', category=UserWarning)
cluster = ipp.Cluster ()
with cluster :
with ipp.Cluster () as cluster :

view = cluster.load_balanced_view()
results = view.map_async ( make_histos , zip ( count () , inputs ) )

for r in progress_bar ( results ) :
if not result : result = r
else : result.Add ( r )
view = cluster.load_balanced_view()
results = view.map_async ( make_histos , zip ( count () , inputs ) )
for r in progress_bar ( results ) :
if not result : result = r
else : result.Add ( r )

with use_canvas ( 'test_ipyparallel_function' , wait = 2 ) :
logger.info ( "Histogram is %s" % result.dump ( 80 , 20 ) )
Expand Down Expand Up @@ -135,18 +134,17 @@ def test_ipyparallel_callable () :
result = None
with warnings.catch_warnings() :
warnings.simplefilter('ignore', category=UserWarning)
cluster = ipp.Cluster ()
with cluster :

##view = cluster.load_balanced_view()
view = cluster[:]
view.use_dill()
with ipp.Cluster () as cluster :

results = view.map_async ( mh , zip ( count () , inputs ) )

for r in progress_bar ( results ) :
if not result : result = r
else : result.Add ( r )
##view = cluster.load_balanced_view()
view = cluster[:]
view.use_dill()

results = view.map_async ( mh , zip ( count () , inputs ) )

for r in progress_bar ( results ) :
if not result : result = r
else : result.Add ( r )

with use_canvas ( 'test_ipyparallel_function' , wait = 2 ) :
logger.info ( "Histogram is %s" % result.dump ( 80 , 20 ) )
Expand Down

0 comments on commit ff7bd61

Please sign in to comment.