Module

utils.profile

Build profile system for persona-based observability.

Provides three profiles optimized for different user workflows:

  • Writer: Fast, clean builds for content authors
  • Theme Developer: Template-focused debugging for theme builders
  • Developer: Full observability for framework contributors

Example:

from bengal.utils.profile import BuildProfile

profile = BuildProfile.from_cli_args(dev=True)
config = profile.get_config()

if config['track_memory']:
    # Enable memory tracking
    pass

Classes

BuildProfile
Build profiles for different user personas. Each profile optimizes observability features for a sp…
4

Build profiles for different user personas.

Each profile optimizes observability features for a specific workflow:

  • WRITER: Content authors who want fast, clean builds
  • THEME_DEV: Theme developers who need template debugging
  • DEVELOPER: Framework contributors who need full observability
Inherits from Enum

Methods 3

from_string classmethod
Parse profile from string.
1 BuildProfile
def from_string(cls, value: str) -> BuildProfile

Parse profile from string.

Parameters 1
value str

Profile name (case-insensitive)

Returns

BuildProfile

BuildProfile enum value

from_cli_args classmethod
Determine profile from CLI arguments with proper precedence. Precedence (highe…
4 BuildProfile
def from_cli_args(cls, profile: str | None = None, dev: bool = False, theme_dev: bool = False, debug: bool = False) -> BuildProfile

Determine profile from CLI arguments with proper precedence.

Precedence (highest to lowest):

  1. --dev flag (full developer mode)
  2. --theme-dev flag
  3. --profile option
  4. --debug flag (enables DEVELOPER profile)
  5. Default (WRITER)

NOTE: --verbose is NOT a profile selector. It only controls output verbosity. Use --theme-dev or --dev for profile-based health checks and metrics.

Parameters 4
profile str | None

Explicit profile name from --profile

dev bool

--dev flag (full developer mode)

theme_dev bool

--theme-dev flag

debug bool

--debug flag (debug logging, maps to DEVELOPER profile)

Returns

BuildProfile

Determined BuildProfile

get_config
Get configuration dictionary for this profile.
0 dict[str, Any]
def get_config(self) -> dict[str, Any]

Get configuration dictionary for this profile.

Returns

dict[str, Any]

Configuration with feature toggles for this profile

Configuration keys:

show_phase_timing: Show build phase timing
track_memory: Enable memory profiling (tracemalloc + psutil)
enable_debug_output: Print debug messages to stderr
collect_metrics: Save metrics to .bengal/metrics/
health_checks: Dict with enabled/disabled validator lists
verbose_build_stats: Show detailed build statistics

Internal Methods 1
__str__
String representation of profile.
0 str
def __str__(self) -> str

String representation of profile.

Returns

str

Functions

set_current_profile
Set the current build profile. This is used by helper functions to determine behavior without pass…
1 None
def set_current_profile(profile: BuildProfile) -> None

Set the current build profile.

This is used by helper functions to determine behavior without passing profile through every function call.

Parameters 1

Name Type Default Description
profile BuildProfile

BuildProfile to set as current

get_current_profile
Get the current build profile.
0 BuildProfile
def get_current_profile() -> BuildProfile

Get the current build profile.

Returns

BuildProfile

Current profile, or WRITER if not set

should_show_debug
Check if debug output should be shown. This is a helper for conditional debug output without passi…
0 bool
def should_show_debug() -> bool

Check if debug output should be shown.

This is a helper for conditional debug output without passing profile through every function.

Returns

bool

True if debug output should be shown

should_track_memory
Check if memory tracking should be enabled.
0 bool
def should_track_memory() -> bool

Check if memory tracking should be enabled.

Returns

bool

True if memory should be tracked

should_collect_metrics
Check if metrics collection should be enabled.
0 bool
def should_collect_metrics() -> bool

Check if metrics collection should be enabled.

Returns

bool

True if metrics should be collected

get_enabled_health_checks
Get list of enabled health check validators for current profile.
0 list[str]
def get_enabled_health_checks() -> list[str]

Get list of enabled health check validators for current profile.

Returns

list[str]

List of validator names that should run, or 'all' string

is_validator_enabled
Check if a specific validator should run.
1 bool
def is_validator_enabled(validator_name: str) -> bool

Check if a specific validator should run.

Parameters 1

Name Type Default Description
validator_name str

Name of validator (e.g., 'config', 'links')

Returns

bool

True if validator should run