kedro-org / kedro-viz

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

Add port in use check to prevent browser redirecting incorrectly for kedro viz #2176

Closed SajidAlamQB closed 2 weeks ago

SajidAlamQB commented 2 weeks ago

Description

Related to: https://github.com/kedro-org/kedro-viz/issues/2052

If there is an existing Kedro Viz server running, kedro viz run will redirect the browser to that one when a second instance of kedro viz is launched using the same port and the error message from uvicorn is missed.

Development notes

Check that the port is in use before running the server and increment it until a max 5 times to find an alternative free port, if none are found send error message to users no free ports available and suggest them to use --port.

QA notes

Checklist

rashidakanchwala commented 2 weeks ago

hey @SajidAlamQB , can we not increment the port number here, directly, if 4141 is occupied, go to 4142, if that is occupied which is it always, go to 4143?

rashidakanchwala commented 2 weeks ago

maybe we put a specific range from 4141, to 4145, and if all the ports in this range are busy, then they tell us which one through --port.

SajidAlamQB commented 2 weeks ago

maybe we put a specific range from 4141, to 4145, and if all the ports in this range are busy, then they tell us which one through --port.

This is a good middle approach we definitely can do.

rashidakanchwala commented 2 weeks ago

@SajidAlamQB , thanks for this , will review this once tests are passing, can we also add unit-testing to this, if we can mock ports being occupied ?