Keep Jupyter notebook running with Macbook closed

As simple as the title: Are there ways to keep jupyter notebook cells running with a closed laptop? Sometimes I need to run to a meeting or leave the office and I have to close my laptop. I'd love to be able to keep cells running.

Is this just a matter of biting the bullet and running my code on AWS/Google compute rather than locally? Or is there a way to set my Macbook to not enter sleep state on closed under certain conditions?


Alternatively you can just go to your system preferences-> energy saver-> set computer sleep and display sleep sliders to “never”.

Best!


I'm using Amphetamine to keep my Mac up and running for various ML tasks


As far as I understand, terminal processes are 'paused' when you close the lid of the MacBook and it enters sleep mode. Re-opening the lid should resume the process, unless there is an error/exception thrown (for example due to failed network access).

A workaround might be to prevent the OS from going to sleep in the first place by using something like caffeine.