Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
giannibalistreri committed Dec 27, 2023
1 parent 8746f51 commit e575ffc
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import urllib3

from custom_logger import Log
from typing import NamedTuple

PARSER = argparse.ArgumentParser(description="slack alerting")
Expand Down Expand Up @@ -46,6 +47,12 @@ def slack_alerting(msg: str,
-> abort: Abort Kubeflow Pipeline
-> succeed: End Kubeflow Pipline successfully
:param aws_region: str
Code of the AWS region
:param slack_channel: str
Name of the Slack channel
:return: NamedTuple
Status code of the request
"""
Expand Down Expand Up @@ -83,7 +90,7 @@ def slack_alerting(msg: str,
"elements": [
{
"type": "mrkdwn",
"text": "Region: *eu-central-1*"
"text": f"Region: *{aws_region}*"
}
]
}
Expand Down Expand Up @@ -165,6 +172,7 @@ def slack_alerting(msg: str,
raise SlackAlertingException(f'Pipeline status ({pipeline_status}) not supported')
_encoded_msg: bytes = json.dumps(_slack_msg).encode('utf-8')
_response = _http.request(method='POST', url=_slack_url, body=_encoded_msg)
Log().log(msg=f'Slack message send to channel "{slack_channel}" with response status "{_response.status}": {_slack_msg}')
return [_slack_msg, _response.status]


Expand Down

0 comments on commit e575ffc

Please sign in to comment.