-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(event_source): add Kinesis Firehose Data Transformation data class #3029
feat(event_source): add Kinesis Firehose Data Transformation data class #3029
Conversation
from here powertools-lambda-python/aws_lambda_powertools/utilities/data_classes/common.py Lines 13 to 14 in 04cf87f
This DictWrapper is designed to be read-only and used by all data-classes. Currently all data-classes in powertools are used to parse events. But for this issue, we are using data-classes to create the event. And this use case doesn't exist in powertools data-classes yet.In this case I can't set value directly to data class expect init the class with data parameter. As you can see in my current code, powertools-lambda-python/aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py Lines 89 to 103 in 6eb8530
I'm using a From my perspective I can think of three possible solution of to support this
# possible UX
result = KinesisFirehoseResponce({})
for record in event.records:
data = record.data_as_json
processed_record = KinesisFirehoseResponceRecord(
record_id=record.record_id,
result=FirehoseStateOk,
)
processed_record.data_from_json(data)
result.add_record(processed_record)
return result
# possible UX
processed_record = KinesisFirehoseResponceRecord(
record_id=record.record_id,
result=FirehoseStateOk,
data=data,
)
# possible UX
data={
"record_id":record.record_id,
"result":FirehoseStateOk,
"data":data_raw,
}
record = KinesisFirehoseResponceRecord(data=data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @roger-zhangg! I'm reviewing the code, your comments, and reading the AWS documentation for Kinesis Firehose Response, but in the meantime, I think you should fix these issues.
Please mark this PR as "ready to review".
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_response.py
Outdated
Show resolved
Hide resolved
Codecov ReportPatch coverage:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #3029 +/- ##
===========================================
- Coverage 96.36% 96.13% -0.23%
===========================================
Files 185 186 +1
Lines 8064 8131 +67
Branches 1509 1525 +16
===========================================
+ Hits 7771 7817 +46
- Misses 236 252 +16
- Partials 57 62 +5
☔ View full report in Codecov by Sentry. |
I like this UX, easy and clean to create records and add these in the response. I'm just wondering if we really need |
Please review the class name, there is a typo: Thanks |
Thanks for the suggestion, I'll refactor to remove the |
You can make this UX even nicer by having a method in the Kinesis Record
that returns a standalone KinesisFirehoseResponceRecord.
That way you don’t need to ask for the record ID since you’re building it
from the record already, and can have more fluid options like JSON to get
the payload in the expected shape etc.
Play around with it later
…On Wed, 30 Aug 2023 at 23:43, Roger Zhang ***@***.***> wrote:
Thanks for the suggestion, I'll refactor to remove the DictWrapper and
keep this UX
—
Reply to this email directly, view it on GitHub
<#3029 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBF56EU6QI6O55BTIVTXX6XYFANCNFSM6AAAAAA4DXDDDM>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some few comments.
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py
Outdated
Show resolved
Hide resolved
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py
Outdated
Show resolved
Hide resolved
coming at this later tonight... had to switch to #3091 as it seemed a potential customer issue |
Three quick things only and we can merge <3
|
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]>
…ls-python into kinesis
Signed-off-by: heitorlessa <[email protected]>
Signed-off-by: heitorlessa <[email protected]>
As soon as the docs contain both the default ( Gonna to go to bed (10:33pm) |
…ls-python into kinesis
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Docs final touches sent
|
Now I can go to sleep hahaha. Thank you SO MUCH both of you for the great work here ;) |
Thank you all! This is a very exciting feature for Powertools |
Issue number:#2440
Summary
Support Kinesis Firehose Response Record data class in event_sources.
This PR is still in draft status, much to discuss including
Changes
User experience
BEFORE
AFTER
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.