PG1204 opened a new issue, #8482:
URL: https://github.com/apache/texera/issues/8482
### 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:
1. **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.
2. **`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
- [x] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]