What is the best way to stop execution of a cell on a Google Datalab notebook?
I would like to halt the execution of a cell executing python commands on a Google Datalab notebook if certain conditions are met. What is the preferred method to do this that doesn't affect the rest of the notebook? if x: quit() Will crash the notebook.
One potential solution is to wrap your code in a function and use return to exit early. def do_work(): stopExecution = True if stopExecution: return print 'do not print' do_work() Another solution is to raise an exception: stopExecution = True if stopExecution: raise Exception('Done') print 'do not print' A better solution is to use the if statement to allow code execution, rather than block it. For example, if ShouldIContinueWorking(): doWork() else: print 'Done' # do nothing (preferred) or return from function
Restore google cloud notebook after restart
Is it possible to set a static external IP address in Cloud Shell?
Menubar in datalab keeps vanishing
How do I attach a local ssd to a Datalab instance?
Is it possible to create a google cloud datalab instance not using datalab-network?
fail to create repository [datalab-notebooks] for Project
bigquery - current_date() inconsistent result?
Can I export to Google Sheets from Datalab?
Using bq command in datalab - credentials needed
Can I create kernel gateway endpoints in google cloud datalab?
Fastest way to read big amounts of data in Google Datalab?
Datalabs project not found
Datalab front get stuck when opening notebooks, and buttons aren't working
How can I programmatically give Cloud ML access to a bucket?
Running cloud datalab kernel on my own server?
How can I get the Cloud ML service account programmatically in Python?