eladkal commented on a change in pull request #17247:
URL: https://github.com/apache/airflow/pull/17247#discussion_r680373180
##########
File path: airflow/providers/slack/operators/slack.py
##########
@@ -203,13 +213,31 @@ def __init__(
self.filename = filename
self.filetype = filetype
self.content = content
+ self.file_params = {}
super().__init__(method=self.method, **kwargs)
def construct_api_call_params(self) -> Any:
- self.api_params = {
- 'channels': self.channel,
- 'content': self.content,
- 'filename': self.filename,
- 'filetype': self.filetype,
- 'initial_comment': self.initial_comment,
- }
+ if self.content is not None:
+ self.api_params = {
+ 'channels': self.channel,
+ 'content': self.content,
+ 'initial_comment': self.initial_comment,
+ }
+ elif self.filename is not None:
+ self.api_params = {
+ 'channels': self.channel,
+ 'filename': self.filename,
+ 'filetype': self.filetype,
+ 'initial_comment': self.initial_comment,
+ }
+ self.file_params = {'file': self.filename}
+
+ def execute(self, **kwargs):
+ """
+ The SlackAPIOperator calls will not fail even if the call is not
unsuccessful.
+ It should not prevent a DAG from completing in success
+ """
+ if not self.api_params:
+ self.construct_api_call_params()
+ slack = SlackHook(token=self.token, slack_conn_id=self.slack_conn_id)
+ slack.call(self.method, data=self.api_params, files=self.file_params)
Review comment:
Why do we need to pass `filename ` in both `files` & `data` ?
`api_params` has a `filename` key that contains `self.filename`
`file_params` has `file` key that contains `self.filename`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]