Absolutely but there are cases where doing that is not practical. For instance machine learning training tasks that can take a long time to converge (months even). There are good arguments that long running tasks should not be in a notebook but they often find themselves in notebooks regardless especially in the ML domain.
yjftsjthsd-h|2 years ago