You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2024/01/13 03:57:58 UTC
[PR] Optionally use `client.files_upload_v2` in Slack Provider [airflow]
Taragolis opened a new pull request, #36757:
URL: https://github.com/apache/airflow/pull/36757
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
closes: https://github.com/apache/airflow/issues/35034
Default method which we use for upload files into the slack might failed with timeout error or gateway errors in case of upload huge files, for resolve this implement optional ability to switch to `client.files_upload_v2` which should resolve this issue.
Unfortunetly it is not 100% builtin replacement and required some changes in scope of application, so I keep **v1** (`client.files_upload`) as default when we consider to bump major version we also could switch default uploader method.
In addition some minor (or not) changes into the execute method signature, which doesn't follow `BaseOperator` signature
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Optionally use `client.files_upload_v2` in Slack Provider [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #36757:
URL: https://github.com/apache/airflow/pull/36757#discussion_r1456596938
##########
airflow/providers/slack/operators/slack.py:
##########
@@ -48,7 +52,7 @@ def __init__(
self,
*,
slack_conn_id: str = SlackHook.default_conn_name,
- method: str | None = None,
+ method: str,
Review Comment:
Nevermind, I replace it by warning in constructor and raise an error in original execute method, which should not breaks custom user operators
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Optionally use `client.files_upload_v2` in Slack Provider [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #36757:
URL: https://github.com/apache/airflow/pull/36757
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Optionally use `client.files_upload_v2` in Slack Provider [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #36757:
URL: https://github.com/apache/airflow/pull/36757#discussion_r1451195890
##########
airflow/providers/slack/provider.yaml:
##########
@@ -58,7 +58,7 @@ versions:
dependencies:
- apache-airflow>=2.6.0
- apache-airflow-providers-common-sql>=1.3.1
- - slack_sdk>=3.0.0
+ - slack_sdk>=3.19.0
Review Comment:
Initial version which supports `client.file_upload_v2`: https://github.com/slackapi/python-slack-sdk/releases/tag/v3.19.0
##########
pyproject.toml:
##########
@@ -755,7 +755,7 @@ grpc = [
"grpcio>=1.15.0",
]
hashicorp = [
- "hvac>=0.10",
+ "hvac>=1.1.0",
Review Comment:
I'm not sure, but seems like this changes made by pre-commit, seems like changes in https://github.com/apache/airflow/pull/36532 made before we move into the `pyproject.toml`
I think better to move this changes in the separate PR
##########
airflow/providers/slack/operators/slack.py:
##########
@@ -48,7 +52,7 @@ def __init__(
self,
*,
slack_conn_id: str = SlackHook.default_conn_name,
- method: str | None = None,
+ method: str,
Review Comment:
method can't be `None` because `SlackHook.call` method expected `str` however this previously doesn't failed on static checks, my assumption due to the wrong signature of `SlackAPIOperator.execute` method. After I change it to correct one it starts failed with an error
```console
airflow/providers/slack/operators/slack.py:100: error: Argument 1 to "call" of
"SlackHook" has incompatible type "Optional[str]"; expected "str" [arg-type]
self.hook.call(self.method, json=self.api_params
```
##########
airflow/providers/slack/operators/slack.py:
##########
@@ -90,7 +94,7 @@ def construct_api_call_params(self) -> Any:
"SlackAPIOperator should not be used directly. Chose one of the subclasses instead"
)
- def execute(self, **kwargs):
+ def execute(self, context: Context):
Review Comment:
This a bit confuse me how it works before 🙄 but it does
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org