stanza.context
Stanza session management for Stanza CLI.
This module manages the top-level Stanza session (the timestamped directory). This is distinct from LoggerSession which handles per-routine data logging.
Architecture: StanzaSession (this module):
- Creates timestamped directories like: 20251020100010_untitled/
- Manages session-level metadata and active session tracking
- Scope: Global/session-wide, persists across routine runs
LoggerSession (stanza/logger/session.py):
- Handles per-routine data collection and buffered writing
- Scope: Per-routine execution, created/destroyed per run
Module Contents
Classes
API
Manages the active Stanza session directory.
This class handles the top-level timestamped session directory (e.g., 20251020100010_untitled/) and tracks which session is currently active.
Value: .stanza
Value: config.json
Create a new timestamped Stanza session directory.
Parameters:
Base directory for session (default: current directory)
Optional suffix for directory name (default: “untitled”)
Returns:
Path to created session directory Example:
StanzaSession.create_session_directory() PosixPath(‘20251020100010_untitled’) StanzaSession.create_session_directory(name=“experiment”) PosixPath(‘20251020100010_experiment’)
Get the active Stanza session directory from working directory config.
Returns:
Path to active session directory, or None if not set Example:
StanzaSession.get_active_session() PosixPath(‘20251020100010_untitled’)
Set the active Stanza session directory.
Parameters:
Path to session directory
Get metadata for a Stanza session directory.
Parameters:
Path to session directory
Returns:
Metadata dictionary or None if not found

