-
Notifications
You must be signed in to change notification settings - Fork 402
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(data_classes): add KinesisFirehoseEvent #1540
feat(data_classes): add KinesisFirehoseEvent #1540
Conversation
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
@ryandeivert it seems we have a couple of failing tests due to mypy errors. Can you take a look at them, please? |
hi @rubenfonseca I just pushed a commit that I think will resolve these. would you mind approving the CI job? thanks! |
sorry @rubenfonseca - I had some syntax errors (missing |
0189976
to
5654d98
Compare
@rubenfonseca okay I think the latest commit should do it now - ran |
5654d98
to
e556593
Compare
I've tried to figured out why this is failing here: https://github.com/awslabs/aws-lambda-powertools-python/actions/runs/3117242603/jobs/5057874979 it looks unrelated to my changes, and related to this recently merged change: #1526 I have merged the develop branch into this feature branch in hopes that it resolves that failure(s) |
Hey Ryan, apologies we missed this linting issue - we’re doing an offsite
on Monday and should get back to you soon after; appreciate your patience
and support.
This feature is one of those we can improve developer experience a lot -
Firehose events expect certain responses too, so this is a great stepping
stone to create an additional Batch Processor after this is merged.
Thank you for helping make everyone’s experience better <3
…On Sat, 24 Sep 2022 at 22:05, ryandeivert ***@***.***> wrote:
I've tried to figured out why this is failing here:
https://github.com/awslabs/aws-lambda-powertools-python/actions/runs/3117242603/jobs/5057874979
it looks unrelated to my changes, and related to this recently merged
change: #1526
<#1526>
I have merged the develop branch into this feature branch in hopes that it
resolves that failure(s)
—
Reply to this email directly, view it on GitHub
<#1540 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBFSAGSJHBRNPSXM333V75NJ3ANCNFSM6AAAAAAQTV3YR4>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
Hi all! Just to help here, I created a Kinesis Firehose using a Lambda as a data transform and the payload is as per the documentation (https://docs.aws.amazon.com/lambda/latest/dg/services-kinesisfirehose.html). There are some optional fields which should be fine to create a test for them. |
55c22dc
to
642734f
Compare
Codecov ReportBase: 99.77% // Head: 99.76% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #1540 +/- ##
===========================================
- Coverage 99.77% 99.76% -0.02%
===========================================
Files 126 127 +1
Lines 5819 5884 +65
Branches 663 668 +5
===========================================
+ Hits 5806 5870 +64
Misses 6 6
- Partials 7 8 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Thank you so much for this! Really looking forward to merge this :) A couple of things:
- I've rebased with
develop
so the mypy error is gone - I've extracted the sample in the documentation to the
examples
folder, so we can cover it with mypy and linting tools - I believe we should create a second test for the case where the Kinesis Firehose is configured with Direct PUT mode. In this case, there's no record metadata. I'm pasting a sample here that you can use
{
"invocationId": "3af0fd17-6799-4368-a857-ae2c18a47560",
"deliveryStreamArn": "arn:aws:firehose:eu-north-1:123456789:deliverystream/PUT-HTP-dNJEu",
"region": "eu-north-1",
"records": [
{
"recordId": "49633694907038825242852484918537387102326040674489597954000000",
"approximateArrivalTimestamp": 1664287467647,
"data": "eyJDSEFOR0UiOjEuMjUsIlBSSUNFIjoxMjAuMDEsIlRJQ0tFUl9TWU1CT0wiOiJJT1AiLCJTRUNUT1IiOiJURUNITk9MT0dZIn0="
}
]
}
Let me know if this makes sense :)
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
@ryandeivert let me know if you want us to make the changes above, so we can merge your PR and include this in our next release! |
Hi @ryandeivert and @rubenfonseca! I'll work to fix small things in this PR and include this feature in the next release, ok? |
hi @leandrodamascena / @rubenfonseca -- so sorry I fell off on this. you are welcome to make these changes or I can get to it later this week! |
No need to apologize! We know everyone is very busy. Be our guest and feel free to fix these small changes 😃 We expect to release a new version next week, so we have time to wait for your update. btw, i will add more comments on this PR. Thanks for the prompt reply. |
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
aws_lambda_powertools/utilities/data_classes/kinesis_firehose_event.py
Outdated
Show resolved
Hide resolved
I made two commits because it only change the type and that reduces the work a little. There was an error in the pipeline, but when you make the final changes, it will be fixed. Thanks |
hi @leandrodamascena taking a look at this now. will follow up |
hi @leandrodamascena -- I believe I have addressed all of the requests. I merged the develop branch into this and used the new test events provided in the other recently merged PR |
Hiiii @ryandeivert! That's amazing that you can handle all the changes quickly! I will check this tomorrow! I see that the pipeline is failing some test, but don't worry if you can't solve it now, I can fix that. Thank you!! |
@leandrodamascena sorry about that! I think it should be fixed now.. |
def data_as_json(self) -> dict: | ||
"""Decoded base64-encoded data loaded to json""" | ||
if self._json_data is None: | ||
self._json_data = json.loads(self.data_as_text) | ||
return self._json_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.
I think we need to review this piece of code.
This is not your fault, we have this method/property as default in all classes and this can be a problem for records that allow non-json data like firehose put
is and maybe others.. Check this out
We'll discuss this in our daily sync on Monday and I back here with updates.
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.
EAFP
Hi @ryandeivert pls don't apologize, you did a great job! Everything is working as expected (I tested it locally) and I'm just worried about this. If we assume that all data is a JSON object can be a problem for those who use |
@leandrodamascena thanks for all the feedback! when I'd robbed that logic from another data class, I did have this same question. however, my conclusion at the time was that users implementing this event source will likely know whether or not their data is in fact json, and would use the appropriate function accordingly. In the event (for whatever reason) that users do not know for certain, I would foresee them wrapping the call to This method simply leverages Python's duck-typing concept and IMO isn't something you need to address in this convenience function (aside from adding documentation that it could raise a I'm fine with whatever you all land on for this - just let me know the outcome and if you want me to make any additional changes! |
I think it might be a good solution.
We avoid breaking changes without proper communication with our clients, so removing this in other classes isn't a good idea in fact.
Let me share your thoughts with others and I'll be back here with updates on Monday/Tuesday. Thanks. |
Hi @ryandeivert! We think this is the best approach and users can handle the exception on their side if the data is not json. Using the other solution to fall back to the So I think this PR is ready to merge. If you don't have any other consideration we can merge it. |
@leandrodamascena sounds good to me! nothing else on my end :) feel free to merge when you see fit! |
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Issue number: #1539
Summary
Adding
KinesisFirehoseEvent
data class for handling Kinesis Firehose Lambda events (for Data Transformation).Changes
KinesisFirehoseEvent
data class and respective sub-DictWrapper classes for handling Kinesis firehose event structureKinesisFirehoseEvent
KinesisFirehoseEvent
User experience
This is included in the documentation updates.
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.
View rendered docs/utilities/data_classes.md