huggingface / knockknock

🚪✊Knock Knock: Get notified when your training ends with only two additional lines of code
MIT License
2.78k stars 234 forks source link

Added support for multiple recipient emails #23

Closed rish-16 closed 5 years ago

rish-16 commented 5 years ago

Hey there!

I was reading through the issues page and saw a feature request to send emails to multiple recipients. I tweaked the original function into one where the user provides a list of emails instead.

It works something like this:

@email_sender(recipient_email_list=["<your_email@address.com>", "<your_second_email@address.com>"], sender_email="<grandma's_email@gmail.com>")
def train_your_nicest_model(your_nicest_parameters):
    import time
    time.sleep(10000)
    return {'loss': 0.9} # Optional return value

It was a simple fix: I looped through all the recipient emails and sent it to all of them one by one.

In the case that the sender_email is None, it will take the first email from the recipient_email_list list and assign it to the sender_email.

Hope this is useful!

VictorSanh commented 5 years ago

Hey @rish-16

Thank you for the PR! Just made a small update for consistency.

Since you already started, could you also modify the email_parser in the __main__.py file (for command-line tools). You can have a look at the slack_parser for inspiration. And it would great if you could also change the example in the README.

Thanks! Victor

rish-16 commented 5 years ago

Will do! I'll get started on the CLI version + docs.

Cheers

rish-16 commented 5 years ago

Alright, I've completed the updates to the CLI version of knockknock and the README.

Waiting for your feedback.

Cheers, Rish

VictorSanh commented 5 years ago

@rish-16 it looks good to me! In the CLI, I changed the type to a comma-separated list (it's not recommended to use type=list with argparse, see here). I'm merging this and pushing it to pip.

rish-16 commented 5 years ago

Thank you, @VictorSanh !