pytorch-lightning icon indicating copy to clipboard operation
pytorch-lightning copied to clipboard

Unhelpful Error Messaging

Open oojo12 opened this issue 2 years ago • 0 comments

🐛 Bug

Lightning does not appropriately relay the origin of a traceback error.

To Reproduce

app.py

import lightning as L

class Work(L.LightningWork):
    def __init__(self) -> None:
        super().__init__()
        self.records = {}


    def run(self):
        self.record[1] = 2

class LitApp(L.LightningFlow):
    def __init__(self) -> None:
        super().__init__()
        self.work = Work()

    def run(self):
        self.work.run()


app = L.LightningApp(LitApp())

error is helpful here

Your Lightning App is starting. This won't take long.
INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
Process Process-2:
Traceback (most recent call last):
  File "C:\Users\Olufemi Ojo\anaconda3\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "C:\Users\Olufemi Ojo\anaconda3\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\utilities\proxies.py", line 308, in __call__
    raise e
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\utilities\proxies.py", line 291, in __call__
    self.run_once()
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\utilities\proxies.py", line 400, in run_once
    self.work.on_exception(e)
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\core\work.py", line 471, in on_exception
    raise exception
INFO: Your Lightning App is being stopped. This won't take long.
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\utilities\proxies.py", line 391, in run_once
    ret = work_run(*args, **kwargs)
  File "C:\Users\Olufemi Ojo\Documents\monitor-network\failure_loading_cloud_app.py", line 10, in run
    self.record[1] = 2

however, making it more complicated gives various unhelpful errors like the below

Your Lightning App is starting. This won't take long.
INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
this is a simple Lightning app to verify your component is working as expected
Process Process-2:
INFO: Your Lightning App is being stopped. This won't take long.
INFO: Your Lightning App has been stopped successfully!

Another error with an example like the first case

app.py

import lightning as L

class Work(L.LightningWork):
    def __init__(self) -> None:
        super().__init__()
        self.records = {}


    def run(self):
        '''
        just extra stuff
        '''
        a = 25
        b = 32

        for i in range(a):
            b += i
            
        self.record[1] = 2

class LitApp(L.LightningFlow):
    def __init__(self) -> None:
        super().__init__()
        self.work = Work()

    def run(self):
        self.work.run()


app = L.LightningApp(LitApp())

error

Your Lightning App is starting. This won't take long.
INFO: Your app has started. View it in your browser: http://127.0.0.1:7501/view
Process Process-2:
Traceback (most recent call last):
  File "C:\Users\Olufemi Ojo\anaconda3\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
INFO: Your Lightning App is being stopped. This won't take long.
  File "C:\Users\Olufemi Ojo\anaconda3\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Olufemi Ojo\Documents\envs\network\lib\site-packages\lightning_app\utilities\proxies.py", line 308, in __call__
    raise e
INFO: Your Lightning App has been stopped successfully!

fixing the typo resolves the problem.

Expected behavior

I get an error message like "Work has no attribute self.record"

Environment

  • CUDA: - GPU: - available: False - version: None
  • Packages: - lightning: 2022.7.18 - lightning_app: 0.5.2 - numpy: 1.23.1 - pyTorch_debug: False - pyTorch_version: 1.12.0+cpu - pytorch-lightning: 1.6.5 - tqdm: 4.64.0
  • System: - OS: Windows - architecture: - 64bit - WindowsPE - processor: Intel64 Family 6 Model 140 Stepping 1, GenuineIntel - python: 3.9.7 - version: 10.0.22000

Note

there are other error cases I have found let me know if it is helpful to add to this or create a separate GitHub issue.

oojo12 avatar Jul 29 '22 17:07 oojo12