Skip to content

Instantly share code, notes, and snippets.

@mithunkamat
Forked from jamescalam/notify_model.py
Created May 18, 2020 07:06
Show Gist options
  • Save mithunkamat/b8a3ce4b1e3b4850249da879b0682abc to your computer and use it in GitHub Desktop.
Save mithunkamat/b8a3ce4b1e3b4850249da879b0682abc to your computer and use it in GitHub Desktop.
Example code using sending email notification on completion of a cash-flow model process.
end = datetime.datetime.now() # get the ending datetime
# get the total runtime in hours:minutes:seconds
hours, rem = divmod((end - start).seconds, 3600)
mins, secs = divmod(rem, 60)
runtime = '{:02d}:{:02d}:{:02d}'.format(hours, mins, secs)
# now built our message
notify.msg(
subject="Cashflow Model Completion",
text=(f'{len(model.output)} loans processed.\n'
f'Total runtime: {runtime}'),
img=[
'../vis/loan01_amortisation.png',
'../vis/loan07_amortisation.png',
'../vis/loan01_profit_and_loss.png',
'../vis/loan07_profit_and_loss.png'
]
)
notify.send(msg) # and send it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment