kunwp1 commented on code in PR #9204: URL: https://github.com/apache/texera/pull/9204#discussion_r4407243740
########## common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/metadata/VisualizationOutputSchemaSpec.scala: ########## @@ -33,15 +33,14 @@ import org.scalatest.matchers.should.Matchers * * The frontend locates the chart HTML a visualization returns by reading a * single `html-content` STRING column from the operator's one output port. - * Every Python visualization descriptor re-declares that contract in its own - * `getOutputSchemas` override, so a new chart (or an edit to an existing one) - * can silently ship a schema the frontend cannot render, and only that - * operator's own spec -- if it asserts the schema at all -- would notice. + * `PythonVisualizationOpDesc` declares that contract once, but a new chart that + * does not extend it, or one that overrides `getOutputSchemas`, can still ship a + * schema the frontend cannot render, and only that operator's own spec -- if it + * asserts the schema at all -- would notice. Review Comment: Now that the contract has one home, could the sweep check that each chart extends `PythonVisualizationOpDesc` rather than `PythonOperatorDescriptor`, and assert `producesDataFrame()` is false next to the schema? No test references `producesDataFrame` today. ########## common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/PythonVisualizationOpDesc.scala: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.texera.amber.operator.visualization + +import org.apache.texera.amber.core.tuple.{AttributeType, Schema} +import org.apache.texera.amber.core.workflow.PortIdentity +import org.apache.texera.amber.operator.{PythonOperatorDescriptor, StandaloneCodeGenerator} + +/** + * A chart drawn by Python code. + * + * Its one output port carries a single `html-content` STRING column, whatever + * the input schemas are: that column is where the frontend finds the rendered + * chart. Its exported script writes the chart to a file rather than producing + * a table, so the translator does not print it as a leaf DataFrame. + */ +trait PythonVisualizationOpDesc extends PythonOperatorDescriptor with StandaloneCodeGenerator { + + override def getOutputSchemas( + inputSchemas: Map[PortIdentity, Schema] + ): Map[PortIdentity, Schema] = + Map(operatorInfo.outputPorts.head.id -> Schema().add("html-content", AttributeType.STRING)) + + override def producesDataFrame(): Boolean = false Review Comment: Marking these two `final` would enforce the contract at compile time. -- 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]
