[#64] Queue and Storage triggers for AWS, GCP and Azure
Summary by CodeRabbit
-
New Features
- Introduced
QueueTriggerandStorageTriggerfor AWS, allowing interaction with SQS and S3 for handling asynchronous and storage-related events. - Added functionality in GCP to manage trigger resources (queues, storage) ensuring they exist before function deployment.
- Enhanced Azure function handler to support multiple triggers, including HTTP requests, queue messages, and blob storage events.
- Introduced
-
Enhancements
- New methods for creating, configuring, and updating function triggers in GCP.
- Improved event handling logic in AWS Lambda to process messages from SQS and S3.
- Expanded Azure and GCP classes to dynamically generate function configurations based on trigger types.
- Updated configuration files to support new dependencies and deployment capabilities related to queue management.
Walkthrough
The recent updates introduce new trigger types (QueueTrigger and StorageTrigger) to the AWS, Azure, and GCP modules, enhancing the ability to handle asynchronous and storage-related events. Additionally, methods for managing trigger resources have been added, ensuring their creation and configuration prior to function deployment. These changes collectively expand the event-driven capabilities across multiple cloud platforms.
Changes
| File | Change Summary |
|---|---|
sebs/aws/triggers.py |
Introduced QueueTrigger and StorageTrigger classes with methods for handling SQS and S3 events. |
sebs/gcp/gcp.py |
Added methods to manage trigger resources, ensuring their existence before function deployment. |
benchmarks/wrappers/aws/python/handler.py |
Enhanced event handling to support SQS and S3 events in AWS Lambda functions. |
benchmarks/wrappers/azure/python/handler.py |
Renamed main function and added support for handling Azure Queue and Blob Storage events. |
benchmarks/wrappers/gcp/python/handler.py |
Restructured handler to support GCP Queue and Storage events. |
benchmarks/wrappers/aws/python/queue.py |
Implemented a wrapper class for interacting with AWS SQS. |
benchmarks/wrappers/azure/python/queue.py |
Introduced a class for interacting with Azure Storage Queues. |
benchmarks/wrappers/gcp/python/queue.py |
Added a class for publishing messages to Google Cloud Pub/Sub. |
sebs/aws/aws.py |
Updated functions to handle new trigger types for AWS Lambda. |
sebs/azure/azure.py |
Enhanced function configuration and trigger management for Azure functions. |
sebs/azure/triggers.py |
Added QueueTrigger and StorageTrigger classes for Azure Queue and Blob operations. |
sebs/gcp/triggers.py |
Introduced QueueTrigger and StorageTrigger classes for GCP Pub/Sub and Cloud Storage interactions. |
config/systems.json |
Expanded configuration for Python base images and added new dependencies for Azure functionality. |
docs/modularity.md |
Updated documentation to reflect new trigger types and their configurations. |
requirements.gcp.txt |
Added dependency for Google Cloud Pub/Sub. |
tests/aws/create_function.py |
Included queue.py in the package files for AWS function creation tests. |
scripts/run_experiments.py |
Updated initialization to include queue.py. |
Poem
In the cloud where functions play,
New triggers dance in bright array.
Queues and storage, side by side,
In eventful realms, they now abide.
With every message, data flows,
In harmony, our system grows! 🐇✨
[!TIP]
Announcements
- The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
- We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
- Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
- Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
- Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).
Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL
Commits
Files that changed from the base of the PR and between dac2840e0d85d894e9122ac33630847c4a1731c1 and 7de164e411d82bfc7769bc55db59a7be798167db.
Files selected for processing (8)
- config/systems.json (3 hunks)
- docs/platforms.md (1 hunks)
- sebs.py (3 hunks)
- sebs/azure/azure.py (7 hunks)
- sebs/cache.py (1 hunks)
- sebs/faas/system.py (1 hunks)
- sebs/gcp/gcp.py (9 hunks)
- sebs/local/local.py (1 hunks)
Files skipped from review due to trivial changes (2)
- docs/platforms.md
- sebs/cache.py
Additional context used
Ruff
sebs/azure/azure.py
259-259: Use context handler for opening files
(SIM115)
Additional comments not posted (13)
config/systems.json (1)
74-75: LGTM!The changes look good:
- Adding
queue.pyto the deployment files across multiple sections indicates that this file is now part of the deployment process.- Adding
azure-storage-queueandazure-identitypackages suggests an expansion of functionality related to Azure services.- The formatting changes (new lines before the added packages) may improve readability.
Also applies to: 120-122
sebs.py (3)
181-181: LGTM!The code changes to add "queue" and "storage" trigger choices are approved.
Line range hint
232-257: LGTM!The code changes to handle the new trigger types in the
invokefunction are approved.
Line range hint
223-223: LGTM!The code change to add the optional
triggerparameter to thepackage_codefunction is approved.sebs/azure/azure.py (3)
257-261: LGTM!The code changes to utilize the
create_function_jsonmethod in thepackage_codefunction are approved.Tools
Ruff
259-259: Use context handler for opening files
(SIM115)
356-361: LGTM!The code changes to conditionally create an
HTTPTriggerin theupdate_functionmethod are approved.
585-647: Approved: Methodcreate_triggersupports multiple trigger types.The changes to the
create_triggermethod significantly enhance the functionality by supporting both queue and storage triggers. The method effectively sets up the necessary Azure resources and permissions.The method also raises a
RuntimeErrorfor unsupported trigger types, which is a good practice for error handling.Verify that the
RuntimeErroris raised for unsupported trigger types:Verification successful
Verified:
RuntimeErroris raised for unsupported trigger types increate_trigger.The
create_triggermethod insebs/azure/azure.pycorrectly raises aRuntimeErrorfor unsupported trigger types, confirming the implementation of error handling as expected.
- Location:
sebs/azure/azure.pyScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `create_trigger` raises a `RuntimeError` for unsupported trigger types. # Test: Search for the `RuntimeError` being raised. Expect: The `RuntimeError` is raised for unsupported trigger types. rg --type python -A 5 $'raise RuntimeError\("Not supported!"\)'Length of output: 95
Script:
#!/bin/bash # Description: Verify that `create_trigger` raises a `RuntimeError` for unsupported trigger types. # Test: Search for the `RuntimeError` being raised. Expect: The `RuntimeError` is raised for unsupported trigger types. rg --type py -A 5 $'raise RuntimeError\("Not supported!"\)'Length of output: 1744
sebs/gcp/gcp.py (6)
143-192: LGTM!The
create_trigger_resourcemethod is well-implemented and enhances the functionality related to trigger resources in GCP. It effectively checks the trigger type, creates the necessary resources, logs the creation process, and handles potential conflicts if the resources already exist.
251-252: LGTM!The code changes to write additional dependencies to the
requirements.txtfile in thepackage_codefunction are approved.
311-314: LGTM!The code changes to call
create_trigger_resourcebefore creating the function in thecreate_functionmethod are approved. This ensures that the required trigger resources are created before the function deployment process.
380-416: LGTM!The code changes to the
create_triggermethod to handle different trigger types, including HTTP, Queue, and Storage triggers, are approved. The method now importsQueueTriggerandStorageTriggerclasses and includes appropriate logging for each trigger type, providing a more structured approach to managing triggers.
428-441: LGTM!The code changes to the
cached_functionmethod to handle different trigger types, includingLibraryTrigger,QueueTrigger, andStorageTrigger, are approved. These changes enhance the functionality of the method by allowing it to handle different trigger types.
457-460: LGTM!The code changes to call
create_trigger_resourcebefore updating the function in theupdate_functionmethod are approved. This ensures that the required trigger resources are verified before the function deployment process.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.