[autoparallel] refactored the autoparallel module for organization (#1706)

* [autoparallel] refactored the autoparallel module for organization

* polish code
This commit is contained in:
Frank Lee
2022-10-14 13:27:00 +08:00
committed by GitHub
parent 91cd34e6e0
commit 6c331a5a09
57 changed files with 408 additions and 799 deletions

View File

@@ -0,0 +1,26 @@
import functools
import warnings
__all__ = ['exception_handler']
def exception_handler(func):
"""
A function wrapper to handle the AssertionError in the function.
Usage:
# mute the assertion error in the function
@exception_handler
def do_something():
...
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
rst = func(*args, **kwargs)
return rst
except AssertionError as e:
warnings.warn(f'{e}')
return wrapper