You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "xchwan (via GitHub)" <gi...@apache.org> on 2025/10/01 01:34:16 UTC
[PR] Firehose and kinesis hook in independent file [airflow]
xchwan opened a new pull request, #56276:
URL: https://github.com/apache/airflow/pull/56276
<!--
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/
-->
<!-- Please keep an empty line above the dashes. -->
---
To handle "AIP-82: Add common messaging system providers #52712" kinesis part, I found there are firehose class which should exist in firehose.py. As issue "Amazon kinesis hook contains firehose class #55955" discussed, I seperate firehose hook and build kinesis hook
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2400990823
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/firehose.py:
##########
@@ -0,0 +1,56 @@
+#
+# 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.
+"""This module contains AWS Firehose hook."""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class FirehoseHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis Firehose.
+
+ Provide thick wrapper around :external+boto3:py:class:`boto3.client("firehose") <Firehose.Client>`.
+
+ :param delivery_stream: Name of the delivery stream
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
+ self.delivery_stream = delivery_stream
+ kwargs["client_type"] = "firehose"
+ super().__init__(*args, **kwargs)
+
+ def put_records(self, records: Iterable) -> dict:
+ """
+ Write batch records to Kinesis Firehose.
+
+ .. seealso::
+ - :external+boto3:py:meth:`Firehose.Client.put_record_batch`
+
+ :param records: list of records
+ """
+ return self.get_conn().put_record_batch(DeliveryStreamName=self.delivery_stream, Records=records)
Review Comment:
Thanks your comment. I can remove kinesis methods, which are wrappers around boto3 API. However, firehose part method you mention is already exist before this PR, and I just copy it to firehose.py. Should I deprecate it and tell user to use boto3 API?
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2430894060
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/kinesis.py:
##########
@@ -37,20 +39,110 @@ class FirehoseHook(AwsBaseHook):
.. seealso::
- :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ .. deprecated::
+ This hook was moved. Import from
+ :class:`airflow.providers.amazon.aws.hooks.firehose.FirehoseHook`
+ instead of kinesis.py
"""
- def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
- self.delivery_stream = delivery_stream
- kwargs["client_type"] = "firehose"
+ def __init__(self, *args, **kwargs) -> None:
+ warnings.warn(
+ "Importing FirehoseHook from kinesis.py is deprecated "
+ "and will be removed in a future release. "
+ "Please import it from firehose.py instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
super().__init__(*args, **kwargs)
- def put_records(self, records: Iterable):
+
+class KinesisHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis.
+
+ Provide thin wrapper around :external+boto3:py:class:`boto3.client("kinesis") <Kinesis.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, *args, **kwargs) -> None:
+ kwargs["client_type"] = "kinesis"
+ super().__init__(*args, **kwargs)
+
+ def create_stream(self, stream_name: str, shard_count: int) -> dict:
Review Comment:
modify done
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan closed pull request #56276: Firehose and kinesis hook in independent file
URL: https://github.com/apache/airflow/pull/56276
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2429746214
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/kinesis.py:
##########
@@ -37,20 +39,110 @@ class FirehoseHook(AwsBaseHook):
.. seealso::
- :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ .. deprecated::
+ This hook was moved. Import from
+ :class:`airflow.providers.amazon.aws.hooks.firehose.FirehoseHook`
+ instead of kinesis.py
"""
- def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
- self.delivery_stream = delivery_stream
- kwargs["client_type"] = "firehose"
+ def __init__(self, *args, **kwargs) -> None:
+ warnings.warn(
+ "Importing FirehoseHook from kinesis.py is deprecated "
+ "and will be removed in a future release. "
+ "Please import it from firehose.py instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
super().__init__(*args, **kwargs)
- def put_records(self, records: Iterable):
+
+class KinesisHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis.
+
+ Provide thin wrapper around :external+boto3:py:class:`boto3.client("kinesis") <Kinesis.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, *args, **kwargs) -> None:
+ kwargs["client_type"] = "kinesis"
+ super().__init__(*args, **kwargs)
+
+ def create_stream(self, stream_name: str, shard_count: int) -> dict:
Review Comment:
Yes, these methods in kinesis just warp the boto3 API. Should I remove them?
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2429746214
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/kinesis.py:
##########
@@ -37,20 +39,110 @@ class FirehoseHook(AwsBaseHook):
.. seealso::
- :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ .. deprecated::
+ This hook was moved. Import from
+ :class:`airflow.providers.amazon.aws.hooks.firehose.FirehoseHook`
+ instead of kinesis.py
"""
- def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
- self.delivery_stream = delivery_stream
- kwargs["client_type"] = "firehose"
+ def __init__(self, *args, **kwargs) -> None:
+ warnings.warn(
+ "Importing FirehoseHook from kinesis.py is deprecated "
+ "and will be removed in a future release. "
+ "Please import it from firehose.py instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
super().__init__(*args, **kwargs)
- def put_records(self, records: Iterable):
+
+class KinesisHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis.
+
+ Provide thin wrapper around :external+boto3:py:class:`boto3.client("kinesis") <Kinesis.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, *args, **kwargs) -> None:
+ kwargs["client_type"] = "kinesis"
+ super().__init__(*args, **kwargs)
+
+ def create_stream(self, stream_name: str, shard_count: int) -> dict:
Review Comment:
Yes, I said I can remove them. these methods in kinesis just warp the boto3 API. Should I remove them?
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2401924263
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/firehose.py:
##########
@@ -0,0 +1,56 @@
+#
+# 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.
+"""This module contains AWS Firehose hook."""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class FirehoseHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis Firehose.
+
+ Provide thick wrapper around :external+boto3:py:class:`boto3.client("firehose") <Firehose.Client>`.
+
+ :param delivery_stream: Name of the delivery stream
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
+ self.delivery_stream = delivery_stream
+ kwargs["client_type"] = "firehose"
+ super().__init__(*args, **kwargs)
+
+ def put_records(self, records: Iterable) -> dict:
+ """
+ Write batch records to Kinesis Firehose.
+
+ .. seealso::
+ - :external+boto3:py:meth:`Firehose.Client.put_record_batch`
+
+ :param records: list of records
+ """
+ return self.get_conn().put_record_batch(DeliveryStreamName=self.delivery_stream, Records=records)
Review Comment:
You're right, no, for these methods just keep them as they are :) Thanks!
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #56276:
URL: https://github.com/apache/airflow/pull/56276#issuecomment-3406254597
Test failure unrelated to this PR, merging. Thanks for putting up the PR and addressing my feedbacks!
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2396389020
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/firehose.py:
##########
@@ -0,0 +1,56 @@
+#
+# 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.
+"""This module contains AWS Firehose hook."""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class FirehoseHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis Firehose.
+
+ Provide thick wrapper around :external+boto3:py:class:`boto3.client("firehose") <Firehose.Client>`.
+
+ :param delivery_stream: Name of the delivery stream
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
+ self.delivery_stream = delivery_stream
+ kwargs["client_type"] = "firehose"
+ super().__init__(*args, **kwargs)
+
+ def put_records(self, records: Iterable):
Review Comment:
sure! modify done
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #56276:
URL: https://github.com/apache/airflow/pull/56276
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "Programmer-RD-AI (via GitHub)" <gi...@apache.org>.
Programmer-RD-AI commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2395010251
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/firehose.py:
##########
@@ -0,0 +1,56 @@
+#
+# 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.
+"""This module contains AWS Firehose hook."""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class FirehoseHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis Firehose.
+
+ Provide thick wrapper around :external+boto3:py:class:`boto3.client("firehose") <Firehose.Client>`.
+
+ :param delivery_stream: Name of the delivery stream
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
+ self.delivery_stream = delivery_stream
+ kwargs["client_type"] = "firehose"
+ super().__init__(*args, **kwargs)
+
+ def put_records(self, records: Iterable):
Review Comment:
could we put the return type of this function?
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2398841614
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/firehose.py:
##########
@@ -0,0 +1,56 @@
+#
+# 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.
+"""This module contains AWS Firehose hook."""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+
+from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
+
+
+class FirehoseHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis Firehose.
+
+ Provide thick wrapper around :external+boto3:py:class:`boto3.client("firehose") <Firehose.Client>`.
+
+ :param delivery_stream: Name of the delivery stream
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
+ self.delivery_stream = delivery_stream
+ kwargs["client_type"] = "firehose"
+ super().__init__(*args, **kwargs)
+
+ def put_records(self, records: Iterable) -> dict:
+ """
+ Write batch records to Kinesis Firehose.
+
+ .. seealso::
+ - :external+boto3:py:meth:`Firehose.Client.put_record_batch`
+
+ :param records: list of records
+ """
+ return self.get_conn().put_record_batch(DeliveryStreamName=self.delivery_stream, Records=records)
Review Comment:
One comment that apply to your other hook as well. We try to avoid creating method in hooks that are jsut wrappers around boto3 API. That is the case of this method, we are justing calling boto3 API with the parameters provided. There is no real value added by this method. In you operator, instead of calling this hook method, you can call the boto3 API directly. Please look at other operators/hooks, you'll find plenty of examples
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2429863121
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/kinesis.py:
##########
@@ -37,20 +39,110 @@ class FirehoseHook(AwsBaseHook):
.. seealso::
- :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ .. deprecated::
+ This hook was moved. Import from
+ :class:`airflow.providers.amazon.aws.hooks.firehose.FirehoseHook`
+ instead of kinesis.py
"""
- def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
- self.delivery_stream = delivery_stream
- kwargs["client_type"] = "firehose"
+ def __init__(self, *args, **kwargs) -> None:
+ warnings.warn(
+ "Importing FirehoseHook from kinesis.py is deprecated "
+ "and will be removed in a future release. "
+ "Please import it from firehose.py instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
super().__init__(*args, **kwargs)
- def put_records(self, records: Iterable):
+
+class KinesisHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis.
+
+ Provide thin wrapper around :external+boto3:py:class:`boto3.client("kinesis") <Kinesis.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, *args, **kwargs) -> None:
+ kwargs["client_type"] = "kinesis"
+ super().__init__(*args, **kwargs)
+
+ def create_stream(self, stream_name: str, shard_count: int) -> dict:
Review Comment:
Yes please
--
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] Firehose and kinesis hook in independent file [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #56276:
URL: https://github.com/apache/airflow/pull/56276#discussion_r2429610435
##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/kinesis.py:
##########
@@ -37,20 +39,110 @@ class FirehoseHook(AwsBaseHook):
.. seealso::
- :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ .. deprecated::
+ This hook was moved. Import from
+ :class:`airflow.providers.amazon.aws.hooks.firehose.FirehoseHook`
+ instead of kinesis.py
"""
- def __init__(self, delivery_stream: str, *args, **kwargs) -> None:
- self.delivery_stream = delivery_stream
- kwargs["client_type"] = "firehose"
+ def __init__(self, *args, **kwargs) -> None:
+ warnings.warn(
+ "Importing FirehoseHook from kinesis.py is deprecated "
+ "and will be removed in a future release. "
+ "Please import it from firehose.py instead.",
+ AirflowProviderDeprecationWarning,
+ stacklevel=2,
+ )
super().__init__(*args, **kwargs)
- def put_records(self, records: Iterable):
+
+class KinesisHook(AwsBaseHook):
+ """
+ Interact with Amazon Kinesis.
+
+ Provide thin wrapper around :external+boto3:py:class:`boto3.client("kinesis") <Kinesis.Client>`.
+
+ Additional arguments (such as ``aws_conn_id``) may be specified and
+ are passed down to the underlying AwsBaseHook.
+
+ .. seealso::
+ - :class:`airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook`
+ """
+
+ def __init__(self, *args, **kwargs) -> None:
+ kwargs["client_type"] = "kinesis"
+ super().__init__(*args, **kwargs)
+
+ def create_stream(self, stream_name: str, shard_count: int) -> dict:
Review Comment:
Related to my previous comment, this method is not needed, is not it?
--
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