@@ -767,10 +767,11 @@ func Registry() []FieldSpec {
767767 if tgt .ModelCard == nil || src .Readme == nil {
768768 return
769769 }
770- cons := ensureConsiderations ( tgt . ModelCard )
771- if cons . UseCases != nil && len (* cons .UseCases ) > 0 {
770+ // Check existing first
771+ if tgt . ModelCard . Considerations != nil && tgt . ModelCard . Considerations . UseCases != nil && len (* tgt . ModelCard . Considerations .UseCases ) > 0 {
772772 return
773773 }
774+ // Collect data
774775 useCases := []string {}
775776 if s := strings .TrimSpace (src .Readme .DirectUse ); s != "" {
776777 useCases = append (useCases , s )
@@ -782,6 +783,8 @@ func Registry() []FieldSpec {
782783 if len (useCases ) == 0 {
783784 return
784785 }
786+ // Only create structure when we have data
787+ cons := ensureConsiderations (tgt .ModelCard )
785788 cons .UseCases = & useCases
786789 logf (src .ModelID , "apply %s set=%s" , ModelCardConsiderationsUseCases , summarizeValue (useCases ))
787790 },
@@ -827,15 +830,18 @@ func Registry() []FieldSpec {
827830 if tgt .ModelCard == nil || src .Readme == nil {
828831 return
829832 }
830- cons := ensureConsiderations ( tgt . ModelCard )
831- if cons . TechnicalLimitations != nil && len (* cons .TechnicalLimitations ) > 0 {
833+ // Check existing first
834+ if tgt . ModelCard . Considerations != nil && tgt . ModelCard . Considerations . TechnicalLimitations != nil && len (* tgt . ModelCard . Considerations .TechnicalLimitations ) > 0 {
832835 return
833836 }
837+ // Validate data exists
834838 s := strings .TrimSpace (src .Readme .BiasRisksLimitations )
835839 if s == "" {
836840 return
837841 }
842+ // Only create structure when we have data
838843 vals := []string {s }
844+ cons := ensureConsiderations (tgt .ModelCard )
839845 cons .TechnicalLimitations = & vals
840846 logf (src .ModelID , "apply %s set=%s" , ModelCardConsiderationsTechnicalLimitations , summarizeValue (s ))
841847 },
@@ -881,10 +887,11 @@ func Registry() []FieldSpec {
881887 if tgt .ModelCard == nil || src .Readme == nil {
882888 return
883889 }
884- cons := ensureConsiderations ( tgt . ModelCard )
885- if cons . EthicalConsiderations != nil && len (* cons .EthicalConsiderations ) > 0 {
890+ // Check existing first
891+ if tgt . ModelCard . Considerations != nil && tgt . ModelCard . Considerations . EthicalConsiderations != nil && len (* tgt . ModelCard . Considerations .EthicalConsiderations ) > 0 {
886892 return
887893 }
894+ // Validate data exists
888895 name := strings .TrimSpace (src .Readme .BiasRisksLimitations )
889896 mit := strings .TrimSpace (src .Readme .BiasRecommendations )
890897 if name == "" && mit == "" {
@@ -893,7 +900,9 @@ func Registry() []FieldSpec {
893900 if name == "" {
894901 name = "bias_risks_limitations"
895902 }
903+ // Only create structure when we have data
896904 ethics := []cdx.MLModelCardEthicalConsideration {{Name : name , MitigationStrategy : mit }}
905+ cons := ensureConsiderations (tgt .ModelCard )
897906 cons .EthicalConsiderations = & ethics
898907 logf (src .ModelID , "apply %s set=true" , ModelCardConsiderationsEthicalConsiderations )
899908 },
@@ -967,10 +976,11 @@ func Registry() []FieldSpec {
967976 if tgt .ModelCard == nil || src .Readme == nil {
968977 return
969978 }
970- qa := ensureQuantitativeAnalysis ( tgt . ModelCard )
971- if qa . PerformanceMetrics != nil && len (* qa .PerformanceMetrics ) > 0 {
979+ // Check existing first
980+ if tgt . ModelCard . QuantitativeAnalysis != nil && tgt . ModelCard . QuantitativeAnalysis . PerformanceMetrics != nil && len (* tgt . ModelCard . QuantitativeAnalysis .PerformanceMetrics ) > 0 {
972981 return
973982 }
983+ // Collect metrics data
974984 metrics := make ([]cdx.MLPerformanceMetric , 0 )
975985
976986 // 1) From model-index in README YAML (detailed metrics with values)
@@ -1030,6 +1040,8 @@ func Registry() []FieldSpec {
10301040 if len (metrics ) == 0 {
10311041 return
10321042 }
1043+ // Only create structure when we have data
1044+ qa := ensureQuantitativeAnalysis (tgt .ModelCard )
10331045 qa .PerformanceMetrics = & metrics
10341046 logf (src .ModelID , "apply %s set=%s" , ModelCardQuantitativeAnalysisPerformanceMetrics , summarizeValue (metrics ))
10351047 },
0 commit comments