test(workflow-operator): add ImageUtilitySpec for encodeImageToHTML#5679
Open
KYinXu wants to merge 2 commits into
Open
test(workflow-operator): add ImageUtilitySpec for encodeImageToHTML#5679KYinXu wants to merge 2 commits into
KYinXu wants to merge 2 commits into
Conversation
Contributor
|
👋 Thanks for your first contribution to Texera, @KYinXu! If you're looking for a good place to start, browse issues labeled You can drive common housekeeping yourself by commenting one of these commands on its own line:
Each command must match exactly: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Pin the Python snippet emitted by ImageUtility.encodeImageToHTML() — the helper that visualization operators splice into generated UDF code to base64-encode binary image data into an
tag. Any drift in the f-string template or the error fallback would silently break image-rendering operators (e.g. Word Cloud). No production-code changes. Negative cases are covered implicitly: removing any pinned substring fails the corresponding assertion.
Spec file name follows the
<srcClassName>Spec.scalaone-to-one convention.Behavior pinned
encodeImageToHTMLStringimport base64appearsbase64.b64encode(binary_image_data).decode("utf-8")appears<img>tag withdata:image;base64,...data:image;base64,{encoded_image_str}appears (verifies the f-string template)except ExceptionandBinary input is not validboth appearhtml =assignmenthtml = fappears so downstream code can referencehtmlThe harness pins via
containson canonical substrings — resilient to incidental whitespace changes fromstripMarginwhile still catching real template drift.Any related issues, documentation, discussions?
Closes #5665
How was this PR tested?
Unit tests were added here, tested through local verification:
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.visualization.ImageUtilitySpec"- All 8 tests passedsbt scalafmtCheckAll-- cleansbt scalafixAll --checkNo lint errorsWas this PR authored or co-authored using generative AI tooling?
Generated-by: Composer 2.5 Fast