Several YAML template files in the template directory have formatting inconsistencies that prevent them from being properly loaded by the DataModelBuilder. This affects the usability of the examples and potentially other parts of the codebase that rely on these templates.
Issues Found
1. simple_model.yaml
- Problem: Uses
value key instead of initial_value for NumericalVariableNode objects
- Error:
ValueError: Unexpected keys: value. Allowed keys: id, name, description, measure_unit, initial_value, default_value, connector_name, remote_resource_spec
- Location: Lines with
value: 0 for numerical variables
- Expected: Should use
initial_value: 0 to match the builder's expectations
2. variable_obj.yml
- Problem: Contains unrecognized YAML tag
!Variable
- Error:
yaml.constructor.ConstructorError: could not determine a constructor for the tag '!Variable'
- Location: Line 5, column 5
- Expected: Should use proper YAML tags that are registered with the builder (e.g.,
!!VariableNode, !!NumericalVariableNode, etc.)
Reproduction Steps
-
Attempt to load simple_model.yaml:
from machine_data_model.builder.data_model_builder import DataModelBuilder
builder = DataModelBuilder()
data_model = builder.get_data_model("template/simple_model.yaml")
-
Attempt to load variable_obj.yml:
from machine_data_model.builder.data_model_builder import DataModelBuilder
builder = DataModelBuilder()
data_model = builder.get_data_model("template/variable_obj.yml")
Expected Behavior
All template files should be valid YAML that can be successfully parsed by the DataModelBuilder without errors.
Additional Context
- The working template data_model.yml uses correct formatting with
initial_value and proper YAML tags
- This affects the examples in the builder when trying to use different templates
- The inconsistency makes it difficult for users to understand the correct YAML format
Files Affected
simple_model.yaml
variable_obj.yml
Suggested Fix
- Update simple_model.yaml to use
initial_value instead of value
- Update
variable_obj.yml to use proper YAML tags (e.g., !!VariableNode)
- Consider adding validation or better error messages in the builder to help identify these issues
- Update any documentation or examples that reference these broken templates
- Rename them to
.yaml to be consistent
Several YAML template files in the template directory have formatting inconsistencies that prevent them from being properly loaded by the
DataModelBuilder. This affects the usability of the examples and potentially other parts of the codebase that rely on these templates.Issues Found
1. simple_model.yaml
valuekey instead ofinitial_valueforNumericalVariableNodeobjectsValueError: Unexpected keys: value. Allowed keys: id, name, description, measure_unit, initial_value, default_value, connector_name, remote_resource_specvalue: 0for numerical variablesinitial_value: 0to match the builder's expectations2. variable_obj.yml
!Variableyaml.constructor.ConstructorError: could not determine a constructor for the tag '!Variable'!!VariableNode,!!NumericalVariableNode, etc.)Reproduction Steps
Attempt to load simple_model.yaml:
Attempt to load variable_obj.yml:
Expected Behavior
All template files should be valid YAML that can be successfully parsed by the
DataModelBuilderwithout errors.Additional Context
initial_valueand proper YAML tagsFiles Affected
simple_model.yamlvariable_obj.ymlSuggested Fix
initial_valueinstead ofvaluevariable_obj.ymlto use proper YAML tags (e.g.,!!VariableNode).yamlto be consistent