kedro-org / kedro-viz

Visualise your Kedro data and machine-learning pipelines and track your experiments.
https://demo.kedro.org
Apache License 2.0
678 stars 112 forks source link

Latest release --autoreload, keep getting "KeyboardInterrupt" errors #1984

Closed pascalwhoop closed 1 month ago

pascalwhoop commented 3 months ago

Description

Using kedro viz run --autoreload, when updating code I get errors, making autoreload unusable

kedro viz run --autoreload                                                                                                                                                         2.7m
Starting Kedro Viz ...
Kedro Viz started successfully.

✨ Kedro Viz is running at
 http://127.0.0.1:4141/
Process SpawnProcess-1:1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/pascalwhoop/Code/everycure/matrix/pipelines/matrix/.venv/lib/python3.11/site-packages/kedro_viz/server.py", line 139, in run_server
    uvicorn.run(app, host=host, port=port, log_config=None)
  File "/Users/pascalwhoop/Code/everycure/matrix/pipelines/matrix/.venv/lib/python3.11/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/Users/pascalwhoop/Code/everycure/matrix/pipelines/matrix/.venv/lib/python3.11/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 123, in run
    raise KeyboardInterrupt()
KeyboardInterrupt
^CException ignored in atexit callback: <function _exit_function at 0x107141da0>
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/util.py", line 360, in _exit_function
    p.join()
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/process.py", line 149, in join
    res = self._popen.wait(timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 43, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^

Your Environment

Include as many relevant details as possible about the environment you experienced the bug in:

kedro==0.19.6
kedro-datasets==4.0.0
kedro-telemetry==0.5.0
kedro-viz==9.1.0
astrojuanlu commented 3 months ago

Thanks @pascalwhoop for reporting this, we'll add this to our back log and have a look soon.

rashidakanchwala commented 3 months ago

@pascalwhoop -- just want to confirm that in previous releases of Kedro-Viz, u didn't encounter this issue ? So if you go back to release 9.0.0, you don't face it?

pascalwhoop commented 3 months ago

I haven't tested older versions

SajidAlamQB commented 1 month ago

Hey, after some digging, I found that this issue doesn’t occur for kedro-viz >= 9.2.0. The reason I believe this happens in earlier versions, like 9.1.0, is due to a bug in Uvicorn 0.29.0.

In Kedro-Viz 9.2.0, Uvicorn was upgraded from uvicorn[standard]~=0.29.0 to uvicorn[standard]>=0.30.0. Version 0.30.0 of Uvicorn has some new multiprocess manager and improved signal handling, which likely resolved the "KeyboardInterrupt" errors during --autoreload. See their release-notes.

Upgrading Kedro-Viz to >=9.2.0 should resolve the problem.