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
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?
Google datalab : how to import pickle
Is text the only content type for %%storage magic function in datalab
Do I need to update gcloud components as indicated in docker startup
How to import user-written custom modules in google datalab?
Access to Google Cloud Datalab Fails with ssh Error
Cloud Datalab permissions - 403 on VM URL when sharing access