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
More informative exception text for failing pre/post conditions using pdp.cond.Condition objects #68
Comments
Hi Shy, For displaying an error message specific to a condition, (Example - For displaying a more specific error message, (Example - Does it align with what you have in mind? |
I'll say let's start with the more basic type of prints, because thinking about this again it seems like most stages will have to be re-written with a more complex and less efficient code to be able to tell this. And the simpler implementation can just have a custom attribute that each condition must populate, with the I would go with a name that shows this attribute is part of the api, so Then, the different methods of def fit(self, X, y=None, exraise=None, verbose=False):
if exraise is None:
exraise = self._exraise
if self._compound_prec(X):
if verbose:
msg = '- ' + '\n '.join(textwrap.wrap(self._appmsg))
print(msg, flush=True)
res_df = self._fit_transform(X, verbose=verbose)
if exraise and not self._compound_post(df=res_df):
try:
raise FailedPostconditionError(self._compound_post.error_message)
except AttributeError:
raise FailedPostconditionError(self._exmsg_post)
return X
if exraise:
try:
raise FailedPreconditionError(self._compound_prec.error_message)
except AttributeError:
raise FailedPreconditionError(self._exmsg)
return X |
We have to do this because a condition can be any |
Thanks for the detailed explanation! Just to check again,
Also would it be more helpful for user if we give them the
|
Yes, just add the Regarding 2: Yeah, good idea. Also, a fix to my mistake: It should be |
If I'm using a
pdp.cond.Condition
object, for examplepdp.cond.HasAllColumns(['a', 'b'])
, as a precondition (or a post-condition) in my pipeline stage and it fails, I expect an informative exception message, such as"Not all required columns ['a', 'b'] found in input dataframe"
(or better yet,"Required columns ['a'] not found in input dataframe"
, in the case only"a"
is missing).This is something that can be achieved by using custom descriptions of specific
Condition
classes, as they provide semantic information on why they failed (or at least, they could).At the moment, I get a generic
"Precondition failed in stage..."
. :(The text was updated successfully, but these errors were encountered: