Coverage for openhcs/config_framework/__init__.py: 100.0%
11 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-04 02:09 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-04 02:09 +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# Cache warming
97from openhcs.config_framework.cache_warming import (
98 prewarm_config_analysis_cache,
99 prewarm_callable_analysis_cache,
100)
102__all__ = [
103 # Factory
104 'LazyDataclassFactory',
105 'auto_create_decorator',
106 'register_lazy_type_mapping',
107 'get_base_type_for_lazy',
108 'ensure_global_config_context',
109 # Resolver
110 'resolve_field_inheritance',
111 '_has_concrete_field_override',
112 # Context
113 'config_context',
114 'get_current_temp_global',
115 'set_current_temp_global',
116 'clear_current_temp_global',
117 'merge_configs',
118 'extract_all_configs',
119 'get_base_global_config',
120 # Placeholder
121 'LazyDefaultPlaceholderService',
122 # Global config
123 'set_current_global_config',
124 'get_current_global_config',
125 'set_global_config_for_editing',
126 # Configuration
127 'set_base_config_type',
128 'get_base_config_type',
129 # Cache warming
130 'prewarm_config_analysis_cache',
131 'prewarm_callable_analysis_cache',
132]
134__version__ = '1.0.0'
135__author__ = 'OpenHCS Team'
136__description__ = 'Generic configuration framework for lazy dataclass resolution'