You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "o-nikolas (via GitHub)" <gi...@apache.org> on 2025/09/09 23:50:00 UTC
[PR] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
o-nikolas opened a new pull request, #55445:
URL: https://github.com/apache/airflow/pull/55445
Similar to the KB creation retry logic here: https://github.com/apache/airflow/blob/d8e591e8b6faa452d0e45399dccdee7eb105e6a3/providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py#L463-L504
We need retries around starting the ingestion job because the index may not be ready or accessible.
I also added tests to cover the retry behaviour.
<!--
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. -->
---
**^ 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] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #55445:
URL: https://github.com/apache/airflow/pull/55445#discussion_r2336973164
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -654,9 +656,37 @@ def execute_complete(self, context: Context, event: dict[str, Any] | None = None
return validated_event["ingestion_job_id"]
def execute(self, context: Context) -> str:
- ingestion_job_id = self.hook.conn.start_ingestion_job(
- knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
- )["ingestionJob"]["ingestionJobId"]
+ def start_ingestion_job():
+ try:
+ ingestion_job_id = self.hook.conn.start_ingestion_job(
+ knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
+ )["ingestionJob"]["ingestionJobId"]
+
+ return ingestion_job_id
+ except ClientError as error:
+ error_message = error.response["Error"]["Message"].lower()
+ is_known_retryable_message = (
Review Comment:
nit. I guess this is more a question of style and personal opinion but do not you think it would be clearer/easier to read if you use `@tenacity`?
--
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] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #55445:
URL: https://github.com/apache/airflow/pull/55445#discussion_r2337443949
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -654,9 +656,37 @@ def execute_complete(self, context: Context, event: dict[str, Any] | None = None
return validated_event["ingestion_job_id"]
def execute(self, context: Context) -> str:
- ingestion_job_id = self.hook.conn.start_ingestion_job(
- knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
- )["ingestionJob"]["ingestionJobId"]
+ def start_ingestion_job():
+ try:
+ ingestion_job_id = self.hook.conn.start_ingestion_job(
+ knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
+ )["ingestionJob"]["ingestionJobId"]
+
+ return ingestion_job_id
+ except ClientError as error:
+ error_message = error.response["Error"]["Message"].lower()
+ is_known_retryable_message = (
Review Comment:
Okay, I have this tested and working and I don't want to burn too much more time on this refactoring it right now. I think I'll merge it so that we get the benefit and we can circle back and change all the operators to use tenacity later if we find the time!
Thanks for the review :smiley:
--
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] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #55445:
URL: https://github.com/apache/airflow/pull/55445#discussion_r2337313244
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -654,9 +656,37 @@ def execute_complete(self, context: Context, event: dict[str, Any] | None = None
return validated_event["ingestion_job_id"]
def execute(self, context: Context) -> str:
- ingestion_job_id = self.hook.conn.start_ingestion_job(
- knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
- )["ingestionJob"]["ingestionJobId"]
+ def start_ingestion_job():
+ try:
+ ingestion_job_id = self.hook.conn.start_ingestion_job(
+ knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
+ )["ingestionJob"]["ingestionJobId"]
+
+ return ingestion_job_id
+ except ClientError as error:
+ error_message = error.response["Error"]["Message"].lower()
+ is_known_retryable_message = (
Review Comment:
I did consider that, but the Bedrock operators already use this pattern in other Operators, so I felt it was better to keep the pattern rather than have multiple going. What do you think?
--
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] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas merged PR #55445:
URL: https://github.com/apache/airflow/pull/55445
--
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] Catch a couple other 404/401 issues for Bedrock Operators [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #55445:
URL: https://github.com/apache/airflow/pull/55445#discussion_r2337357279
##########
providers/amazon/src/airflow/providers/amazon/aws/operators/bedrock.py:
##########
@@ -654,9 +656,37 @@ def execute_complete(self, context: Context, event: dict[str, Any] | None = None
return validated_event["ingestion_job_id"]
def execute(self, context: Context) -> str:
- ingestion_job_id = self.hook.conn.start_ingestion_job(
- knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
- )["ingestionJob"]["ingestionJobId"]
+ def start_ingestion_job():
+ try:
+ ingestion_job_id = self.hook.conn.start_ingestion_job(
+ knowledgeBaseId=self.knowledge_base_id, dataSourceId=self.data_source_id
+ )["ingestionJob"]["ingestionJobId"]
+
+ return ingestion_job_id
+ except ClientError as error:
+ error_message = error.response["Error"]["Message"].lower()
+ is_known_retryable_message = (
Review Comment:
I think I would personally prefer tenacity but I will not block the PR because of that
--
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