Source code for eclypse.builders.application.deathstarbench.media_service.application
"""Factory for a media service microservice application."""
from __future__ import annotations
from typing import (
TYPE_CHECKING,
Literal,
)
from eclypse.builders.application._helpers import build_application_from_specs
if TYPE_CHECKING:
from eclypse.graph import Application
from eclypse.graph.assets import Asset
from eclypse.utils.types import (
CommunicationInterface,
InitPolicy,
UpdatePolicies,
)
[docs]
def get_media_service(
application_id: str = "MediaService",
communication_interface: CommunicationInterface | None = None,
update_policies: UpdatePolicies = None,
node_assets: dict[str, Asset] | None = None,
edge_assets: dict[str, Asset] | None = None,
include_default_assets: bool = False,
requirement_init: InitPolicy = "min",
flows: Literal["default"] | list[list[str]] = "default",
store_step: bool = False,
seed: int | None = None,
) -> Application:
"""Get the media service application.
Args:
application_id (str): Identifier assigned to the generated application.
communication_interface (CommunicationInterface | None):
Communication backend used to instantiate executable services. When
``None``, the builder returns a graph-only application.
update_policies (Callable | list[Callable] | None):
Graph update policies executed during ``evolve()``.
node_assets (dict[str, Asset] | None):
Optional assets attached to application nodes.
edge_assets (dict[str, Asset] | None):
Optional assets attached to application edges.
include_default_assets (bool):
Whether default graph assets should be included in the application.
requirement_init (InitPolicy):
Initialisation strategy applied to node and edge requirements.
flows (Literal["default"] | list[list[str]]):
User-defined application flows. Use ``"default"`` to install the
benchmark's built-in review-composition and movie-information
flows.
store_step (bool):
Whether instantiated services should store their step outputs in
the internal step queue. Ignored when
``communication_interface`` is ``None``.
seed (int | None):
Seed forwarded to the application random generator.
Returns:
Application: The configured media service application.
Raises:
ValueError: If ``communication_interface`` is not supported.
"""
default_flows = [
[
"ComposeReviewService",
"UniqueIdService",
"MovieIdService",
"TextService",
"RatingService",
"UserService",
"ReviewStorageService",
"UserReviewService",
"MovieReviewService",
"ComposeReviewService",
],
["MovieInfoService", "CastInfoService", "MovieInfoService"],
["MovieInfoService", "PlotService", "MovieInfoService"],
["MovieInfoService", "MovieReviewService", "MovieInfoService"],
]
service_names = [
"ComposeReviewService",
"UniqueIdService",
"MovieIdService",
"TextService",
"RatingService",
"UserService",
"ReviewStorageService",
"UserReviewService",
"MovieReviewService",
"MovieInfoService",
"CastInfoService",
"PlotService",
]
node_requirements = {
"ComposeReviewService": {
"cpu": 2,
"gpu": 0,
"ram": 1.75,
"storage": 0.5,
"availability": 0.94,
"processing_time": 16,
},
"UniqueIdService": {
"cpu": 1,
"gpu": 0,
"ram": 0.25,
"storage": 0.25,
"availability": 0.98,
"processing_time": 4,
},
"MovieIdService": {
"cpu": 1,
"gpu": 0,
"ram": 1.0,
"storage": 0.75,
"availability": 0.94,
"processing_time": 8,
},
"TextService": {
"cpu": 1,
"gpu": 0,
"ram": 0.75,
"storage": 0.25,
"availability": 0.96,
"processing_time": 6,
},
"RatingService": {
"cpu": 1,
"gpu": 0,
"ram": 0.25,
"storage": 0.25,
"availability": 0.98,
"processing_time": 4,
},
"UserService": {
"cpu": 1,
"gpu": 0,
"ram": 1.25,
"storage": 1.0,
"availability": 0.94,
"processing_time": 9,
},
"ReviewStorageService": {
"cpu": 3,
"gpu": 0,
"ram": 2.5,
"storage": 3.0,
"availability": 0.91,
"processing_time": 13,
},
"UserReviewService": {
"cpu": 2,
"gpu": 0,
"ram": 1.5,
"storage": 1.5,
"availability": 0.93,
"processing_time": 10,
},
"MovieReviewService": {
"cpu": 2,
"gpu": 0,
"ram": 1.75,
"storage": 1.75,
"availability": 0.92,
"processing_time": 11,
},
"MovieInfoService": {
"cpu": 2,
"gpu": 0,
"ram": 1.75,
"storage": 1.5,
"availability": 0.93,
"processing_time": 13,
},
"CastInfoService": {
"cpu": 1,
"gpu": 0,
"ram": 1.0,
"storage": 1.0,
"availability": 0.94,
"processing_time": 8,
},
"PlotService": {
"cpu": 1,
"gpu": 0,
"ram": 1.0,
"storage": 1.0,
"availability": 0.94,
"processing_time": 8,
},
}
edge_requirements = [
(
"ComposeReviewService",
"UniqueIdService",
{"symmetric": True, "latency": 12, "bandwidth": 8},
),
(
"UniqueIdService",
"MovieIdService",
{"symmetric": True, "latency": 10, "bandwidth": 8},
),
(
"MovieIdService",
"TextService",
{"symmetric": True, "latency": 10, "bandwidth": 8},
),
(
"TextService",
"RatingService",
{"symmetric": True, "latency": 10, "bandwidth": 6},
),
(
"RatingService",
"UserService",
{"symmetric": True, "latency": 10, "bandwidth": 8},
),
(
"UserService",
"ReviewStorageService",
{"symmetric": True, "latency": 14, "bandwidth": 14},
),
(
"ReviewStorageService",
"UserReviewService",
{"symmetric": True, "latency": 14, "bandwidth": 14},
),
(
"UserReviewService",
"MovieReviewService",
{"symmetric": True, "latency": 14, "bandwidth": 12},
),
(
"MovieReviewService",
"ComposeReviewService",
{"symmetric": True, "latency": 12, "bandwidth": 10},
),
(
"MovieInfoService",
"CastInfoService",
{"symmetric": True, "latency": 12, "bandwidth": 8},
),
(
"MovieInfoService",
"PlotService",
{"symmetric": True, "latency": 12, "bandwidth": 8},
),
(
"MovieInfoService",
"MovieReviewService",
{"symmetric": True, "latency": 14, "bandwidth": 12},
),
]
return build_application_from_specs(
application_id=application_id,
communication_interface=communication_interface,
update_policies=update_policies,
node_assets=node_assets,
edge_assets=edge_assets,
include_default_assets=include_default_assets,
requirement_init=requirement_init,
flows=flows,
store_step=store_step,
default_flows=default_flows,
service_names=service_names,
node_requirements=node_requirements,
edge_requirements=edge_requirements,
seed=seed,
package_name=__package__,
)