question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception during exception handling

See original GitHub issue

Hey,

I have some issues with the exception handling in sacred: Consider the slightly modified “hello world” example from the docs which throws an exception:

main.py:

from sacred import Experiment

ex = Experiment('hello_config')

@ex.config
def my_config():
    recipient = "world"
    message = "Hello %s!" % recipient

@ex.automain
def my_main(message):
    raise ValueError("Some Error")

Now, python main.py produces the following output:

WARNING - hello_config - No observers have been added to this run
INFO - hello_config - Running command 'my_main'
INFO - hello_config - Started
ERROR - hello_config - Failed after 0:00:00!
Traceback (most recent call last):
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/experiment.py", line 312, in run_commandline
    return self.run(
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/experiment.py", line 276, in run
    run()
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/run.py", line 238, in __call__
    self.result = self.main_function(*args)
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/config/captured_function.py", line 42, in captured_function
    result = wrapped(*args, **kwargs)
  File "/home/markus/test/sacred_test/main.py", line 12, in my_main
    raise ValueError("Some Error")
ValueError: Some Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/markus/test/sacred_test/main.py", line 11, in <module>
    def my_main(message):
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/experiment.py", line 190, in automain
    self.run_commandline()
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/experiment.py", line 347, in run_commandline
    print_filtered_stacktrace()
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/utils.py", line 493, in print_filtered_stacktrace
    print(format_filtered_stacktrace(filter_traceback), file=sys.stderr)
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/utils.py", line 528, in format_filtered_stacktrace
    return "".join(filtered_traceback_format(tb_exception))
  File "/home/markus/test/sacred_test/env/lib64/python3.9/site-packages/sacred/utils.py", line 568, in filtered_traceback_format
    current_tb = tb_exception.exc_traceback
AttributeError: 'TracebackException' object has no attribute 'exc_traceback'

i.e. there is another exception during the handling of the ValueError.

This was produced on a fresh virtual environment with Python 3.9.7 and Sacred 0.8.2. The behavior is reproducible across several machines and was also observed by a coworker. It is also mentioned here: https://stackoverflow.com/questions/67014839/attributeerror-tracebackexception-object-has-no-attribute-exc-trackback-err and here: https://github.com/ray-project/ray/issues/5181 This issue seems to be relatively new, but I cannot track down, what versions/changes introduced this behavior.

This is a major issue for us because we intentionally raise exceptions to log and schedule restarts of the experiments.

I would be grateful for some help!

Best, Markus

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Rocamondecommented, Oct 29, 2022

Same exception, same problem. This does not seem to be fixed.

1reaction
thequilocommented, Oct 8, 2021

Yes, I think that that commit fixed the exception handling for Python 3.9. It could be time for a new release on pypi with the fixes for Python 3.9.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Throwing an exception while handling an exception
There are cases where exception handling must be abandoned for less subtle error-handling techniques. The guiding principles are: Don't throw an ...
Read more >
What is Exception Handling? - SearchSoftwareQuality
Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events...
Read more >
Exceptions in Java - GeeksforGeeks
Customized Exception Handling: Java exception handling is managed via five keywords: try, catch, throw, throws, and finally. Briefly, here is ...
Read more >
Exception Handling in Java - Javatpoint
Exception Handling is a mechanism to handle runtime errors such as ClassNotFoundException, IOException, SQLException, RemoteException, etc.
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
If an exception occurs which does not match the exception named in the except clause, it is passed on to outer try statements;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found