-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ui: don't show exception for "Too many files" error #3058
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
Conversation
@efiop can include the output after this change, please? |
@shcheklein not sure I follow, could you rephrase, please? |
I mean the CLI output after this changes vs what was before. The same way as @pared included then in the docs discussion. It's hard otherwise to see the difference and understand how does it looks like. |
@shcheklein Ah, right. So before:
after:
|
@efiop so, i'm lost then :) how does it correspond with this one - iterative/dvc.org#875 (comment) ? was it just a suggestion? |
@shcheklein I've removed the unnecessary second |
@efiop got it! thanks. |
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.
looks good 👍
@efiop , what about showing the whole stack every time? |
@MrOutis what about it? We don't unless |
mhm, then I think I didn't get the purpose of this PR
Why are you passing the |
@MrOutis I do, but only on |
@efiop , it is hard to me to review this 🤔 I have mixed feelings about the way we are handling exceptions and displaying error messages. I think the don't show exception for "Too many files" error could be solved by doing
The "Too many files" is the message that we are displaying with Still confused why we need to deal with the stack trace. By the way, @efiop , the WIP PR that I was talking about is right here: #3059 😅 |
But raise where? We don't have control over it, so we will have to hack to delete the exception. Also, that would remove the traceback from |
True that. Anyways, using I'd better opt to add an extra argument to the exception itself and handle it correctly on the logger. except Exception as exc: # pylint: disable=broad-except
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
exc.display_only_message = True
logger.exception(
"too many open files, please increase your `ulimit`"
) EDIT: It looks ugly 😅 There's another one, modifying the exception arguments, if we don't care about the message: except Exception as exc: # pylint: disable=broad-except
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
exc.args = ("too many open files, please increase your `ulimit`",)
logger.exception("") EDIT 2: Ok ok, a mix of both approaches: except Exception as exc: # pylint: disable=broad-except
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
exc.alternative_message = "too many open files, please increase your `ulimit`"
logger.exception("") and a one-liner (without tests 😅 ) change in the following PR: #3059) @@ -65,7 +65,7 @@ class ColorFormatter(logging.Formatter):
info = "{message}{separator}{exception}{cause}".format(
message=record.msg or "",
separator=" - " if record.msg and exception.args else "",
- exception=exception,
+ exception=exception.alt_message or exception,
cause=": " + str(cause) if cause else "",
) |
We NEVER display tracebacks in non-verbose mode, hence why we have all that code in logger.py to handle it.
Now that's a hack 🙂 |
@efiop , agree with your comments, your patch solve the problem 🙂 I just felt that it is misleading that we were using If we were doing so, the message would be something like:
Isn't |
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.
To summarize, my point is that stack_info
is not following the expected behavior, and it is used to mask a message. This is misleading, but it works.
I can't offer a better solution, so I agree with going with the one you suggested.
@MrOutis |
iterative/dvc.org#875 (comment) Stops showing the exception in non-verbose mode, but shows full traceback in verbose mode. Introducing our custom parameter `tb_only` through standard `extra` logging parameter.
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.
Looks good, @efiop ! Thanks for taking it into account 🙂
iterative/dvc.org#875 (comment)
Stops showing the exception in non-verbose mode, but shows full
traceback in verbose mode.
Introducing our custom parameter
tb_only
through standardextra
logging parameter.
❗ Have you followed the guidelines in the Contributing to DVC list?
📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏