Deployments that send emails
You can use Modelbit's API to send emails from deployments. This is useful for quick, ad-hoc alerting when an expectation has been violated, e.g. an inference outside normal boundaries, or a batch size that's too large or too small.
To send an email, call mb.send_email
:
mb.send_email(
subject = "My Subject Line"
to = ["recipient_one@mycompany.com", "recipient_two@mycompany.com"],
msg = "Body of the email"
)
All emails are sent from support@modelbit.com
.
Sending emails from Notebook-based deployments
Emails can be sent from the deploy functions of deployments deployed from Notebooks. For example:
from sklearn import linear_model
lm = linear_model.LinearRegression()
lm.fit([[1], [2], [3]], [2, 4, 6])
def example_doubler(half: int) -> int:
if type(half) is not int:
mb.send_email(
subject = "Invalid type sent to doubler!",
to = ["tom@modelbit.com"],
msg = f"Doubler received invalid type. Type was: {type(half)}"
)
return None
return round(lm.predict([[half]])[0])
mb.deploy(example_doubler)
Sending emails from git-based deployments
Emails can also be sent from any place in code checked and deployed via git. Simply place the mb.send_email
line anywhere in your code.