Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-691] Add Email Bot #11861

Closed
wants to merge 4 commits into from
Closed

[MXNET-691] Add Email Bot #11861

wants to merge 4 commits into from

Conversation

YuelinZhang0822
Copy link

@YuelinZhang0822 YuelinZhang0822 commented Jul 23, 2018

Description

An email bot which can automatically send daily GitHub issue reports using Amazon Simple Email Service and AWS Lambda.

@lanking520 @Roshrini
@nswamy @marcoabreu @eric-haibin-lin

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@YuelinZhang0822 YuelinZhang0822 changed the title [MXNET-691][W Add Email Bot [MXNET-691][WIP] Add Email Bot Jul 23, 2018
# Send emails using Amazon Simple Email Service(SES)
# Sender's email address must be verified.
# Replace it with sender's email address
sender = "sender@email.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also set this as an Environment Variable instead of dig into the code and fix it?
Does the user required to use Gmail to send Email, can MS Email also using the same tool?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, every email address verified in SES can use this tool

sender = "sender@email.com"
# Recipients' email address must be verified
# Replace it with recipients' email addresses
recipients = ["recipient1@email.com", "recipient2@email.com"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies to here, can user define them outside? How about storing them into a json file and then use the code to load these information?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store information in a json file is approachable

# Replace it with recipients' email addresses
recipients = ["recipient1@email.com", "recipient2@email.com"]
# If necessary, replace us-west-2 with the AWS Region you're using for Amazon SES.
aws_region = "us-west-2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concerns mentioned above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

return 1
# response.headers['link'] will looks like:
# <https://api.github.com/repositories/34864402/issues?state=all&page=387>; rel="last"
# In this case we need to extrac '387' as the count of pages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract

@haojin2
Copy link
Contributor

haojin2 commented Jul 24, 2018

@CathyZhang0822 test test

@YuelinZhang0822 YuelinZhang0822 changed the title [MXNET-691][WIP] Add Email Bot [MXNET-691] Add Email Bot Jul 30, 2018
@lanking520
Copy link
Member

@haojin2 Test added, review?

Copy link
Member

@Roshrini Roshrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Cathy!
Added a few comments:

  • Remove extra empty lines from all files.
  • Add docstring comment at the top of file mentioning usage of that particular file.

logging.getLogger('botocore').setLevel(logging.CRITICAL)

LOGGER = logging.getLogger(__name__)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty lines



class EmailBot:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

# Replace it with recipients' email addresses
recipients = ["recipient1@email.com", "recipient2@email.com"]
# If necessary, replace us-west-2 with the AWS Region you're using for Amazon SES.
aws_region = "us-west-2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

self.end = datetime.datetime.today()+datetime.timedelta(days=2)

def __clean_string(self, raw_string, sub_string):
# covert all non-alphanumeric characters from raw_string to sub_string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*convert

# In this case we need to extrac '387' as the count of pages
return int(self.__clean_string(response.headers['link'], " ").split()[-3])

def read_repo(self, periodically=True):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add method description in comments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. All methods descriptions are added.

non_responded += [{k: v for k, v in item.items()
if k in ['number', 'html_url', 'title']}]
non_responded_urls = non_responded_urls + url
if (datetime.datetime.strptime("2018-05-15", "%Y-%m-%d") < created
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep sla_start_date variable in class then, use that variable everywhere instead

* [Verify Email Addresses](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses-procedure.html) Go to AWS console -> SES -> Email Addresses to verify email address. Then fill in `sender` and `recipients` in `EmailBot.py`.
* Test the Lambda Function. On the lambda function's console, click Test.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these extra lines

@@ -0,0 +1,25 @@
# MXNet Bot
This is a directory contains bots served to improve operational efficiency.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*This directory contains bots served to improve operational efficiency.

## Label Bot
This bot will help automate/simplify issue labeling process, which mainly contains 3 parts:
* Machine Learning part:
A web server built based on AWS Elastic Beanstalk which can response to GET/POST requests and realize self-maintenance. It mainly has 2 features:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add link to "AWS Elastic Beanstalk"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. Set constructor arguments for EmailBot class
2. Automate deployment process
3. Improve coding style
4. Edit README
@nswamy nswamy added Feature Build pr-awaiting-review PR is waiting for code review labels Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants