google-cloud-datalab


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

Related Links

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

Categories

HOME
url-redirection
assembly
adal
telegram
rdbms
nunit
powerpoint
toolbox
apache-spark-mllib
tivoli
nsbundle
soa
simulink
pearson-correlation
tvos
crystal-reports-2013
missing-data
opengl-3
arangodb
jquery-ui-sortable
mel
alamofire
x-cart
plink
symfony-2.8
mvc-mini-profiler
enterprise-miner
articulate-storyline
inno-download-plugin
visual-studio-extensions
imageresizer
php-mysqlidb
exit
xunit
expressionengine3
fat
pylons
delimiter
amazon-quicksight
mat
entity-relationship-model
handler
gp
ntp
calculation
boost-asio
recurring-events
sammy.js
sim-card
bc
ods
print-css
plr
drupal-theming
double-click
openresty
textsum
proget
openrasta
wcftestclient
globalize
mschart
tinymce-3
openblas
corruption
singleinstance
aquamacs
azure-cli
java-6
backbone-collections
edit
winusb
iotivity
windows-azure-queues
stream-processing
false-sharing
kendo-upload
jparsec
maybe
directdraw
vhosts
rewrite
fuelcms
rubaxa-sortable
omnifaces
zxspectrum
execve
paw
encryption-asymmetric
renderer
xmltodict
gd-graph
embedded-fonts
inputmismatchexception
sqlclr
patricia-trie
qtconcurrent
boost-msm
iboutlet
adobe-media-server
paginator
failing-tests
stress
procedures
fsevents
google-ajax-api
rmdir
massive
instantiationexception
aspmenu

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App