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

Add post_func_skip_list to control execution of post functions #644

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(
step=1,
data=None,
convergence_check=True,
post_func_skip_list=None,
**kwargs,
):
"""Constructor.
Expand Down Expand Up @@ -163,6 +164,8 @@ def __init__(
The raw data of System class.
convergence_check : boolean
Whether to request a convergence check.
post_func_skip_list : list of str
The list of post function names to skip.
**kwargs : dict
other parameters
"""
Expand All @@ -180,6 +183,9 @@ def __init__(
return
if file_name is None:
return
self.post_func_skip_list = (
post_func_skip_list if post_func_skip_list is not None else []
)
self.from_fmt(
file_name,
fmt,
Expand Down Expand Up @@ -229,7 +235,12 @@ def from_fmt_obj(self, fmtobj, file_name, **kwargs):
self.data = {**self.data, **data}
self.check_data()
if hasattr(fmtobj.from_system, "post_func"):
assert isinstance(
self.post_func_skip_list, list
), "post_func_skip_list should be a list of string"
for post_f in fmtobj.from_system.post_func:
if post_f in self.post_func_skip_list:
continue
self.post_funcs.get_plugin(post_f)(self)
return self

Expand Down
Loading