-
Notifications
You must be signed in to change notification settings - Fork 203
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
deprecate log.error and log.exception in favor of log.fatal (WIP) #1183
Conversation
Refer to this link for build results (access rights to CI server needed): |
@@ -214,6 +214,18 @@ def _init_log(self): | |||
|
|||
self.log = fancylogger.getLogger(name=self.__class__.__name__, fname=False) | |||
|
|||
# deprecate self.log.error in easyblocks, self.log.fatal should be used instead | |||
def error(msg, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't self
missing from this method's signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure yet whether this is actually worth the trouble...
This will not catch all occurrences of the use of the error()
log method anyway (see for example https://github.com/hpcugent/easybuild-easyblocks/blob/master/easybuild/easyblocks/generic/intelbase.py#L51).
I'm strongly considering just dropping the custom definition of error
(and exception
too, while we're at it) all together, and announcing this breaking change on the mailing list (before it gets merged).
This will only affect easyblocks that have not been contributed back, in the sense that the log.error
still being used in them will no longer raise an EasyBuildError
, and hence will (hopefully) crash and burn somewhere else rather than with a clean error message...
I think we can get away with this by including it in EasyBuild v2.0 (since people are likely to revisit their in-house easyblocks anyway because of http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.htm .
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@riccardomurri: no, self
is part of args
; I can add self
explicitly though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree: if you are going to make breaking changes, then v2.0.0 is a better place for them than a minor release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, a call to self.error(msg, args)
inside an easyblock will result in a call EasyBlock.error(self, msg, args)
because it's a class method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JensTimmerman: error
will still be there, yes, but not with the intended behaviour anymore since it's no longer redefined in EasyBuildLog
anyway, this PR will change significantly after some discussion with @stdweird, hold on...
Just to clarify to others that were not involved in this discussion: this change is being made because EasyBuild modifies the semantics of the standard This has serious consequences for 3rd party libraries like GC3Pie, since if they use The proper (yet painful) solution is to define our own logging method that both logs and raises, which is the |
Looks fine by me but I would change the name. |
Another option is to introduce a The only 'problem' then is that we need to pass the logger instance to this fail method, e.g.: fail("FAIL!", log=self.log) |
self.raiseError = True | ||
|
||
raise EasyBuildError(newMsg) | ||
self.log.deprecated("Use fatal() for logging/raise errors, rather than exception()", '3.0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at the above code again. exception
never raised anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm
will be reworked once hpcugent/vsc-base#156 is merged in |
vsc base was updated |
Why not have your fatal exceptions log the message? E.g., something
This would allow you to do::
and use a logger defined in the caller's environment, or to specify
|
👍 I like riccardomurri's suggestion a lot you could add an else case to use the rootlogger (or another default, maybe an exceptionlogger) if no logger was found. |
I like @riccardomurri's idea too... We can maybe even go about this without the fancy I'll look into revamping this PR with an approach like that, thanks for the excellent suggestion @riccardomurri! |
@boegel please keep the inspect stuff. there's no real reason to throw it away. correct logger is the way to go (or we switch to root logger only in whole of EB). |
I agree with stdweird, the inspect stuff might slow things down, but in easybuild you always quit after an EasyBuildException has been thrown, so having it do an inspect right at the end of your execution is not a big deal. |
implementation for |
different approach following @riccardomurri's suggestion in #1218, closing this as a dead end |
@stdweird, @JensTimmerman: as discussed yesterday
This PR is not complete yet, the replacement needs to be done in other modules too, but I'd like to get feedback on this first before I make the diff even more unreadable...
A similar cleanup will have to be done in the easyblocks.
This makes #1171, #1174, #1179 and #1182 futile.
cc @riccardomurri