serverless-benchmarks icon indicating copy to clipboard operation
serverless-benchmarks copied to clipboard

[#64] Queue and Storage triggers for AWS, GCP and Azure

Open oanarosca opened this issue 2 years ago • 1 comments

Summary by CodeRabbit

  • New Features

    • Introduced QueueTrigger and StorageTrigger for 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.
  • 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.

oanarosca avatar May 06 '24 16:05 oanarosca

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.py to the deployment files across multiple sections indicates that this file is now part of the deployment process.
  • Adding azure-storage-queue and azure-identity packages 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 invoke function are approved.


Line range hint 223-223: LGTM!

The code change to add the optional trigger parameter to the package_code function is approved.

sebs/azure/azure.py (3)

257-261: LGTM!

The code changes to utilize the create_function_json method in the package_code function are approved.

Tools
Ruff

259-259: Use context handler for opening files

(SIM115)


356-361: LGTM!

The code changes to conditionally create an HTTPTrigger in the update_function method are approved.


585-647: Approved: Method create_trigger supports multiple trigger types.

The changes to the create_trigger method 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 RuntimeError for unsupported trigger types, which is a good practice for error handling.

Verify that the RuntimeError is raised for unsupported trigger types:

Verification successful

Verified: RuntimeError is raised for unsupported trigger types in create_trigger.

The create_trigger method in sebs/azure/azure.py correctly raises a RuntimeError for unsupported trigger types, confirming the implementation of error handling as expected.

  • Location: sebs/azure/azure.py
Scripts 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_resource method 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.txt file in the package_code function are approved.


311-314: LGTM!

The code changes to call create_trigger_resource before creating the function in the create_function method 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_trigger method to handle different trigger types, including HTTP, Queue, and Storage triggers, are approved. The method now imports QueueTrigger and StorageTrigger classes 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_function method to handle different trigger types, including LibraryTrigger, QueueTrigger, and StorageTrigger, 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_resource before updating the function in the update_function method 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?

Share
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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Jul 05 '24 05:07 coderabbitai[bot]