sebs.openwhisk package
Submodules
sebs.openwhisk.config module
Configuration management for Apache OpenWhisk deployments in SeBS.
It handles Docker registry configuration, storage settings, and deployment parameters for OpenWhisk serverless functions.
- Classes:
OpenWhiskCredentials: Manages authentication credentials for OpenWhisk OpenWhiskResources: Handles Docker registry and storage resources OpenWhiskConfig: Main configuration class for OpenWhisk deployment settings
- class sebs.openwhisk.config.OpenWhiskConfig(resources: OpenWhiskResources, credentials: OpenWhiskCredentials, cache: Cache)[source]
Bases:
ConfigMain configuration class for OpenWhisk deployments.
This class focuses on OpenWhisk-specific configuration settings: cluster management, WSK CLI settings, and experimental features.
- name
Platform name identifier (‘openwhisk’)
- Type:
str
- shutdownStorage
Whether to shutdown storage after experiments
- Type:
bool
- removeCluster
Whether to remove cluster after experiments
- Type:
bool
- wsk_exec
Path to WSK CLI executable
- Type:
str
- wsk_bypass_security
Whether to bypass security checks in WSK CLI
- Type:
bool
- experimentalManifest
Whether to use experimental manifest features
- Type:
bool
- cache
Cache instance for configuration persistence
- Type:
sebs.cache.Cache
- dockerhub_repository
Repository at DockerHub to use for pushing images.
- Type:
str
- _credentials
OpenWhisk credentials configuration
- _resources
OpenWhisk resources configuration
- cache: Cache
- property credentials: OpenWhiskCredentials
Get OpenWhisk credentials configuration.
- Returns:
OpenWhiskCredentials instance
- static deserialize(config: Dict[str, Any], cache: Cache, handlers: LoggingHandlers) Config[source]
Deserialize OpenWhisk configuration from dictionary and cache.
- Parameters:
config – Configuration dictionary containing OpenWhisk settings
cache – Cache instance to retrieve cached configuration
handlers – Logging handlers for configuration operations
- Returns:
OpenWhiskConfig instance with deserialized configuration
- dockerhub_repository: str
- experimentalManifest: bool
- static initialize(cfg: Config, dct: Dict[str, Any]) None[source]
Initialize configuration from dictionary.
- Parameters:
cfg – Configuration instance to initialize
dct – Dictionary containing initialization data
- name: str
- removeCluster: bool
- property resources: OpenWhiskResources
Get OpenWhisk resources configuration.
- Returns:
OpenWhiskResources instance
- serialize() Dict[str, Any][source]
Serialize configuration to dictionary format.
- Returns:
Dictionary containing all OpenWhisk configuration settings including credentials and resources
- shutdownStorage: bool
- update_cache(cache: Cache) None[source]
Update cache with current configuration values.
- Parameters:
cache – Cache instance to update with current configuration
- wsk_bypass_security: bool
- wsk_exec: str
- class sebs.openwhisk.config.OpenWhiskCredentials[source]
Bases:
CredentialsManages authentication credentials for OpenWhisk deployments.
Since we do not use extra credentials there, it just implements the expected interface.
Note
OpenWhisk deployments typically rely on local authentication through the wsk CLI tool rather than explicit credential management.
- static deserialize(config: Dict[str, Any], cache: Cache, handlers: LoggingHandlers) Credentials[source]
Deserialize OpenWhisk credentials from configuration.
- Parameters:
config – Configuration dictionary containing credential data
cache – Cache instance for storing/retrieving cached credentials
handlers – Logging handlers for credential operations
- Returns:
OpenWhiskCredentials instance (currently empty)
- serialize() Dict[str, Any][source]
Serialize credentials to dictionary format.
- Returns:
Empty dictionary as OpenWhisk uses CLI-based authentication
- class sebs.openwhisk.config.OpenWhiskResources(registry: str | None = None, username: str | None = None, password: str | None = None, registry_updated: bool = False)[source]
Bases:
SelfHostedResourcesManages Docker registry and storage resources for OpenWhisk deployments.
This class handles configuration of Docker registry.
- _docker_registry
Docker registry URL for storing function images
- _docker_username
Username for Docker registry authentication
- _docker_password
Password for Docker registry authentication
- _registry_updated
Flag indicating if registry configuration has been updated
- _storage_updated
Flag indicating if storage configuration has been updated
- static deserialize(config: Dict[str, Any], cache: Cache, handlers: LoggingHandlers) Resources[source]
Deserialize OpenWhisk resources from configuration.
This method handles both user-provided configuration and cached values, prioritizing user configuration while detecting updates.
- Parameters:
config – Configuration dictionary that may contain ‘docker_registry’ section
cache – Cache instance to retrieve/store configuration
handlers – Logging handlers for resource operations
- Returns:
OpenWhiskResources instance with appropriate configuration
- property docker_password: str | None
Get the Docker registry password.
- Returns:
Docker registry password or None if not configured
- property docker_registry: str | None
Get the Docker registry URL.
- Returns:
Docker registry URL or None if not configured
- property docker_username: str | None
Get the Docker registry username.
- Returns:
Docker registry username or None if not configured
- static initialize(res: Resources, dct: Dict[str, Any]) None[source]
Initialize OpenWhisk resources from dictionary configuration.
- Parameters:
res – Resources instance to initialize
dct – Dictionary containing Docker registry configuration Expected keys: ‘registry’, ‘username’, ‘password’
- property registry_updated: bool
Check if registry configuration has been updated.
- Returns:
True if registry configuration has been updated, False otherwise
- serialize() Dict[str, Any][source]
Serialize resource configuration to dictionary.
- Returns:
Dictionary containing all resource configuration including Docker registry settings and inherited storage configuration
- property storage_updated: bool
Check if storage configuration has been updated.
- Returns:
True if storage configuration has been updated, False otherwise
- static typename() str[source]
Get the type name for this resource class.
- Returns:
String identifier for OpenWhisk resources
- update_cache(cache: Cache) None[source]
Update cache with current resource configuration.
- Parameters:
cache – Cache instance to update with current configuration
sebs.openwhisk.container module
Docker container management for OpenWhisk functions in SeBS.
Its primary focus is supporting both DockerHub and custom, local Docker registries. The latter make development and prototyping much faster and easier. They also allow users to push new images.
- Classes:
OpenWhiskContainer: OpenWhisk-specific Docker container management
- class sebs.openwhisk.container.OpenWhiskContainer(system_config: SeBSConfig, config: OpenWhiskConfig, docker_client: DockerClient, experimental_manifest: bool)[source]
Bases:
DockerContainerOpenWhisk-specific Docker container management.
- config
OpenWhisk configuration containing registry settings
Example
>>> container = OpenWhiskContainer( ... sys_config, ow_config, docker_client, True ... ) >>> registry, repo, tag, uri = container.registry_name( ... "benchmark", "python", "3.8", "x86_64" ... )
- static name() str[source]
Get the platform name identifier.
- Returns:
Platform name as string
- registry_name(benchmark: str, language_name: str, language_version: str, architecture: str) Tuple[str, str, str, str][source]
Generate Docker registry information for a benchmark image.
This method creates the appropriate registry name, repository name, image tag, and complete image URI based on the benchmark parameters and OpenWhisk configuration. It handles both custom registries and Docker Hub.
- 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., ‘x86_64’)
- Returns:
Registry name (e.g., “my-registry.com” or “Docker Hub”)
Full repository name with registry prefix
Image tag
Complete image URI
- Return type:
Tuple containing
- static typename() str[source]
Get the container type name.
- Returns:
Container type name as string
sebs.openwhisk.function module
OpenWhisk function and configuration classes for SeBS.
- Classes:
OpenWhiskFunctionConfig: Configuration data class for OpenWhisk functions OpenWhiskFunction: OpenWhisk-specific function implementation
- class sebs.openwhisk.function.OpenWhiskFunction(name: str, benchmark: str, code_package_hash: str, cfg: OpenWhiskFunctionConfig)[source]
Bases:
FunctionOpenWhisk-specific function implementation for SeBS.
It does not implemnet anything non-standard, just implements trigger and config types specific to OpenWhisk.
- _cfg
OpenWhisk-specific function configuration
Example
>>> config = OpenWhiskFunctionConfig.from_benchmark(benchmark) >>> function = OpenWhiskFunction("test-func", "benchmark-name", "hash123", config)
- property config: OpenWhiskFunctionConfig
Get OpenWhisk-specific function configuration.
- Returns:
OpenWhiskFunctionConfig instance with current settings
- static deserialize(cached_config: Dict[str, Any]) OpenWhiskFunction[source]
Deserialize function from cached configuration data.
- Parameters:
cached_config – Dictionary containing cached function configuration and trigger information
- Returns:
OpenWhiskFunction instance with deserialized configuration and triggers
- Raises:
AssertionError – If unknown trigger type is encountered
- serialize() Dict[str, Any][source]
Serialize function to dictionary format.
- Returns:
Dictionary containing function data and OpenWhisk-specific configuration
- static typename() str[source]
Get the type name for this function class.
- Returns:
String identifier for OpenWhisk functions
- class sebs.openwhisk.function.OpenWhiskFunctionConfig(timeout: int, memory: int, runtime: Runtime, architecture: Architecture = Architecture.X86, docker_image: str = '', namespace: str = '_', object_storage: MinioConfig | None = None, nosql_storage: ScyllaDBConfig | None = None)[source]
Bases:
FunctionConfigConfiguration data class for OpenWhisk functions.
This class extends the base FunctionConfig to include OpenWhisk-specific configuration parameters such as Docker image information, namespace settings, and storage configurations for both object and NoSQL storage.
- docker_image
Docker image URI used for the function deployment
- Type:
str
- namespace
OpenWhisk namespace (default: “_” for default namespace)
- Type:
str
- object_storage
Minio object storage configuration if required
- Type:
sebs.storage.config.MinioConfig | None
- nosql_storage
ScyllaDB NoSQL storage configuration if required
- Type:
sebs.storage.config.ScyllaDBConfig | None
Note
The docker_image attribute should be merged with higher-level image abstraction in future refactoring. This is quite similar to AWS deployments.
- static deserialize(data: Dict[str, Any]) OpenWhiskFunctionConfig[source]
Deserialize configuration from dictionary data.
- Parameters:
data – Dictionary containing serialized configuration data
- Returns:
OpenWhiskFunctionConfig instance with deserialized data
- docker_image: str = ''
- static from_benchmark(benchmark: Benchmark) OpenWhiskFunctionConfig[source]
Create configuration from benchmark specification.
- Parameters:
benchmark – Benchmark instance containing configuration requirements
- Returns:
OpenWhiskFunctionConfig instance initialized from benchmark
- namespace: str = '_'
- nosql_storage: ScyllaDBConfig | None = None
- object_storage: MinioConfig | None = None
- serialize() Dict[str, Any][source]
Serialize configuration to dictionary format.
- Returns:
Dictionary containing all configuration data
sebs.openwhisk.openwhisk module
Apache OpenWhisk serverless platform implementation for SeBS.
This module provides the main OpenWhisk system class that integrates OpenWhisk serverless platform with the SeBS benchmarking framework. It handles function deployment, execution, monitoring, and resource management for OpenWhisk clusters.
- class sebs.openwhisk.openwhisk.OpenWhisk(system_config: SeBSConfig, config: OpenWhiskConfig, cache_client: Cache, docker_client: DockerClient, logger_handlers: LoggingHandlers)[source]
Bases:
SystemApache OpenWhisk serverless platform implementation for SeBS.
This class provides the main integration between SeBS and Apache OpenWhisk, handling function deployment, execution, container management, and resource management (primarily self-hosted storage like Minio/ScyllaDB via SelfHostedSystemResources), and interaction with the wsk CLI. It supports OpenWhisk deployments with Docker-based function packaging. We do not use code packages due to low package size limits.
- _config
OpenWhisk-specific configuration settings
- Type:
sebs.openwhisk.config.OpenWhiskConfig
- container_client
Docker container client for function packaging
- logging_handlers
Logging handlers for the OpenWhisk system
Example
>>> openwhisk = OpenWhisk(sys_config, ow_config, cache, docker_client, handlers) >>> function = openwhisk.create_function(benchmark, "test-func", True, "image:tag")
- cached_function(function: Function) None[source]
Configure a cached function with current system settings.
Updates triggers with current logging handlers and WSK command configuration.
- Parameters:
function – Cached function to configure
- property config: OpenWhiskConfig
Get OpenWhisk configuration.
- Returns:
OpenWhisk configuration instance
- property container_client: OpenWhiskContainer
Get OpenWhisk container client.
- Returns:
OpenWhisk container client
- create_function(code_package: Benchmark, func_name: str, system_variant: SystemVariant, container_uri: str | None) OpenWhiskFunction[source]
Create or retrieve an OpenWhisk function (action).
This method checks if a function already exists and updates it if necessary, or creates a new function with the appropriate configuration, storage settings, and Docker image.
- Parameters:
code_package – Benchmark configuration and code package
func_name – Name for the OpenWhisk action
system_variant – Selected deployment variant
container_uri – URI of the Docker image for the function
- Returns:
OpenWhiskFunction instance configured with LibraryTrigger
- Raises:
RuntimeError – If WSK CLI is not accessible or function creation fails
- create_trigger(function: Function, trigger_type: TriggerType) Trigger[source]
Create a trigger for function invocation.
- Parameters:
function – Function to create trigger for
trigger_type – Type of trigger to create (LIBRARY or HTTP)
- Returns:
Created trigger instance
- Raises:
RuntimeError – If WSK CLI is not accessible or trigger type not supported
- default_function_name(code_package: Benchmark, resources: Resources | None = None) str[source]
Generate default function name based on benchmark and resource configuration.
- Parameters:
code_package – Benchmark package containing name and language info
resources – Optional specific resources to use for naming
- Returns:
Generated function name string
- disable_rich_output() None[source]
Disable rich output formatting for container operations.
This is useful for non-interactive 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)[source]
Download metrics for function executions (no-op for OpenWhisk).
- Parameters:
function_name – Name of the function to download metrics for
start_time – Start time for metrics collection (epoch timestamp)
end_time – End time for metrics collection (epoch timestamp)
requests – Dictionary mapping request IDs to execution results
metrics – Dictionary to store downloaded metrics
Note
OpenWhisk metrics collection is not currently implemented.
- enforce_cold_start(functions: List[Function], code_package: Benchmark) None[source]
Enforce cold start for functions (not implemented for OpenWhisk).
- Parameters:
functions – List of functions to enforce cold start for
code_package – Benchmark package configuration
- Raises:
NotImplementedError – Cold start enforcement not implemented for OpenWhisk
- finalize_container_build() Callable[[str, Language, str, str, str, bool], Tuple[str, float]] | None[source]
Regardless of Docker image status, we need to create .zip file to allow registration of function with OpenWhisk. By returning the code package routine, we ensure that a package will be created.
- Returns:
Code packaging function.
- static function_type() Type[Function][source]
Get the function type for this platform.
- Returns:
OpenWhiskFunction class type
- get_wsk_cmd() List[str][source]
Get the WSK CLI command with appropriate flags.
- Returns:
List of command arguments for WSK CLI execution
- initialize(config: Dict[str, str] = {}, resource_prefix: str | None = None, quiet: bool = False) None[source]
Initialize OpenWhisk system resources.
- Parameters:
config – Additional configuration parameters (currently unused)
resource_prefix – Optional prefix for resource naming
- is_configuration_changed(cached_function: Function, benchmark: Benchmark) bool[source]
Check if function configuration has changed compared to cached version.
Compares current benchmark configuration and storage settings with the cached function configuration to determine if an update is needed.
- Parameters:
cached_function – Previously cached function configuration
benchmark – Current benchmark configuration to compare against
- Returns:
True if configuration has changed and function needs updating
- static name() str[source]
Get the platform name identifier.
- Returns:
Platform name as string
- package_code(directory: str, language: Language, language_version: str, architecture: str, benchmark: str, is_cached: bool) Tuple[str, float][source]
Package benchmark code for OpenWhisk deployment.
Creates a ZIP archive containing the benchmark code. The ZIP archive is required for OpenWhisk function registration even when using Docker-based deployment. It contains only the main handlers (__main__.py or index.js).
For Java, extracts the JAR from the built container image - this a fix since we need to provide it as argument to OpenWhisk action, but we do not want to add extra builder image.
- Parameters:
directory – Path to the benchmark code directory
language – Programming language (e.g., ‘python’, ‘nodejs’, ‘java’)
language_version – Language version (e.g., ‘3.8’, ‘14’, ‘17’)
architecture – Target architecture (e.g., ‘x86_64’)
benchmark – Benchmark name
is_cached – Whether Docker image is already cached
- Returns:
Path to created ZIP archive (or JAR for Java)
Size of archive in bytes
- Return type:
Tuple containing
- shutdown() None[source]
Shutdown OpenWhisk system and clean up resources.
This method stops storage services if configured and optionally removes the OpenWhisk cluster based on configuration settings.
- storage_arguments(code_package: Benchmark) List[str][source]
Generate storage-related arguments for function deployment.
Creates WSK CLI parameters for Minio object storage and ScyllaDB NoSQL storage configurations based on the benchmark requirements.
- Parameters:
code_package – Benchmark configuration requiring storage access
- Returns:
List of WSK CLI parameter arguments for storage configuration
- static typename() str[source]
Get the platform type name.
- Returns:
Platform type name as string
- update_function(function: Function, code_package: Benchmark, system_variant: SystemVariant, container_uri: str | None) None[source]
Update an existing OpenWhisk function with new code and configuration.
- Parameters:
function – Existing function to update
code_package – New benchmark configuration and code package
system_variant – Selected deployment variant
container_uri – URI of the new Docker image
- Raises:
RuntimeError – If WSK CLI is not accessible or update fails
- update_function_configuration(function: Function, code_package: Benchmark) None[source]
Update configuration of an existing OpenWhisk function.
Updates memory allocation, timeout, and storage parameters without changing the function code or Docker image.
- Parameters:
function – Function to update configuration for
code_package – New benchmark configuration settings
- Raises:
RuntimeError – If WSK CLI is not accessible or configuration update fails
sebs.openwhisk.triggers module
Trigger implementations for OpenWhisk function invocation in SeBS.
This module provides different trigger types for invoking OpenWhisk functions, including library-based (CLI) triggers and HTTP-based triggers.
- Classes:
LibraryTrigger: CLI-based function invocation using wsk tool HTTPTrigger: HTTP-based function invocation using web actions
- class sebs.openwhisk.triggers.HTTPTrigger(fname: str, url: str)[source]
Bases:
TriggerHTTP-based trigger for OpenWhisk web action invocation.
This trigger uses HTTP requests to invoke OpenWhisk web actions, providing an alternative to CLI-based invocation. It inherits HTTP invocation capabilities from the base Trigger class.
- fname
Name of the OpenWhisk action
- url
HTTP URL for the web action endpoint
Example
>>> trigger = HTTPTrigger( ... "my-function", ... "https://openwhisk.example.com/api/v1/web/guest/default/my-function.json" ... ) >>> result = trigger.sync_invoke({"key": "value"})
- async_invoke(payload: Dict[str, Any]) Future[source]
Asynchronously invoke the OpenWhisk function via HTTP.
- Parameters:
payload – Dictionary of parameters to pass to the function
- Returns:
Future object that will contain the ExecutionResult
- static deserialize(obj: Dict[str, str]) Trigger[source]
Deserialize trigger from configuration dictionary.
- Parameters:
obj – Dictionary containing serialized trigger data
- Returns:
HTTPTrigger instance
- serialize() Dict[str, str][source]
Serialize trigger configuration to dictionary.
- Returns:
Dictionary containing trigger type, function name, and URL
- sync_invoke(payload: Dict[str, Any]) ExecutionResult[source]
Synchronously invoke the OpenWhisk function via HTTP.
- Parameters:
payload – Dictionary of parameters to pass to the function
- Returns:
ExecutionResult containing timing information and function output
- static trigger_type() TriggerType[source]
Get the trigger type identifier.
- Returns:
TriggerType.HTTP for HTTP-based invocation
- static typename() str[source]
Get the trigger type name.
- Returns:
String identifier for this trigger type
- class sebs.openwhisk.triggers.LibraryTrigger(fname: str, wsk_cmd: List[str] | None = None)[source]
Bases:
TriggerCLI-based trigger for OpenWhisk function invocation.
This trigger uses the wsk CLI tool to invoke OpenWhisk actions directly, providing synchronous and asynchronous invocation capabilities. It handles parameter passing and result parsing for CLI-based invocations.
- fname
Name of the OpenWhisk action to invoke
- _wsk_cmd
Complete WSK CLI command for function invocation
Example
>>> trigger = LibraryTrigger("my-function", ["wsk", "-i"]) >>> result = trigger.sync_invoke({"key": "value"})
- async_invoke(payload: Dict[str, Any]) Future[source]
Asynchronously invoke the OpenWhisk function via CLI.
- Parameters:
payload – Dictionary of parameters to pass to the function
- Returns:
Future object that will contain the ExecutionResult
- static deserialize(obj: Dict[str, str]) Trigger[source]
Deserialize trigger from configuration dictionary.
- Parameters:
obj – Dictionary containing serialized trigger data
- Returns:
LibraryTrigger instance
- static get_command(payload: Dict[str, Any]) List[str][source]
Convert payload dictionary to WSK CLI parameter arguments.
- Parameters:
payload – Dictionary of parameters to pass to the function
- Returns:
List of CLI arguments for passing parameters to WSK
Example
>>> get_command({"key1": "value1", "key2": 42}) ["--param", "key1", '"value1"', "--param", "key2", "42"]
- serialize() Dict[str, str][source]
Serialize trigger configuration to dictionary.
- Returns:
Dictionary containing trigger type and function name
- sync_invoke(payload: Dict[str, Any]) ExecutionResult[source]
Synchronously invoke the OpenWhisk function via CLI.
- Parameters:
payload – Dictionary of parameters to pass to the function
- Returns:
ExecutionResult containing timing information and function output
- static trigger_type() TriggerType[source]
Get the trigger type identifier.
- Returns:
TriggerType.LIBRARY for CLI-based invocation
- static typename() str[source]
Get the trigger type name.
- Returns:
String identifier for this trigger type
- property wsk_cmd: List[str]
Get the complete WSK CLI command for invocation.
- Returns:
List of command arguments for WSK CLI invocation
- Raises:
AssertionError – If wsk_cmd has not been set
Module contents
Apache OpenWhisk integration module for SeBS.
This module provides the complete OpenWhisk integration: - OpenWhisk system and function management - Configuration classes for credentials and resources - Function and trigger implementations - Docker container management - CLI and HTTP-based invocation methods
- Main Classes:
OpenWhisk: Main OpenWhisk system implementation OpenWhiskConfig: Configuration management for OpenWhisk deployments OpenWhiskFunction: OpenWhisk-specific function implementation LibraryTrigger: CLI-based function invocation HTTPTrigger: HTTP-based function invocation
Example
>>> from sebs.openwhisk import OpenWhisk, OpenWhiskConfig
>>> config = OpenWhiskConfig.deserialize(config_dict, cache, handlers)
>>> system = OpenWhisk(sys_config, config, cache, docker_client, handlers)