Skip to content

Commit

Permalink
1. Add (fictive) contetx mnager protocol to WorkManager
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Oct 10, 2024
1 parent 22179c1 commit c29eb24
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ReleaseNotes/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
1. add meaningful `description` argument to all `progress_bar` instance
1. extend `gof1d` and `gofnd` tests
1. Add `RooAddPdf::fixCoefNormalization( vars )` for all appearences of `RooAddPdf`

1. Add (fictive) contetx mnager protocol to WorkManager

## Backward incompatible

## Bug fixes
Expand Down
18 changes: 16 additions & 2 deletions ostap/parallel/parallel_gaudi.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,22 @@ def iexecute ( self , job , jobs_args , progress = False , **kwargs ) :
def get_pp_stat ( self ) :
""" Get PP-statistics if/when possible
"""
return None

return None

## context protocol: restart the pool
def __enter__ ( self ) :
sys.stdout .flush ()
sys.stderr .flush ()
return self

## context protocol: close/join/clear the pool
def __exit__ ( self , *_ ) :
if self.pool :
self.pool.close()
self.pool.join ()
sys.stdout .flush ()
sys.stderr .flush ()

# =============================================================================
if '__main__' == __name__ :

Expand Down
13 changes: 12 additions & 1 deletion ostap/parallel/parallel_ipyparallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__( self ,
self.__balanced = True if balanced else False
self.__use_dill = True if use_dill else False
if self.__use_dill and not dill :
logger.warning ( "dill is not available, swithc it off" )
logger.warning ( "dill is not available, switch it off!" )
self.__use_dill = False

if not self.silent :
Expand Down Expand Up @@ -169,6 +169,17 @@ def get_pp_stat ( self ) :
"""
return None

## context protocol
def __enter__ ( self ) :
sys.stdout .flush ()
sys.stderr .flush ()
return self

## context protocol
def __exit__ ( self , *_ ) :
sys.stdout .flush ()
sys.stderr .flush ()

# =========================================================================
## define "importable" content of the module:
__all__ = __all__ + (
Expand Down

0 comments on commit c29eb24

Please sign in to comment.