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

derive EasyBuildError from LoggedException, deprecate log.error in favor of raise EasyBuildError #1218

Merged
merged 17 commits into from
Mar 31, 2015

Conversation

@boegel
Copy link
Member Author

boegel commented Mar 11, 2015

This is just a proof-of-concept, all other uses of log.error (and log.exception) still need to be replaced, but I didn't want to make the diff huge to start off with.

@stdweird, @JensTimmerman, @riccardomurri: thoughts?

@@ -94,7 +95,7 @@ def experimental(self, msg, *args, **kwargs):
self.warning(msg, *args, **kwargs)
else:
msg = 'Experimental functionality. Behaviour might change/be removed later (use --experimental option to enable). ' + msg
self.error(msg, *args)
raise EasyBuildError(msg % args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not support EasyBuildError(msg, *args) ?

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1487/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 13, 2015

remarks fixed, pls rereview @stdweird?

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1498/
Test FAILed.

class EasyBuildError(Exception):
# 1st argument (a LoggedException instance) is ignored
def log_error_no_raise(_, logger, msg):
"""Utility function to log an error with raising an exception."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thsi method is deprected and add _ to indicate it's private

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1509/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 17, 2015

remarks fixed, please revisit before I tackle all remaining occurences of log.error into raise EasyBuildError

orig_raise_error = self.raiseError
self.raiseError = False

self.deprecated("Use of dedicated _error_no_raise log method", '3.0')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have to revisit this bit, since the tests treat all log.deprecated statements being hit as errors (by defining EASYBUILD_DEPRECATED to same ridiculously high version)

I don't think that'll work out well (since we'll be hitting this one all the time). Not sure where I can move this though for proper deprecation of _error_no_raise...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After giving this some more thought, I don't think we should be using log.deprecated at all here...

The idea behind the log.deprecated is to indicate that deprecated functionality, i.e. stuff that will be removed in the future, is being triggered.

In this case _error_no_raise actually implement the behaviour that we want to be using, so it shouldn't trigger log.deprecated at all... Leaving it like this, we'll be triggering log.deprecated whenever an EasyBuildError is created.

I'll see if I can refurbish things to log.error being the behaviour we want (no raise), and move the bit currently in error that does the raise in a separate method that does contain log.deprecated.

I'm not sure that will fly though, since by default we actually want log.error to still raise, for now (to retain backward-compatibility).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then simply add comment that indicates that method should never be used and that we are going to remove this in 3.0. no need to hack more around. it's already bad enough 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will do

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1510/
Test FAILed.

self.msg = msg

def __str__(self):
"""Return string representation of this EasyBuildError instance."""
print '__str__'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't print

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1515/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

(GitHub was having some problems at the time the tests ran, so I've retriggered them)

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1566/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

and again...

Jenkins: test this please

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1567/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1568/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1569/
Test FAILed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1572/
Test FAILed.

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

2 similar comments
@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

@boegel
Copy link
Member Author

boegel commented Mar 27, 2015

Jenkins: test this please

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1577/
Test FAILed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1579/
Test FAILed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1580/
Test PASSed.

@hpcugentbot
Copy link
Contributor

Refer to this link for build results (access rights to CI server needed):
https://jenkins1.ugent.be/job/easybuild-framework-pr-builder/1582/
Test PASSed.

orig_raise_error = self.raiseError
self.raiseError = False

self.error(msg)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to change this using Fancylogger.error, otherwise errors are reporting in the logs like:

== 2015-03-31 13:34:58,605 main ERROR EasyBuild crashed with an error
(at easybuild/tools/build_log.py:136 in _error_no_raise):
Can't find path /Users/kehoste/work/easybuild-framework/foo.eb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while it used to be like:

ERROR: EasyBuild crashed with an error (at easybuild/framework/easyconfig/tools.py:317 in parse_easyconfigs):
Can't find path /Users/kehoste/work/easybuild-framework/foo.eb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll handle this in a follow-up PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #1249

@boegel
Copy link
Member Author

boegel commented Mar 31, 2015

That's it, I'm merging in this beast. Progress!

Thanks for the review @stdweird!

boegel added a commit that referenced this pull request Mar 31, 2015
derive EasyBuildError from LoggedException, deprecate log.error in favor of raise EasyBuildError
@boegel boegel merged commit 93a6560 into easybuilders:develop Mar 31, 2015
@boegel boegel deleted the raise_error branch March 31, 2015 14:27
@boegel boegel mentioned this pull request Jun 24, 2015
@boegel boegel mentioned this pull request Jul 7, 2015
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants