spcl / serverless-benchmarks

SeBS: serverless benchmarking suite for automatic performance analysis of FaaS platforms.
https://mcopik.github.io/projects/sebs/
BSD 3-Clause "New" or "Revised" License
149 stars 67 forks source link

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

Open oanarosca opened 6 months ago

oanarosca commented 6 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 4 months ago

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](https://discordapp.com/channels/1134356397673414807/1279579842131787838) 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](https://discordapp.com/channels/1134356397673414807/1282535539299323995) 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: ```shell #!/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: ```shell #!/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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.