saturnin.component.recipe

Saturnin recipe definitions and management.

This module defines the structure and types associated with Saturnin recipes. Recipes are configuration files that describe how to run services or bundles, including their type, execution mode, executor, and associated application. It provides enums for recipe types and execution modes, a configuration class (SaturninRecipe) for parsing recipe files, a dataclass (RecipeInfo) for representing loaded recipes, and a RecipeRegistry to manage them.

Enums

class saturnin.component.recipe.RecipeType(value)[source]

Bases: Enum

Recipe type.

BUNDLE = 'bundle'
SERVICE = 'service'
class saturnin.component.recipe.RecipeExecutionMode(value)[source]

Bases: Enum

Recipe execution mode.

DAEMON = 'daemon'
NORMAL = 'normal'

Globals

saturnin.component.recipe.recipe_registry: RecipeRegistry

Global RecipeRegistryinstance, automatically populated from the directory_scheme.recipes directory upon module import if it exists.

Classes

class saturnin.component.recipe.SaturninRecipe[source]

Bases: Config

Saturnin recipe descriptor - configuration section.

application: DataclassOption

Application specification (if any) associated with this recipe.

description: StrOption

Description

execution_mode: EnumOption

Recipe execution mode - RecipeExecutionMode enum.

executor: PathOption

Recipe executor (container). If not provided, the default executor according to recipe type is used.

recipe_type: EnumOption

Recipe type - RecipeType enum.

class saturnin.component.recipe.RecipeInfo(name: str, recipe_type: RecipeType, execution_mode: RecipeExecutionMode, executor: Path, application: ComponentSpecification, description: str, filename: Path)[source]

Bases: Distinct

Dataclass recipe information record stored in recipe registry.

Parameters:
  • name (str) – Recipe name

  • recipe_type (RecipeType) – Recipe type

  • execution_mode (RecipeExecutionMode) – Recipe execution mode

  • executor (Path) – Recipe executor

  • application (ComponentSpecification) – Application to be used

  • description (str) – Recipe description

  • filename (Path) – Path to recipe file

get_key() Hashable[source]

Returns the recipe name, which serves as its unique key in the registry.

Return type:

Hashable

application: ComponentSpecification

Application to be used

description: str

Recipe description

execution_mode: RecipeExecutionMode

Recipe execution mode

executor: Path

Recipe executor

filename: Path

Path to recipe file

name: str

Recipe name

recipe_type: RecipeType

Recipe type

class saturnin.component.recipe.RecipeRegistry(data: Mapping[Any, Distinct] | Sequence[Distinct] | Registry = None)[source]

Bases: Registry

Saturnin recipe registry.

Holds RecipeInfo instances.

Parameters:

data (Mapping[Any, Distinct] | Sequence[Distinct] | Registry)

app_is_used(app_uid: UUID) bool[source]

Returns True if application is used in any installed recipe.

Parameters:

app_uid (UUID)

Return type:

bool

get_recipes_with_app(app_uid: UUID) list[RecipeInfo][source]

Returns list of recipes that use specified application.

Parameters:

app_uid (UUID)

Return type:

list[RecipeInfo]

load_from(directory: Path, *, ignore_errors: bool = False) None[source]

Populate registry from descriptors of installed recipes.

Parameters:
  • directory (Path) – Directory with recipe files.

  • ignore_errors (bool) – When True, errors are ignored, otherwise Error is raised.

Return type:

None