add unit test coverage for AudioTaskCodegen
- Dominant language
- Scala
- Stars
- 314
- Forks
- 187
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 214
Description
### Task Summary
Add a dedicated `AudioTaskCodegenSpec.scala` that pins the payload/parse Python-snippet contract of `AudioTaskCodegen` — the Hugging Face codegen for the audio task family. Mirror the existing `TextGenCodegenSpec` (same package) as the template.
## Background
`AudioTaskCodegen` (`common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/AudioTaskCodegen.scala`) is an `object extends TaskCodegen`. Automatic-speech-recognition and audio-classification send audio bytes as the raw request body; text-to-speech is prompt-driven and sends a JSON payload, and its providers return either audio bytes or a JSON envelope pointing at audio.
```scala
override val task: String = "automatic-speech-recognition"
override val tasks: Set[String] = Set(
"automatic-speech-recognition", "audio-classification", "text-to-speech"
)
```
## Behavior to pin
| Member | Contract |
| --- | --- |
| `task` | equals `"automatic-speech-recognition"` |
| `tasks` | equals exactly the 3-element set above |
| `payloadPython` (audio-only) | tasks in `audio_only_tasks` set `payload = current_audio_bytes`, `use_raw_binary_body = True`, `raw_binary_headers = audio_headers` |
| `payloadPython` (TTS) | `text-to-speech` sets `payload = {"inputs": prompt_value}` |
| `parsePython` (TTS) | normalizes audio via `self._url_to_data_url` (url) or a `data:audio/mpeg;base64,` string (b64_json) |
| `parsePython` (ASR) | extracts `body["text"]` / `body["generated_text"]`; audio-classification returns `json.dumps(body)` |
| no raw-value leakage | with sentinel `CodegenContext` fields (e.g. `audioInput` / `inputAudioColumn` = `"MARKER_…"`), neither snippet contains the sentinel |
Build the `CodegenContext` with a `makeCtx` helper as in `TextGenCodegenSpec`. Assert on snippet structure / marker substrings, not exact whitespace.
## Scope
- New spec: `AudioTaskCodegenSpec.scala` under `common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/codegen/`.
- No production-code changes.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
Contributor guide
Assessment
This issue has not been assessed yet.