sebs.aws package

Submodules

sebs.aws.aws module

AWS Lambda implementation for the SeBs framework.

This module provides the AWS implementation of the FaaS System interface. It handles deploying and managing serverless functions on AWS Lambda, including code packaging, function creation, trigger management, and metrics collection.

class sebs.aws.aws.AWS(sebs_config: SeBSConfig, config: AWSConfig, cache_client: Cache, docker_client: DockerClient, logger_handlers: LoggingHandlers)[source]

Bases: System

AWS Lambda implementation of the System interface.

This class implements the FaaS System interface for AWS Lambda, providing methods for deploying, invoking, and managing Lambda functions.

logs_client

AWS CloudWatch Logs client

cached

Whether AWS resources have been cached

_config

AWS-specific configuration

Type:

sebs.aws.config.AWSConfig

cached = False
cached_function(function: Function) None[source]

Set up triggers for a cached function.

Configures triggers for a function that was loaded from cache, ensuring they have proper logging handlers and deployment client references.

Parameters:

function – Function instance to configure triggers for

cleanup_resources(dry_run: bool = False) dict[source]

Delete allocated resources on AWS. Currently it deletes the following resources: * Lambda functions and its HTTP API triggers. * CloudWatch log groups of the functions. * DynamoDB tables created for the benchmark. * S3 buckets and their content created for the benchmark. * ECR repositories (images are retained locally).

Parameters:

dry_run – when true, only display resources.

Returns:

dictionary with the list of deleted resources for each resource type.

cloud_runtime(language: Language, language_version: str)[source]

Map language runtime to AWS Lambda-compatible format.

AWS uses different naming schemes for runtime versions. For example, Node.js uses ‘12.x’ instead of ‘12’.

Parameters:
  • language – Language name (e.g., ‘nodejs’, ‘python’)

  • runtime – Runtime version (e.g., ‘12’, ‘3.8’)

Returns:

AWS Lambda-compatible runtime version

Return type:

str

property config: AWSConfig

Get the AWS-specific configuration.

Returns:

AWS configuration

Return type:

AWSConfig

property container_client: ECRContainer | None

Get the AWS-specific container manager that uses ECR.

Returns:

Container manager instance.

create_function(code_package: Benchmark, func_name: str, container_deployment: bool, container_uri: str | None) LambdaFunction[source]

Create or update an AWS Lambda function.

If the function already exists, it updates the code and configuration. Otherwise, it creates a new function with the specified parameters.

Parameters:
  • code_package – Benchmark code package

  • func_name – Name of the function

  • container_deployment – Whether to use container deployment

  • container_uri – URI of the container image (if container_deployment=True)

Returns:

The created or updated Lambda function

Return type:

LambdaFunction

create_trigger(func: Function, trigger_type: TriggerType) Trigger[source]

Create a trigger for the specified function.

Creates and configures a trigger based on the specified type. Currently supports HTTP triggers (via API Gateway) and library triggers.

Parameters:
  • func – Function to create trigger for

  • trigger_type – Type of trigger to create (HTTP or LIBRARY)

Returns:

The created trigger instance

Return type:

Trigger

Raises:

RuntimeError – If trigger type is not supported

default_function_name(code_package: Benchmark, resources: Resources | None = None) str[source]

Generate default function name for a benchmark.

Creates a standardized function name based on resource ID, benchmark name, language, version, and architecture. Ensures the name is compatible with AWS Lambda naming requirements.

Parameters:
  • code_package – Benchmark code package

  • resources – Optional resources object (uses default if not provided)

Returns:

Formatted function name suitable for AWS Lambda

Return type:

str

delete_function(func_name: str) None[source]

Delete an AWS Lambda function.

Parameters:

func_name – Name of the function to delete

disable_rich_output() None[source]

Disable rich output formatting for ECR operations.

Disables colored/formatted output in the ECR container client, useful for CI/CD environments or when plain text output is preferred.

download_metrics(function_name: str, start_time: int, end_time: int, requests: Dict[str, ExecutionResult], metrics: dict) None[source]

Download execution metrics from CloudWatch Logs.

Queries CloudWatch Logs for Lambda execution reports and parses them to extract performance metrics for each request.

Parameters:
  • function_name – Name of the Lambda function

  • start_time – Start time for metrics collection (Unix timestamp)

  • end_time – End time for metrics collection (Unix timestamp)

  • requests – Dictionary mapping request IDs to ExecutionResult objects

  • metrics – Dictionary to store collected metrics

enforce_cold_start(functions: List[Function], code_package: Benchmark) None[source]

Enforce cold start for multiple functions.

Updates all specified functions to force cold starts on their next invocations. This is useful for ensuring consistent performance measurements.

Parameters:
  • functions – List of functions to enforce cold start for

  • code_package – Benchmark code package with configuration

static format_function_name(func_name: str) str[source]

Format function name for AWS Lambda compatibility.

AWS Lambda has specific naming requirements. This method ensures the function name complies with AWS Lambda naming rules.

Parameters:

func_name – Raw function name

Returns:

Formatted function name with illegal characters replaced

Return type:

str

static function_type() Type[Function][source]

Get the function type for this system.

Returns:

LambdaFunction class

Return type:

Type[Function]

get_invocation_error(function_name: str, start_time: int, end_time: int) None[source]

Retrieve and log invocation errors from CloudWatch Logs.

Queries CloudWatch Logs for error messages during the specified time range and logs them for debugging purposes.

Parameters:
  • function_name – Name of the Lambda function

  • start_time – Start time for log query (Unix timestamp)

  • end_time – End time for log query (Unix timestamp)

Note

It is unclear at the moment if this function is always working correctly.

get_lambda_client()[source]

Get or create an AWS Lambda client.

Returns:

Lambda client

Return type:

boto3.client

initialize(config: Dict[str, str] = {}, resource_prefix: str | None = None)[source]

Initialize AWS resources.

Creates a boto3 session, initializes Lambda client, and prepares system resources and ECR client.

Parameters:
  • config – Additional configuration parameters

  • resource_prefix – Optional prefix for resource names

logs_client = None
static name() str[source]

Get the name of this system.

Returns:

System name (‘aws’)

Return type:

str

package_code(directory: str, language: Language, language_version: str, architecture: str, benchmark: str, is_cached: bool) Tuple[str, int][source]

Package code for deployment to AWS Lambda.

Creates a suitable deployment package with the following structure:

function/
  - function.py
  - storage.py
  - resources/
handler.py

It would be sufficient to just pack the code and ship it as zip to AWS. However, to have a compatible function implementation across providers, we create a small module. Issue: relative imports in Python when using storage wrapper. Azure expects a relative import inside a module thus it’s easier to always create a module.

Parameters:
  • directory – Path to the code directory

  • language – Programming language name (e.g., ‘python’, ‘nodejs’)

  • language_version – Language version (e.g., ‘3.8’, ‘14’)

  • architecture – Target CPU architecture (e.g., ‘x64’, ‘arm64’)

  • benchmark – Benchmark name

  • is_cached – Whether code is already cached

Returns:

  • Path to the packaged code (ZIP file)

  • Size of the package in bytes

Return type:

Tuple containing

static parse_aws_report(log: str, requests: ExecutionResult | Dict[str, ExecutionResult]) str[source]

Parse AWS Lambda execution report from CloudWatch logs.

Extracts execution metrics from AWS Lambda log entries and updates the corresponding ExecutionResult objects with timing, memory, billing information, and init duration (when provided).

Parameters:
  • log – Raw log string from CloudWatch or synchronous invocation

  • requests – Either a single ExecutionResult or dictionary mapping request IDs to ExecutionResult objects

Returns:

Request ID of the parsed execution

Return type:

str

Example

The log format expected is tab-separated AWS Lambda report format: “REPORT RequestId: abc123 Duration: 100.00 ms Billed Duration: 100 ms …”

shutdown() None[source]

Shutdown the AWS system and clean up resources.

Calls the parent shutdown method to perform standard cleanup.

property system_resources: AWSSystemResources

Get the AWS system resources manager.

Returns:

AWS resource manager

Return type:

AWSSystemResources

static typename() str[source]

Get the type name of this system.

Returns:

Type name (‘AWS’)

Return type:

str

update_function(function: Function, code_package: Benchmark, container_deployment: bool, container_uri: str | None)[source]

Update an existing AWS Lambda function.

Updates the function code and waits for the update to complete. For container deployments, updates the container image. For ZIP deployments, uploads the code package directly or via S3.

Parameters:
  • function – The function to update

  • code_package – Benchmark code package

  • container_deployment – Whether to use container deployment

  • container_uri – URI of the container image (if container_deployment=True)

update_function_configuration(function: Function, code_package: Benchmark, env_variables: dict = {}) None[source]

Update Lambda function configuration.

Updates the function’s timeout, memory, and environment variables. Automatically adds environment variables for NoSQL storage table names if the benchmark uses NoSQL storage.

Parameters:
  • function – Function to update

  • code_package – Benchmark code package with configuration

  • env_variables – Additional environment variables to set

Raises:

AssertionError – If code package input has not been processed

wait_function_active(func: LambdaFunction) None[source]

Wait for Lambda function to become active after creation.

Uses AWS Lambda waiter to wait until the function is in Active state and ready to be invoked.

Parameters:

func – Lambda function to wait for

wait_function_updated(func: LambdaFunction) None[source]

Wait for Lambda function to complete update process.

Uses AWS Lambda waiter to wait until the function update is complete and the function is ready to be invoked with new configuration.

Parameters:

func – Lambda function to wait for

sebs.aws.config module

Configuration management for AWS SeBS integration.

This module provides configuration classes for AWS credentials, resources, and settings used when deploying to AWS Lambda. It handles AWS authentication, resource management including ECR repositories, IAM roles, and HTTP APIs, along with caching and serialization capabilities.

Key classes:

AWSCredentials: Manages AWS access credentials and account information AWSResources: Manages AWS resources like ECR repositories, IAM roles, and HTTP APIs AWSConfig: Main configuration container combining credentials and resources

class sebs.aws.config.AWSConfig(credentials: AWSCredentials, resources: AWSResources)[source]

Bases: Config

Main AWS configuration container.

Combines AWS credentials and resources into a single configuration object for use by the AWS SeBS implementation.

_credentials

AWS authentication credentials

_resources

AWS resource management configuration

property credentials: AWSCredentials

Get AWS credentials.

Returns:

AWS authentication credentials

Return type:

AWSCredentials

static deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) Config[source]

Deserialize AWS configuration from config and cache.

Creates an AWSConfig instance by deserializing credentials and resources, then loading region configuration from cache or user-provided config.

Parameters:
  • config – Configuration dictionary

  • cache – Cache instance for retrieving cached configuration

  • handlers – Logging handlers for status messages

Returns:

Deserialized AWSConfig instance

Return type:

Config

static initialize(cfg: Config, dct: dict) None[source]

Initialize AWS configuration from dictionary.

Parameters:
  • cfg – Base Config instance to initialize

  • dct – Dictionary containing ‘region’ configuration

property resources: AWSResources

Get AWS resources configuration.

Returns:

AWS resource management configuration

Return type:

AWSResources

serialize() dict[source]

Serialize AWS configuration to dictionary.

Returns:

Serialized configuration including name, region, credentials, and resources

Return type:

dict

static typename() str[source]

Get the type name for this configuration.

Returns:

The type name ‘AWS.Config’

Return type:

str

update_cache(cache: Cache) None[source]

Update the contents of the user cache.

The changes are directly written to the file system. Updates region, credentials, and resources in the cache.

Parameters:

cache – Cache instance to update

class sebs.aws.config.AWSCredentials(access_key: str, secret_key: str)[source]

Bases: Credentials

AWS authentication credentials for SeBS.

This class manages AWS access credentials including access key, secret key, and automatically retrieves the associated AWS account ID through STS.

Account ID is cached to retain information on which account was the benchmark executed. Credentials are not cached.

_access_key

AWS access key ID

_secret_key

AWS secret access key

_account_id

AWS account ID retrieved via STS

property access_key: str

Get the AWS access key ID.

Returns:

AWS access key ID

Return type:

str

property account_id: str

Get the AWS account ID.

Returns:

AWS account ID

Return type:

str

static deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) Credentials[source]

Deserialize AWS credentials from configuration and cache.

Loads AWS credentials from configuration file, environment variables, or cache. Validates that credentials match cached account ID if available.

Parameters:
  • config – Configuration dictionary that may contain credentials

  • cache – Cache instance for retrieving/storing credentials

  • handlers – Logging handlers for error reporting

Returns:

Deserialized AWSCredentials instance

Return type:

Credentials

Raises:

RuntimeError – If credentials are missing or don’t match cached account

static initialize(dct: dict) AWSCredentials[source]

Initialize AWS credentials from a dictionary.

Parameters:

dct – Dictionary containing ‘access_key’ and ‘secret_key’

Returns:

Initialized credentials object

Return type:

AWSCredentials

Raises:

KeyError – If required keys are missing from dictionary

property secret_key: str

Get the AWS secret access key.

Returns:

AWS secret access key

Return type:

str

serialize() dict[source]

Serialize credentials to a dictionary.

Returns:

Dictionary containing account_id

Return type:

dict

static typename() str[source]

Get the type name for these credentials.

Returns:

The type name ‘AWS.Credentials’

Return type:

str

update_cache(cache: Cache) None[source]

Update the cache with current credentials.

Parameters:

cache – Cache instance to update

class sebs.aws.config.AWSResources(registry: str | None = None, username: str | None = None, password: str | None = None)[source]

Bases: Resources

AWS resource management for SeBS.

This class manages AWS-specific resources including ECR repositories, IAM roles, HTTP APIs, and Docker registry configurations. It provides methods for creating and managing these resources with caching support.

_docker_registry

Docker registry URL (ECR repository URI)

_docker_username

Docker registry username

_docker_password

Docker registry password

_container_repository

ECR repository name

_lambda_role

IAM role ARN for Lambda execution

_http_apis

Dictionary of HTTP API configurations

class HTTPApi(arn: str, endpoint: str)[source]

Bases: object

HTTP API configuration for AWS API Gateway.

Represents an HTTP API resource in AWS API Gateway with its ARN and endpoint.

_arn

API Gateway ARN

_endpoint

API Gateway endpoint URL

property arn: str

Get the API Gateway ARN.

Returns:

API Gateway ARN

Return type:

str

static deserialize(dct: dict) HTTPApi[source]

Deserialize HTTP API from dictionary.

Parameters:

dct – Dictionary containing ‘arn’ and ‘endpoint’

Returns:

Deserialized HTTP API instance

Return type:

AWSResources.HTTPApi

property endpoint: str

Get the API Gateway endpoint URL.

Returns:

API Gateway endpoint URL

Return type:

str

serialize() dict[source]

Serialize HTTP API to dictionary.

Returns:

Dictionary containing arn and endpoint

Return type:

dict

check_ecr_repository_exists(ecr_client: ECRClient, repository_name: str) str | None[source]

Check if ECR repository exists.

Parameters:
  • ecr_client – ECR client instance

  • repository_name – Name of the ECR repository

Returns:

Repository URI if exists, None otherwise

Return type:

Optional[str]

Raises:

Exception – If ECR operation fails (other than RepositoryNotFound)

cleanup_cloudwatch_logs(function_names: List[str], boto3_session: Session, dry_run: bool) List[str][source]

Remove CloudWatch logs for selected functions.

Parameters:
  • function_names – list of function names to clean up logs for

  • boto3_session – boto3 session for AWS API calls

  • dry_run – when true, skip actual deletion

Returns:

list of deleted log group names

cleanup_ecr_repository(boto3_session: Session, cache_client: Cache, dry_run: bool = False) List[str][source]

Remove ECR repository used for container images.

Parameters:
  • boto3_session – boto3 session for AWS API calls

  • cache_client – SeBS cache instance

  • dry_run – when true, skip actual deletion

Returns:

list of deleted ECR repositories (currently always one)

cleanup_http_apis(boto3_session: Session, cache_client: Cache, dry_run: bool = False) List[str][source]

Remove HTTP APIs allocated for HTTP triggers.

Parameters:
  • boto3_session – boto3 session for AWS API calls

  • cache_client – SeBS cache client

  • dry_run – when true, skip actual deletion

Returns:

list of deleted HTTP API names

property container_repository: str | None

Get the ECR repository name.

Returns:

ECR repository name

Return type:

Optional[str]

static deserialize(config: dict, cache: Cache, handlers: LoggingHandlers) Resources[source]

Deserialize AWS resources from configuration and cache.

Parameters:
  • config – Configuration dictionary

  • cache – Cache instance for retrieving cached resources

  • handlers – Logging handlers for status messages

Returns:

Deserialized AWSResources instance

Return type:

Resources

property docker_password: str | None

Get the Docker registry password.

Returns:

Docker registry password

Return type:

Optional[str]

property docker_registry: str | None

Get the Docker registry URL.

Returns:

Docker registry URL (ECR repository URI)

Return type:

Optional[str]

property docker_username: str | None

Get the Docker registry username.

Returns:

Docker registry username

Return type:

Optional[str]

ecr_repository_authorization(ecr_client: ECRClient) Tuple[str, str, str][source]

Get ECR repository authorization credentials.

Retrieves temporary authorization token from ECR and extracts username and password for Docker registry authentication.

Parameters:

ecr_client – ECR client instance

Returns:

Username, password, and registry URL

Return type:

Tuple[str, str, str]

Raises:
  • AssertionError – If username or registry are None

  • ClientError – If ECR authorization fails

get_ecr_repository(ecr_client: ECRClient) str[source]

Get or create ECR repository for container deployments.

Creates an ECR repository with a unique name based on the resource ID if it doesn’t already exist. Updates the docker_registry property.

Parameters:

ecr_client – ECR client instance

Returns:

ECR repository name

Return type:

str

Raises:

ClientError – If ECR operations fail

http_api(api_name: str, func: LambdaFunction, boto3_session: Session) HTTPApi[source]

Get or create HTTP API for Lambda function.

Creates an HTTP API Gateway that routes requests to the specified Lambda function. If the API already exists, returns the cached instance.

Parameters:
  • api_name – Name of the HTTP API

  • func – Lambda function to route requests to

  • boto3_session – Boto3 session for AWS API calls

Returns:

HTTP API configuration

Return type:

AWSResources.HTTPApi

Raises:
  • RuntimeError – If API creation fails after retries

  • TooManyRequestsException – If API Gateway rate limits are exceeded

static initialize(res: Resources, dct: dict) None[source]

Initialize AWS resources from dictionary.

Parameters:
  • res – Base Resources instance to initialize

  • dct – Dictionary containing resource configuration

Returns:

Initialized AWS resources instance

Return type:

AWSResources

lambda_role(boto3_session: Session) str[source]

Get or create IAM role for Lambda execution.

Creates a Lambda execution role with S3 and basic execution permissions if it doesn’t already exist. The role allows Lambda functions to access S3 and write CloudWatch logs.

Parameters:

boto3_session – Boto3 session for AWS API calls

Returns:

Lambda execution role ARN

Return type:

str

Raises:

ClientError – If IAM operations fail

serialize() dict[source]

Serialize AWS resources to dictionary.

Returns:

Serialized resource configuration

Return type:

dict

static typename() str[source]

Get the type name for these resources.

Returns:

The type name ‘AWS.Resources’

Return type:

str

update_cache(cache: Cache) None[source]

Update cache with current resource configuration.

Parameters:

cache – Cache instance to update

sebs.aws.container module

AWS ECR container management for SeBS.

This module provides the ECRContainer class which handles Docker container operations for AWS Lambda deployments using Amazon Elastic Container Registry (ECR). It extends the base DockerContainer class with AWS-specific functionality for image registry operations.

Key classes:

ECRContainer: AWS ECR-specific container management

class sebs.aws.container.ECRContainer(system_config: SeBSConfig, session: Session, config: AWSConfig, docker_client: DockerClient)[source]

Bases: DockerContainer

AWS ECR container management for SeBS.

This class handles Docker container operations specifically for AWS Lambda deployments using Amazon Elastic Container Registry (ECR). It provides functionality for building, tagging, and pushing container images to ECR.

ecr_client

AWS ECR client for registry operations

config

AWS-specific configuration

property client: ECRClient

Get the ECR client.

Returns:

AWS ECR client for registry operations

Return type:

ECRClient

find_image(repository_name: str, image_tag: str) bool[source]

Check if an image exists in the ECR repository.

Parameters:
  • repository_name – Name of the ECR repository

  • image_tag – Tag of the image to search for

Returns:

True if the image exists, False otherwise

Return type:

bool

static name() str[source]

Get the name of this container system.

Returns:

System name (‘aws’)

Return type:

str

push_image(repository_uri: str, image_tag: str) None[source]

Push a Docker image to ECR.

Authenticates with ECR using temporary credentials and pushes the specified image to the repository.

Parameters:
  • repository_uri – URI of the ECR repository

  • image_tag – Tag of the image to push

Raises:

RuntimeError – If the push operation fails

registry_name(benchmark: str, language_name: str, language_version: str, architecture: str) Tuple[str, str, str, str][source]

Generate ECR registry details for a benchmark image.

Creates the registry name, repository name, image tag, and full image URI for a specific benchmark configuration.

Parameters:
  • benchmark – Name of the benchmark

  • language_name – Programming language (e.g., ‘python’, ‘nodejs’)

  • language_version – Language version (e.g., ‘3.8’, ‘14’)

  • architecture – Target architecture (e.g., ‘x64’, ‘arm64’)

Returns:

Registry name, repository name, image tag, and image URI

Return type:

Tuple[str, str, str, str]

static typename() str[source]

Get the type name of this container system.

Returns:

Type name (‘AWS.ECRContainer’)

Return type:

str

sebs.aws.dynamodb module

AWS DynamoDB NoSQL storage implementation for SeBS.

This module provides the DynamoDB class which implements NoSQL storage functionality for the Serverless Benchmarking Suite using Amazon DynamoDB. It handles table creation, data operations, and caching for benchmark data storage.

Key classes:

DynamoDB: AWS DynamoDB NoSQL storage implementation

class sebs.aws.dynamodb.DynamoDB(session: Session, cache_client: Cache, resources: Resources, region: str, access_key: str, secret_key: str)[source]

Bases: NoSQLStorage

AWS DynamoDB NoSQL storage implementation for SeBS.

This class provides NoSQL storage functionality using Amazon DynamoDB. It handles table creation, data operations, caching, and provides a unified interface for benchmark data storage.

client

DynamoDB client for AWS API operations

_tables

Mapping of benchmark names to table configurations

_serializer

DynamoDB type serializer for data conversion

clear_table(name: str) str[source]

Clear all data from a table.

Parameters:

name – Name of the table to clear

Returns:

Result of the operation

Return type:

str

Raises:

NotImplementedError – This operation is not yet implemented

create_table(benchmark: str, name: str, primary_key: str, secondary_key: str | None = None) str[source]

Create a DynamoDB table for benchmark data.

Creates a unique DynamoDB table name using resource ID, benchmark name, and provided name. Unlike Azure (account -> database -> container) and GCP (database per benchmark), AWS requires unique table names across the account.

The function handles cases where the table already exists or is being created. Uses PAY_PER_REQUEST billing mode.

Parameters:
  • benchmark – Name of the benchmark

  • name – Logical table name

  • primary_key – Name of the primary key attribute

  • secondary_key – Optional name of the secondary key attribute

Returns:

Name of the created table

Return type:

str

Raises:

RuntimeError – If table creation fails for unknown reasons

static deployment_name() str[source]

Get the deployment name for this storage system.

Returns:

Deployment name (‘aws’)

Return type:

str

get_tables(benchmark: str) Dict[str, str][source]

Get table mappings for a benchmark.

Parameters:

benchmark – Name of the benchmark

Returns:

Mapping of logical table names to actual DynamoDB table names

Return type:

Dict[str, str]

remove_table(name: str) str[source]

Remove a table completely.

Parameters:

name – Name of the table to remove

Returns:

Result of the operation

Return type:

str

retrieve_cache(benchmark: str) bool[source]

Retrieve table configuration from cache.

Parameters:

benchmark – Name of the benchmark

Returns:

True if cache was found and loaded, False otherwise

Return type:

bool

static typename() str[source]

Get the type name for this storage system.

Returns:

Type name (‘AWS.DynamoDB’)

Return type:

str

update_cache(benchmark: str) None[source]

Update cache with current table configuration.

Parameters:

benchmark – Name of the benchmark to update cache for

write_to_table(benchmark: str, table: str, data: dict, primary_key: Tuple[str, str], secondary_key: Tuple[str, str] | None = None) None[source]

Write data to a DynamoDB table.

Parameters:
  • benchmark – Name of the benchmark

  • table – Logical table name

  • data – Data to write to the table

  • primary_key – Primary key as (attribute_name, value) tuple

  • secondary_key – Optional secondary key as (attribute_name, value) tuple

Raises:

AssertionError – If the table name is not found

sebs.aws.function module

Module for AWS Lambda function implementation in the SeBs framework.

This module provides the LambdaFunction class, which represents an AWS Lambda function in the serverless benchmarking suite. It handles AWS-specific attributes and operations such as ARN, runtime, role, and serialization.

class sebs.aws.function.LambdaFunction(name: str, benchmark: str, arn: str, code_package_hash: str, runtime: str, role: str, cfg: FunctionConfig, bucket: str | None = None)[source]

Bases: Function

AWS Lambda function implementation for the SeBs framework.

This class represents an AWS Lambda function in the serverless benchmarking suite. It extends the base Function class with AWS-specific attributes and functionality, like resource ARN, role, and optional bucket for code deployment.

arn

Amazon Resource Name of the Lambda function

role

IAM role ARN used by the function

runtime

Runtime environment for the function (e.g., ‘python3.8’)

bucket

S3 bucket name where the function code is stored

code_bucket(benchmark: str, storage_client: S3) str[source]

Get the S3 bucket for the function code.

Parameters:
  • benchmark – Name of the benchmark

  • storage_client – S3 storage client

Returns:

Name of the S3 bucket

Return type:

str

static deserialize(cached_config: dict) LambdaFunction[source]

Create a LambdaFunction instance from a cached configuration.

Parameters:

cached_config – Dictionary containing the cached function configuration

Returns:

A new instance with the deserialized data

Return type:

LambdaFunction

Raises:

AssertionError – If an unknown trigger type is encountered

serialize() dict[source]

Serialize the Lambda function to a dictionary.

Returns:

Dictionary representation of the Lambda function

Return type:

dict

static typename() str[source]

Get the type name of this class.

Returns:

The type name

Return type:

str

sebs.aws.resources module

AWS system resources management for SeBS.

This module provides the AWSSystemResources class which manages AWS-specific resources like S3 storage and DynamoDB NoSQL storage within the SeBS framework. It handles initialization, caching, and provides access to AWS services.

Key classes:

AWSSystemResources: Main resource manager for AWS services

class sebs.aws.resources.AWSSystemResources(config: AWSConfig, cache_client: Cache, docker_client: DockerClient, logger_handlers: LoggingHandlers)[source]

Bases: SystemResources

AWS system resources manager for SeBS.

This class manages AWS-specific resources including S3 storage and DynamoDB NoSQL storage. It provides a unified interface for accessing AWS services with proper session management and caching.

_session

AWS boto3 session for API calls

_logging_handlers

Logging configuration handlers

_storage

S3 storage client instance

_nosql_storage

DynamoDB NoSQL storage client instance

property config: AWSConfig

Get the AWS configuration.

Returns:

AWS-specific configuration

Return type:

AWSConfig

get_nosql_storage() NoSQLStorage[source]

Get or create DynamoDB NoSQL storage client.

Creates a client instance for DynamoDB NoSQL storage. The client is configured with AWS credentials and region from the system config.

Returns:

DynamoDB NoSQL storage client instance

Return type:

NoSQLStorage

Raises:

AssertionError – If session has not been initialized

get_storage(replace_existing: bool | None = None) PersistentStorage[source]

Get or create S3 storage client.

Creates a client instance for S3 cloud storage. Storage is initialized with required buckets that may be created or retrieved from cache.

Parameters:

replace_existing – Whether to replace existing files in cached buckets

Returns:

S3 storage client instance

Return type:

PersistentStorage

Raises:

AssertionError – If session has not been initialized

initialize_session(session: Session) None[source]

Initialize the AWS boto3 session.

Parameters:

session – Boto3 session to use for AWS API calls

static typename() str[source]

Get the type name for these resources.

Returns:

The type name ‘AWS.SystemResources’

Return type:

str

sebs.aws.s3 module

AWS S3 storage implementation for SeBS.

This module provides the S3 class which implements persistent storage functionality for the Serverless Benchmarking Suite using Amazon S3. It handles bucket creation, file upload/download operations, and caching for benchmark data storage.

Key classes:

S3: AWS S3 persistent storage implementation

class sebs.aws.s3.S3(session: Session, cache_client: Cache, resources: Resources, location: str, access_key: str, secret_key: str, replace_existing: bool)[source]

Bases: PersistentStorage

AWS S3 persistent storage implementation for SeBS.

This class provides persistent storage functionality using Amazon S3. It handles bucket creation, file operations, and provides a unified interface for benchmark data storage and retrieval.

client

S3 client for AWS API operations

cached

Whether bucket configurations are cached

clean_bucket(bucket: str) None[source]

Remove all objects from an S3 bucket.

Parameters:

bucket – Name of the bucket to clean

correct_name(name: str) str[source]

No correction is needed for S3 bucket name.

Parameters:

name – Original bucket name

Returns:

Corrected bucket name (no changes for S3)

Return type:

str

static deployment_name() str[source]

Get the deployment name for this storage system.

Returns:

Deployment name (‘aws’)

Return type:

str

download(bucket_name: str, key: str, filepath: str) None[source]

Download a file from S3.

Parameters:
  • bucket_name – Name of the S3 bucket

  • key – S3 object key of the file to download

  • filepath – Local path where the file should be saved

exists_bucket(bucket_name: str) bool[source]

Check if an S3 bucket exists and is accessible.

Parameters:

bucket_name – Name of the bucket to check

Returns:

True if bucket exists and is accessible, False otherwise

Return type:

bool

list_bucket(bucket_name: str, prefix: str = '') List[str][source]

List objects in an S3 bucket with optional prefix filtering.

Parameters:
  • bucket_name – Name of the S3 bucket

  • prefix – Optional prefix to filter objects

Returns:

List of object keys in the bucket

Return type:

List[str]

list_buckets(bucket_name: str | None = None) List[str][source]

List S3 buckets with optional name filtering.

Parameters:

bucket_name – Optional bucket name pattern to filter by

Returns:

List of bucket names

Return type:

List[str]

remove_bucket(bucket: str) None[source]

Delete an S3 bucket.

Parameters:

bucket – Name of the bucket to delete

Note

The bucket must be empty before it can be deleted

property replace_existing: bool

Get whether to replace existing files.

Returns:

True if existing files should be replaced, False otherwise

Return type:

bool

static typename() str[source]

Get the type name for this storage system.

Returns:

Type name (‘AWS.S3’)

Return type:

str

upload(bucket_name: str, filepath: str, key: str) None[source]

Upload a file to S3.

Parameters:
  • bucket_name – Name of the S3 bucket

  • filepath – Local path to the file to upload

  • key – S3 object key for the uploaded file

uploader_func(path_idx: int, key: str, filepath: str) None[source]

Upload a file to S3 with caching and replacement logic.

Handles the upload of benchmark files with appropriate caching behavior: skips upload if using cached buckets and not replacing existing files, and we know that the file is already uploaded.

Parameters:
  • path_idx – Index of the input path configuration

  • key – S3 object key for the file

  • filepath – Local path to the file to upload

sebs.aws.triggers module

AWS trigger implementations for SeBS.

This module provides trigger implementations for AWS Lambda functions, including library (direct SDK) triggers and HTTP triggers via API Gateway. Triggers handle function invocation and result processing.

Key classes:

LibraryTrigger: Direct Lambda SDK invocation trigger HTTPTrigger: HTTP API Gateway trigger

class sebs.aws.triggers.HTTPTrigger(url: str, api_id: str)[source]

Bases: Trigger

AWS API Gateway HTTP trigger for Lambda functions.

This trigger uses HTTP requests to invoke Lambda functions through AWS API Gateway. It provides both synchronous and asynchronous invocation methods.

url

API Gateway endpoint URL

api_id

API Gateway API ID

async_invoke(payload: dict) Future[source]

Asynchronously invoke the function via HTTP.

Submits the HTTP invocation to a thread pool for asynchronous execution.

Parameters:

payload – Dictionary payload to send to the function

Returns:

Future object for the async invocation

Return type:

concurrent.futures.Future

static deserialize(obj: dict) Trigger[source]

Deserialize a trigger from a dictionary.

Parameters:

obj – Dictionary containing trigger configuration

Returns:

Deserialized HTTPTrigger instance

Return type:

Trigger

serialize() dict[source]

Serialize the trigger to a dictionary.

Returns:

Serialized trigger configuration

Return type:

dict

sync_invoke(payload: dict) ExecutionResult[source]

Synchronously invoke the function via HTTP.

Sends an HTTP request to the API Gateway endpoint and waits for the response.

Parameters:

payload – Dictionary payload to send to the function

Returns:

Result of the HTTP invocation

Return type:

ExecutionResult

static trigger_type() TriggerType[source]

Get the trigger type.

Returns:

HTTP trigger type

Return type:

Trigger.TriggerType

static typename() str[source]

Get the type name for this trigger.

Returns:

Type name (‘AWS.HTTPTrigger’)

Return type:

str

class sebs.aws.triggers.LibraryTrigger(fname: str, deployment_client: AWS | None = None)[source]

Bases: Trigger

AWS Lambda library trigger for direct SDK invocation.

This trigger uses the AWS Lambda SDK to directly invoke Lambda functions. It provides both synchronous and asynchronous invocation methods with comprehensive result parsing and error handling.

name

Name of the Lambda function

_deployment_client

AWS deployment client for Lambda operations

async_invoke(payload: dict) Future[source]

Asynchronously invoke the Lambda function.

Triggers the Lambda function asynchronously without waiting for the result. Used for fire-and-forget invocations.

Parameters:

payload – Dictionary payload to send to the function

Returns:

Future object representing the async invocation

Return type:

concurrent.futures.Future

Raises:

RuntimeError – If the async invocation fails

property deployment_client: AWS

Get the AWS deployment client.

Returns:

AWS deployment client

Return type:

AWS

Raises:

AssertionError – If deployment client is not set

static deserialize(obj: dict) Trigger[source]

Deserialize a trigger from a dictionary.

Parameters:

obj – Dictionary containing trigger configuration

Returns:

Deserialized LibraryTrigger instance

Return type:

Trigger

serialize() dict[source]

Serialize the trigger to a dictionary.

Returns:

Serialized trigger configuration

Return type:

dict

sync_invoke(payload: dict) ExecutionResult[source]

Synchronously invoke the Lambda function.

Invokes the Lambda function with the provided payload and waits for the result. Parses AWS-specific metrics and benchmark output.

Parameters:

payload – Dictionary payload to send to the function

Returns:

Result of the function execution including metrics

Return type:

ExecutionResult

static trigger_type() TriggerType[source]

Get the trigger type.

Returns:

LIBRARY trigger type

Return type:

Trigger.TriggerType

static typename() str[source]

Get the type name for this trigger.

Returns:

Type name (‘AWS.LibraryTrigger’)

Return type:

str

Module contents

AWS module for the Serverless Benchmarking Suite (SeBS).

This module provides the AWS implementation of the SeBS framework, enabling deployment and management of serverless functions on AWS Lambda. It includes comprehensive support for AWS services including Lambda, S3, DynamoDB, ECR, and API Gateway.

Key components:

AWS: Main AWS system implementation LambdaFunction: AWS Lambda function representation AWSConfig: AWS-specific configuration management S3: Object storage implementation for S3 DynamoDB: Key-value store implementation for DynamoDB

The module handles AWS-specific functionality including: - Lambda function deployment and management - Container deployments via ECR - S3 storage for code packages and data - DynamoDB NoSQL storage - API Gateway HTTP triggers - IAM role management - CloudWatch metrics collection