Skip to content

Framework API Reference

This page provides detailed API documentation for the Framework module in SPOC.

Framework Class

spoc.framework.Framework(base_dir, schema, echo=False, mode='strict')

Core framework class for SPOC applications.

Manages the lifecycle of an application including module loading, dependency resolution, and plugin registration. Provides a structured way to bootstrap and tear down applications.

Parameters:

  • base_dir (Path) –

    Base directory for the application.

  • schema (Schema) –

    Schema describing modules and dependencies.

  • echo (bool, default: False ) –

    Whether to echo debug information during operations.

  • mode (FrameworkMode, default: 'strict' ) –

    Whether to enforce modules (files.py) in all apps at startup.

get_component(kind, name)

Get a framework component by .

startup()

Bootstrap the application.

Registers all configured applications, initializes modules in dependency order, and loads all plugins.

Returns:

  • Framework

    Self instance for method chaining

shutdown()

Tear down the application.

Shuts down all modules in the reverse order of initialization, calling shutdown hooks as needed.

Returns:

  • Framework

    Self instance for method chaining

Schema Class

spoc.framework.Schema(modules, dependencies=dict(), hooks=dict()) dataclass

Schema definition for application modules and their dependencies.

Defines a structure for modules to be loaded, their dependencies, and associated lifecycle hooks.

Hook Type

spoc.framework.Hook

Type definition for lifecycle hooks.

A dictionary containing optional startup and shutdown callables that are executed during framework initialization and termination.

Config Class

spoc.framework.Config(project, settings, environment) dataclass

Configuration container for the framework.

Holds project configuration, settings, and environment variables loaded from configuration files.

Attributes:

  • `project`

    Project configuration

  • `settings`

    Settings configuration

  • `environment`

    Environment variables

Helper Functions

spoc.framework.build_config(base_dir)

Build a configuration object from files in the specified directory.

Parameters:

  • base_dir (Path) –

    Base directory containing configuration files

Returns:

  • Config

    Config object populated with project, settings and environment data