Links

Scheduler demo

Tags: #naas #scheduler #snippet #operations
Author: Jeremy Ravenel
Transform all your work routines in notebooks and run them even when you sleep. Here we are going to use the Notifications feature to test Scheduler.
📺 Start learning how to schedule your Naas notebook on our Youtube channel.
from IPython.display import IFrame
IFrame(
src='https://www.youtube.com/embed/ONiILHFItzs',
width="560",
height="315"
)
Read the doc: https://naas.gitbook.io/naas/features/scheduler

Input

Import library

import naas
from IPython.display import HTML

Setup Naas notification

# Email receiver
EMAIL_TO = "ENTER_YOUR_EMAIL_TO_HERE" #EXAMPLE: "[email protected]"
# Email subject
EMAIL_SUBJECT = "Naas Scheduler Test"

Setup Naas scheduler

# Schedule your notebook everyday at 9:00 AM
naas.scheduler.add(cron="0 9 * * *")
# To delete your scheduler, uncomment the line below and execute this cell
# naas.scheduler.delete()

Model

Create content

# Email content
EMAIL_CONTENT = (
'''
<p>Hello !</p>
<p>If i put html in there..&nbsp;</p>
<p><img src="https://specials-images.forbesimg.com/imageserve/5f1f37a40a5db2c8275972c0/960x0.jpg?fit=scale" alt="" width="959" height="663" /></p>
'''
)
# Display content
HTML(EMAIL_CONTENT)

Send the email

result = naas.notification.send(
email_to=EMAIL_TO,
subject=EMAIL_SUBJECT,
html=EMAIL_CONTENT
)

Output

Display result

result
Last modified 1mo ago