Skip to content

README

liblaf.cherries.profiles

Type Aliases:

Classes:

  • Profile –

    Base class for named run profiles.

  • ProfileDebug –

    Profile for local/debug runs with remote and commit side effects disabled.

  • ProfileDefault –

    Profile for local CAS recording, logs, and opt-in Comet observability.

Functions:

  • factory –

    Resolve a profile name, instance, class, or environment default.

ProfileLike

ProfileLike = ProfileName | Profile | type[Profile]

Profile selector accepted by factory.

ProfileName

ProfileName = Literal['default', 'debug'] | str

Registered profile name.

Profile

Bases: ABC, Registry


              flowchart TD
              liblaf.cherries.profiles.Profile[Profile]

              

              click liblaf.cherries.profiles.Profile href "" "liblaf.cherries.profiles.Profile"
            

Base class for named run profiles.

Methods:

  • init –

    Configure and return the process-global run.

init abstractmethod

init() -> Run

Configure and return the process-global run.

Source code in src/liblaf/cherries/profiles/_abc.py
@abc.abstractmethod
def init(self) -> core.Run:
    """Configure and return the process-global run."""
    raise NotImplementedError

ProfileDebug

Bases: Profile


              flowchart TD
              liblaf.cherries.profiles.ProfileDebug[ProfileDebug]
              liblaf.cherries.profiles._abc.Profile[Profile]

                              liblaf.cherries.profiles._abc.Profile --> liblaf.cherries.profiles.ProfileDebug
                


              click liblaf.cherries.profiles.ProfileDebug href "" "liblaf.cherries.profiles.ProfileDebug"
              click liblaf.cherries.profiles._abc.Profile href "" "liblaf.cherries.profiles._abc.Profile"
            

Profile for local/debug runs with remote and commit side effects disabled.

Methods:

  • init –

    Register local logging on the process-global run.

init

init() -> Run

Register local logging on the process-global run.

Source code in src/liblaf/cherries/profiles/_debug.py
@override
def init(self) -> core.Run:
    """Register local logging on the process-global run."""
    run: core.Run = core.run
    run.plugins.register(plugins.Logging(run=run))
    return run

ProfileDefault

Bases: Profile


              flowchart TD
              liblaf.cherries.profiles.ProfileDefault[ProfileDefault]
              liblaf.cherries.profiles._abc.Profile[Profile]

                              liblaf.cherries.profiles._abc.Profile --> liblaf.cherries.profiles.ProfileDefault
                


              click liblaf.cherries.profiles.ProfileDefault href "" "liblaf.cherries.profiles.ProfileDefault"
              click liblaf.cherries.profiles._abc.Profile href "" "liblaf.cherries.profiles._abc.Profile"
            

Profile for local CAS recording, logs, and opt-in Comet observability.

Methods:

  • init –

    Register the production plugin set on the process-global run.

init

init() -> Run

Register the production plugin set on the process-global run.

Source code in src/liblaf/cherries/profiles/_default.py
@override
def init(self) -> core.Run:
    """Register the production plugin set on the process-global run."""
    run: core.Run = core.run
    if os.environ.get("CHERRIES_COMET", "0") == "1":
        run.plugins.register(plugins.Comet(run=run))
    run.plugins.register(plugins.Logging(run=run))
    return run

factory

factory(profile: ProfileLike | None = None) -> Profile

Resolve a profile name, instance, class, or environment default.

Parameters:

  • profile (ProfileLike | None, default: None ) –

    Explicit profile selector. When omitted, DEBUG=1 selects the debug profile; otherwise PROFILE defaults to default.

Returns:

  • Profile –

    Instantiated profile object.

Source code in src/liblaf/cherries/profiles/_factory.py
def factory(profile: ProfileLike | None = None) -> Profile:
    """Resolve a profile name, instance, class, or environment default.

    Args:
        profile: Explicit profile selector. When omitted, `DEBUG=1` selects the
            debug profile; otherwise `PROFILE` defaults to `default`.

    Returns:
        Instantiated profile object.
    """
    if profile is None:
        try:
            debug: bool = env.bool("DEBUG", False)
        except environs.EnvValidationError:
            pass
        else:
            if debug:
                profile: str = "debug"
    if profile is None:
        profile: str = env.str("PROFILE", "default")
    if isinstance(profile, str):
        return Profile[profile]()
    if isinstance(profile, Profile):
        return profile
    return profile()