You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "yangyulely (via GitHub)" <gi...@apache.org> on 2024/10/29 02:54:17 UTC
[PR] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
yangyulely opened a new pull request, #43456:
URL: https://github.com/apache/airflow/pull/43456
<!--
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.
-->
Closes: #43274
This PR will remove returns in the final clause of `S3ToDynamoDBOperator`.
Other related issues has been fixed by the PR: [#43426](https://github.com/apache/airflow/pull/43426)
<!--
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 [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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "yangyulely (via GitHub)" <gi...@apache.org>.
yangyulely commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1822300149
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
Review Comment:
Just want to tell an exception details here, this PR mainly fix the possible unexpected propagate on, mentioned in https://github.com/apache/airflow/issues/43274.
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "romsharon98 (via GitHub)" <gi...@apache.org>.
romsharon98 commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1820571764
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
+ self.log.warning("Error while loading data from temp table, deleting temp table. Error: %s", e)
Review Comment:
```suggestion
self.log.warning("Error while loading data from temp table. Error: %s", e)
```
This log message only shows the error and not really deleting the temp table, we have a log after it that said deleting temp table. So I think better removing it from here.
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "yangyulely (via GitHub)" <gi...@apache.org>.
yangyulely commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1820413842
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
- finally:
- self.log.info("Delete tmp DynamoDB table %s", self.tmp_table_name)
- client.delete_table(TableName=self.tmp_table_name)
- return dynamodb_hook.get_conn().Table(self.dynamodb_table_name).table_arn
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
+ self.log.warning("Error while loading data from temp table, deleting temp table. Error: %s", e)
+
+ self.log.info("Delete tmp DynamoDB table %s", self.tmp_table_name)
+ client.delete_table(TableName=self.tmp_table_name)
Review Comment:
Yes, maybe it's better to keep them in finally clause, in case of exception not handled by the try clause.
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "romsharon98 (via GitHub)" <gi...@apache.org>.
romsharon98 commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1820294841
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
- finally:
- self.log.info("Delete tmp DynamoDB table %s", self.tmp_table_name)
- client.delete_table(TableName=self.tmp_table_name)
- return dynamodb_hook.get_conn().Table(self.dynamodb_table_name).table_arn
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
+ self.log.warning("Error while loading data from temp table, deleting temp table. Error: %s", e)
+
+ self.log.info("Delete tmp DynamoDB table %s", self.tmp_table_name)
+ client.delete_table(TableName=self.tmp_table_name)
Review Comment:
don't we want to keep it in a finally clause?
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1828084861
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
Review Comment:
Agree, do we need the `except` statement here? Removing the `except` would make more sense to me
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "romsharon98 (via GitHub)" <gi...@apache.org>.
romsharon98 merged PR #43456:
URL: https://github.com/apache/airflow/pull/43456
--
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] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "yangyulely (via GitHub)" <gi...@apache.org>.
yangyulely commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1828834906
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
Review Comment:
I've remove 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
Re: [PR] Remove returns in final clause of S3ToDynamoDBOperator [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #43456:
URL: https://github.com/apache/airflow/pull/43456#discussion_r1821404777
##########
providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py:
##########
@@ -237,10 +237,13 @@ def _load_into_existing_table(self) -> str:
total_items += page.get("Count", 0)
dynamodb_hook.write_batch_data(items=page["Items"])
self.log.info("Number of items loaded: %s", total_items)
+ except Exception as e:
+ # Does not raise errors to keep previous behavior.
Review Comment:
This comment implies that this is not a bug but a backward-compatability choice. Based solely on that comment, this would appear to be a breaking change, not a bugfix? Do we need to do a deprecation process for this?
--
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