From 3f698dc7cd7b6be819fe04719c574150e136b610 Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Sat, 2 May 2020 17:19:19 -0700 Subject: [PATCH] Let the label bot respond to additional comments; not just when an issue is opened. * See kubeflow/code-intelligence#133 we want to allow the label bot to respond after additional comments on an issue and take those comments into account. This is because additional comments on the issue might provide more data pointing at how the issue should be labeled. * We only do this for issues that are forwarded to a pubsub backend and using the newer code for label prediction. related to kubeflow/code-intelligence#133 --- flask_app/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flask_app/app.py b/flask_app/app.py index 5d802e4d..5e3ab865 100644 --- a/flask_app/app.py +++ b/flask_app/app.py @@ -123,7 +123,7 @@ def bot(): verify_webhook(request) # Check if payload corresponds to an issue being opened - if 'action' not in request.json or request.json['action'] != 'opened' or 'issue' not in request.json: + if 'issue' not in request.json: logging.warning("Event is not for an issue with action opened.") return 'ok' @@ -143,6 +143,9 @@ def bot(): logging.info(f"Recieved {username}/{repo}#{issue_num}") try: # forward some issues of specific repos and select by their given forwarded proportion + # TODO(jlewi): We could probably simplify this because at this point + # for any repo/org that we are forwarding the issues we should probably + # always forward the issues. forward_probability = None repo_spec = f'{username}/{repo}' if username in forwarded_repos.get("orgs", {}): @@ -167,6 +170,11 @@ def bot(): f"{username}/{repo}#{issue_num}\n Exception: {e}\n" f"{traceback.format_exc()}") + # Check if payload corresponds to an issue being opened + if 'action' not in request.json or request.json['action'] != 'opened': + logging.warning("Event is not for an issue with action opened.") + return 'ok' + # write the issue to the database using ORM issue_db_obj = Issues(repo=repo, username=username,