def test_add_metadata_with_model_attributes(self, tmp_path):
        """Test adding optimization information from model attributes."""
        # Setup
        model_attributes = {
            "original_model_path": "/path/to/original/model.onnx",
            "optimization_passes": ["OnnxTransformerOptimization", "OnnxQuantization"],
            "hf_task": "text-classification",
            "quantization_config": "dynamic_int8",
        }
        input_model = get_onnx_model(model_attributes=model_attributes)
        config = {"graph_name": "optimized_graph", "add_optimization_info": True}
        p = create_pass_from_dict(AddOliveMetadata, config, disable_search=True)
        output_folder = str(tmp_path / "onnx")

        # Execute
        output_model = p.run(input_model, output_folder)

        # Assert
        onnx_model = onnx.load_model(output_model.model_path)
        metadata_dict = {entry.key: entry.value for entry in onnx_model.metadata_props}

        assert metadata_dict["original_model_path"] == "/path/to/original/model.onnx"
        assert metadata_dict["optimization_passes"] == "OnnxTransformerOptimization, OnnxQuantization"
        assert metadata_dict["hf_task"] == "text-classification"
        assert metadata_dict["quantization_config"] == "dynamic_int8"
Test adding optimization information from model attributes.
test/unit_test/passes/onnx/test_add_metadata.py