Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions components/Python/Scikit-learn/slack-events/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_channel_id(sc, name):
chid = None
try:
for ch in ret['channels']:
if ch['name'] == 'testapp':
if ch['name'] == name:
print(ch)
chid = ch['id']
except Exception:
Expand Down Expand Up @@ -148,21 +148,43 @@ def main():
else:
alert_message = ":ok_hand:"

text_message =\
"*MLApp Name*: {}\n"\
"*Description*: {}\n"\
"*Event Type*: {}\n"\
"*Message Type*: {}\n"\
"*Alert*: {}\n"\
"*Created At* :clock12: : {}\n"\
"*Host*: {}\n".format(
jsons['ionName'],
jsons['description'],
jsons['eventType'],
jsons['msgType'],
alert_message,
datetime.utcfromtimestamp(jsons['created']/1000),
jsons['host'])
text_message = ""

if jsons['eventType'] == "GenericEvent" and jsons['name'] == "ModelReview":
text_message = \
"*MLApp Name*: {}\n" \
"*Description*: {}\n" \
"*Event Type*: {}\n" \
"*Model Id*: {}\n" \
"*Reviewed By*: {}\n" \
"*Alert*: {}\n" \
"*Created At* :clock12: : {}\n" \
"*Host*: {}\n".format(
jsons['ionName'],
jsons['stateDescription'],
"ModelUpdated",
jsons['modelId'],
jsons['reviewedBy'],
alert_message,
datetime.utcfromtimestamp(jsons['created']/1000),
jsons['host'])
else:
text_message =\
"*MLApp Name*: {}\n"\
"*Description*: {}\n"\
"*Event Type*: {}\n"\
"*Message Type*: {}\n"\
"*Alert*: {}\n"\
"*Created At* :clock12: : {}\n"\
"*Host*: {}\n".format(
jsons['ionName'],
jsons['description'],
jsons['eventType'],
jsons['msgType'],
alert_message,
datetime.utcfromtimestamp(jsons['created']/1000),
jsons['host'])

if jsons['eventType'] == "ModelAccepted":
text_message = text_message +\
"*Model ID*: {}\n".format(jsons['modelId'])
Expand Down