carloea2 commented on code in PR #8344:
URL: https://github.com/apache/texera/pull/8344#discussion_r3973443371
##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/IcicleChart/IcicleChartOpDesc.scala:
##########
@@ -132,4 +136,46 @@ class IcicleChartOpDesc extends PythonOperatorDescriptor {
finalCode.encode
}
+ // Output is an HTML chart, not a tabular DataFrame.
+ // The translator skips it in the leaf-DataFrame print block.
+ override def producesDataFrame(): Boolean = false
+
+ override def generateStandaloneCode(): String = {
+ val attributes = hierarchy.map(section =>
pyStringLiteral(section.attributeName)).mkString(", ")
+ val valueLit = pyStringLiteral(value)
+ // The error page is written to output.html, the same file a plotted chart
lands
+ // in, so a reason for "no chart" is where the reader looks for the chart —
+ // printing it to the terminal alone left output.html absent.
render_error's
+ // continuation line keeps the runtime path's indentation, since the HTML
is
+ // triple-quoted and those spaces reach the browser.
+ s"""def render_error(error_msg):
+ | return '''<h1>Icicle chart is not available.</h1>
+ | <p>Reason is: {} </p>
+ | '''.format(error_msg)
+ |
+ |def fail(error_msg):
+ | with open("output.html", "w", encoding="utf-8") as output:
+ | output.write(render_error(error_msg))
+ | print(f"Icicle chart error: {error_msg}")
+ |
+ |if in1df.empty:
+ | fail("input table is empty.")
+ |else:
+ | # On a copy: the same frame can feed another branch of the plan,
and
+ | # both the assignment and the drop below would otherwise reach it.
+ | chart_df = in1df.copy()
+ | chart_df[$valueLit] = chart_df[chart_df[$valueLit] > 0][$valueLit]
+ | chart_df = chart_df.dropna(subset=[$attributes])
+ | if chart_df.empty:
+ | fail("value column contains only non-positive numbers or
nulls.")
+ | else:
+ | fig = px.icicle(chart_df, path=[$attributes], values=$valueLit,
+ | color=$valueLit, hover_data=[$attributes],
+ | color_continuous_scale='RdBu')
+ | fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
+ | fig.write_json("output.json")
Review Comment:
Every chart writes the same output filenames, and the translator runs all
fragments in one directory. A workflow with two chart leaves therefore keeps
only the last chart. This affects the other visualization PRs too. Please give
each operator its own output paths through the shared export contract and test
a workflow with two chart branches.
--
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]