Skip to content

Inconsistent YAML formatting in template files causing parsing errors #57

Description

@Galfurian

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

  1. 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")
  2. 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

  1. Update simple_model.yaml to use initial_value instead of value
  2. Update variable_obj.yml to use proper YAML tags (e.g., !!VariableNode)
  3. Consider adding validation or better error messages in the builder to help identify these issues
  4. Update any documentation or examples that reference these broken templates
  5. Rename them to .yaml to be consistent

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions