|
|
@@ -303,8 +303,9 @@ class VariableCollection:
|
|
|
"""Get variable values only from sections with satisfied dependencies.
|
|
|
|
|
|
This respects both toggle states and section dependencies, ensuring that:
|
|
|
- - Variables from disabled sections (toggle=false) are excluded
|
|
|
+ - Variables from disabled sections (toggle=false) are excluded EXCEPT required variables
|
|
|
- Variables from sections with unsatisfied dependencies are excluded
|
|
|
+ - Required variables are always included if their section dependencies are satisfied
|
|
|
|
|
|
Returns:
|
|
|
Dictionary of variable names to values for satisfied sections only
|
|
|
@@ -312,19 +313,25 @@ class VariableCollection:
|
|
|
satisfied_values = {}
|
|
|
|
|
|
for section_key, section in self._sections.items():
|
|
|
- # Skip sections with unsatisfied dependencies
|
|
|
+ # Skip sections with unsatisfied dependencies (even required variables need satisfied deps)
|
|
|
if not self.is_section_satisfied(section_key):
|
|
|
logger.debug(f"Excluding variables from section '{section_key}' - dependencies not satisfied")
|
|
|
continue
|
|
|
|
|
|
- # Skip disabled sections (toggle check)
|
|
|
- if not section.is_enabled():
|
|
|
- logger.debug(f"Excluding variables from section '{section_key}' - section is disabled")
|
|
|
- continue
|
|
|
+ # Check if section is enabled
|
|
|
+ is_enabled = section.is_enabled()
|
|
|
|
|
|
- # Include all variables from this satisfied section
|
|
|
- for var_name, variable in section.variables.items():
|
|
|
- satisfied_values[var_name] = variable.convert(variable.value)
|
|
|
+ if is_enabled:
|
|
|
+ # Include all variables from enabled section
|
|
|
+ for var_name, variable in section.variables.items():
|
|
|
+ satisfied_values[var_name] = variable.convert(variable.value)
|
|
|
+ else:
|
|
|
+ # Section is disabled - only include required variables
|
|
|
+ logger.debug(f"Section '{section_key}' is disabled - including only required variables")
|
|
|
+ for var_name, variable in section.variables.items():
|
|
|
+ if variable.required:
|
|
|
+ logger.debug(f"Including required variable '{var_name}' from disabled section '{section_key}'")
|
|
|
+ satisfied_values[var_name] = variable.convert(variable.value)
|
|
|
|
|
|
return satisfied_values
|
|
|
|
|
|
@@ -381,17 +388,32 @@ class VariableCollection:
|
|
|
return successful
|
|
|
|
|
|
def validate_all(self) -> None:
|
|
|
- """Validate all variables in the collection, skipping disabled and unsatisfied sections."""
|
|
|
+ """Validate all variables in the collection.
|
|
|
+
|
|
|
+ Validates:
|
|
|
+ - All variables in enabled sections with satisfied dependencies
|
|
|
+ - Required variables even if their section is disabled (but dependencies must be satisfied)
|
|
|
+ """
|
|
|
errors: list[str] = []
|
|
|
|
|
|
for section_key, section in self._sections.items():
|
|
|
- # Skip sections with unsatisfied dependencies or disabled via toggle
|
|
|
- if not self.is_section_satisfied(section_key) or not section.is_enabled():
|
|
|
- logger.debug(f"Skipping validation for section '{section_key}'")
|
|
|
+ # Skip sections with unsatisfied dependencies (even for required variables)
|
|
|
+ if not self.is_section_satisfied(section_key):
|
|
|
+ logger.debug(f"Skipping validation for section '{section_key}' - dependencies not satisfied")
|
|
|
continue
|
|
|
+
|
|
|
+ # Check if section is enabled
|
|
|
+ is_enabled = section.is_enabled()
|
|
|
+
|
|
|
+ if not is_enabled:
|
|
|
+ logger.debug(f"Section '{section_key}' is disabled - validating only required variables")
|
|
|
|
|
|
- # Validate each variable in the section
|
|
|
+ # Validate variables in the section
|
|
|
for var_name, variable in section.variables.items():
|
|
|
+ # Skip non-required variables in disabled sections
|
|
|
+ if not is_enabled and not variable.required:
|
|
|
+ continue
|
|
|
+
|
|
|
try:
|
|
|
# Skip autogenerated variables when empty
|
|
|
if variable.autogenerated and not variable.value:
|