Task Summary
HuggingFaceSpamSMSDetectionOpDesc.getOutputSchemas is the only one of the four legacy Hugging Face operators that neither validates its result-attribute names nor keys the input schema by port id. Bring it in line with its siblings.
Context
getOutputSchemas (HuggingFaceSpamSMSDetectionOpDesc.scala:87-95) is:
override def getOutputSchemas(
inputSchemas: Map[PortIdentity, Schema]
): Map[PortIdentity, Schema] = {
Map(
operatorInfo.outputPorts.head.id -> inputSchemas.values.head
.add(resultAttributeSpam, AttributeType.BOOLEAN)
.add(resultAttributeProbability, AttributeType.DOUBLE)
)
}
Two differences from the other three operators in the same package:
-
No result-attribute validation. HuggingFaceSentimentAnalysisOpDesc (L112-117) and HuggingFaceIrisLogisticRegressionOpDesc (L118-121) both check x == null || x.trim.isEmpty and return null before building the schema; HuggingFaceTextSummarizationOpDesc (L91-92) throws instead. This operator does neither, so an unset or blank name is passed straight into Schema.add and surfaces later, and less clearly, than in the sibling operators.
-
inputSchemas.values.head instead of keying by port id. The sibling operators use inputSchemas(operatorInfo.inputPorts.head.id). With a single input port these are equivalent today, so this is a robustness and consistency point rather than a live defect, values.head depends on map iteration order rather than the declared port.
Note EncodableString is String @EncodableStringAnnotation (PythonTemplateBuilder.scala:52), so the sibling null/empty check applies unchanged here.
Proposed change
Add the same null/empty guard the sibling operators use for resultAttributeSpam and resultAttributeProbability, and key the input schema by the declared input port id.
Match HuggingFaceSentimentAnalysisOpDesc's return null rather than HuggingFaceTextSummarizationOpDesc's throw: it is the majority behavior among the siblings, and getOutputSchemas is called while an operator is still being configured, where throwing would be noisy.
Unifying the error contract across all four operators where two return null, one throws, one does neither and is a larger discussion and is deliberately out of scope here.
Required test
Extend HuggingFaceSpamSMSDetectionOpDescSpec to cover a null and a blank result-attribute name, and to assert the happy path still adds both columns to the input schema.
Task Type
Task Summary
HuggingFaceSpamSMSDetectionOpDesc.getOutputSchemasis the only one of the four legacy Hugging Face operators that neither validates its result-attribute names nor keys the input schema by port id. Bring it in line with its siblings.Context
getOutputSchemas(HuggingFaceSpamSMSDetectionOpDesc.scala:87-95) is:Two differences from the other three operators in the same package:
No result-attribute validation.
HuggingFaceSentimentAnalysisOpDesc(L112-117) andHuggingFaceIrisLogisticRegressionOpDesc(L118-121) both checkx == null || x.trim.isEmptyand returnnullbefore building the schema;HuggingFaceTextSummarizationOpDesc(L91-92) throws instead. This operator does neither, so an unset or blank name is passed straight intoSchema.addand surfaces later, and less clearly, than in the sibling operators.inputSchemas.values.headinstead of keying by port id. The sibling operators useinputSchemas(operatorInfo.inputPorts.head.id). With a single input port these are equivalent today, so this is a robustness and consistency point rather than a live defect,values.headdepends on map iteration order rather than the declared port.Note
EncodableStringisString @EncodableStringAnnotation(PythonTemplateBuilder.scala:52), so the sibling null/empty check applies unchanged here.Proposed change
Add the same null/empty guard the sibling operators use for
resultAttributeSpamandresultAttributeProbability, and key the input schema by the declared input port id.Match
HuggingFaceSentimentAnalysisOpDesc'sreturn nullrather thanHuggingFaceTextSummarizationOpDesc's throw: it is the majority behavior among the siblings, andgetOutputSchemasis called while an operator is still being configured, where throwing would be noisy.Unifying the error contract across all four operators where two return
null, one throws, one does neither and is a larger discussion and is deliberately out of scope here.Required test
Extend
HuggingFaceSpamSMSDetectionOpDescSpecto cover a null and a blank result-attribute name, and to assert the happy path still adds both columns to the input schema.Task Type