carloea2 commented on code in PR #8504:
URL: https://github.com/apache/texera/pull/8504#discussion_r4254036485
##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/carpetPlot/CarpetPlotOpDescSpec.scala:
##########
@@ -75,4 +149,89 @@ class CarpetPlotOpDescSpec extends AnyFlatSpec with
Matchers {
c.b shouldBe "bx"
c.y shouldBe "yx"
}
+
+ // Runs the exported block over one frame per case and reports the page it
+ // wrote, so a branch that raises instead of answering shows up as a failure
+ // rather than as a missing file.
+ private val driverScript: String =
+ """import pathlib
+ |import sys
+ |import tempfile
+ |
+ |import pandas as pd
+ |import plotly.graph_objects as go
+ |
+ |source = pathlib.Path(sys.argv[1]).read_text()
+ |
+ |cases = {
+ | "good": pd.DataFrame({"ax": [1.0, 2.0], "bx": [1.0, 2.0], "yx":
[3.0, 4.0]}),
+ | "missing": pd.DataFrame({"ax": [1.0], "yx": [3.0]}),
+ | "words": pd.DataFrame({"ax": ["one", "two"], "bx": [1.0, 2.0],
"yx": [3.0, 4.0]}),
+ | "empty": pd.DataFrame({"ax": [], "bx": [], "yx": []}),
+ | "nulls": pd.DataFrame({"ax": [None, None], "bx": [1.0, 2.0], "yx":
[3.0, 4.0]}),
+ |}
+ |
+ |for name, frame in cases.items():
+ | directory = tempfile.mkdtemp()
+ | scope = {
+ | "in1df": frame,
+ | "outputHtml": directory + "/chart.html",
+ | "outputJson": directory + "/chart.json",
+ | "pd": pd,
+ | "go": go,
+ | }
+ | exec(compile(source, "standalone", "exec"), scope)
+ | # An answer page is the whole file and opens with the heading,
where a
+ | # chart is a plotly document that happens to contain any wording.
+ | page = pathlib.Path(scope["outputHtml"]).read_text().strip()
Review Comment:
Please read these UTF-8 files with an explicit UTF-8 encoding. This driver
and Filled Area's boundary driver fail on Windows with UnicodeDecodeError at
byte 0x8f in the generated Plotly HTML. The same tests pass with PYTHONUTF8=1.
Both the generated module and HTML reads currently depend on the machine's
default encoding.
--
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]