Coverage for openhcs/config_framework/__init__.py: 100.0%
10 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-01 18:33 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-01 18:33 +0000
1"""
2Generic configuration framework for lazy dataclass resolution.
4This framework provides a complete system for hierarchical configuration management
5with lazy resolution, dual-axis inheritance, and UI integration.
7Key Features:
8- Lazy dataclass factory with dynamic field resolution
9- Dual-axis inheritance (context hierarchy + sibling inheritance)
10- Contextvars-based context management
11- Placeholder text generation for UI
12- Thread-local global configuration storage
14Quick Start:
15 >>> from openhcs.config_framework import (
16 ... set_base_config_type,
17 ... LazyDataclassFactory,
18 ... config_context,
19 ... )
20 >>> from myapp.config import GlobalConfig
21 >>>
22 >>> # Initialize framework
23 >>> set_base_config_type(GlobalConfig)
24 >>>
25 >>> # Create lazy dataclass
26 >>> LazyStepConfig = LazyDataclassFactory.make_lazy_simple(StepConfig)
27 >>>
28 >>> # Use with context
29 >>> with config_context(pipeline_config):
30 ... step = LazyStepConfig()
31 ... # Fields resolve from pipeline_config context
33Architecture:
34 The framework uses a dual-axis resolution system:
36 X-Axis (Context Hierarchy):
37 Step context → Pipeline context → Global context → Static defaults
39 Y-Axis (Sibling Inheritance):
40 Fields within the same context inherit from sibling dataclasses
42 This enables sophisticated configuration patterns where fields can inherit
43 from both parent contexts and sibling configurations.
45Modules:
46 - lazy_factory: Lazy dataclass factory and decorator system
47 - dual_axis_resolver: Dual-axis inheritance resolver
48 - context_manager: Contextvars-based context management
49 - placeholder: Placeholder text generation for UI
50 - global_config: Thread-local global configuration storage
51 - config: Framework configuration (pluggable types and behaviors)
52"""
54# Factory
55from openhcs.config_framework.lazy_factory import (
56 LazyDataclassFactory,
57 auto_create_decorator,
58 register_lazy_type_mapping,
59 get_base_type_for_lazy,
60 ensure_global_config_context,
61)
63# Resolver
64from openhcs.config_framework.dual_axis_resolver import (
65 resolve_field_inheritance,
66 _has_concrete_field_override,
67)
69# Context
70from openhcs.config_framework.context_manager import (
71 config_context,
72 get_current_temp_global,
73 set_current_temp_global,
74 clear_current_temp_global,
75 merge_configs,
76 extract_all_configs,
77 get_base_global_config,
78)
80# Placeholder
81from openhcs.config_framework.placeholder import LazyDefaultPlaceholderService
83# Global config
84from openhcs.config_framework.global_config import (
85 set_current_global_config,
86 get_current_global_config,
87 set_global_config_for_editing,
88)
90# Configuration
91from openhcs.config_framework.config import (
92 set_base_config_type,
93 get_base_config_type,
94)
96__all__ = [
97 # Factory
98 'LazyDataclassFactory',
99 'auto_create_decorator',
100 'register_lazy_type_mapping',
101 'get_base_type_for_lazy',
102 'ensure_global_config_context',
103 # Resolver
104 'resolve_field_inheritance',
105 '_has_concrete_field_override',
106 # Context
107 'config_context',
108 'get_current_temp_global',
109 'set_current_temp_global',
110 'clear_current_temp_global',
111 'merge_configs',
112 'extract_all_configs',
113 'get_base_global_config',
114 # Placeholder
115 'LazyDefaultPlaceholderService',
116 # Global config
117 'set_current_global_config',
118 'get_current_global_config',
119 'set_global_config_for_editing',
120 # Configuration
121 'set_base_config_type',
122 'get_base_config_type',
123]
125__version__ = '1.0.0'
126__author__ = 'OpenHCS Team'
127__description__ = 'Generic configuration framework for lazy dataclass resolution'