Skip to content

Commit

Permalink
Merge branch 'refs/heads/staging' into NU-1464-NU-color-changes
Browse files Browse the repository at this point in the history
# Conflicts:
#	designer/client/cypress/e2e/__image_snapshots__/electron/Linux/Components list should display component #0.png
#	designer/client/cypress/e2e/__image_snapshots__/electron/Linux/Fragment should allow adding input parameters and display used fragment graph in modal #1.png
#	designer/client/cypress/e2e/__image_snapshots__/electron/Linux/Fragment should allow adding input parameters and display used fragment graph in modal #2.png
#	designer/client/cypress/e2e/__image_snapshots__/electron/Linux/Fragment should allow adding input parameters and display used fragment graph in modal #4.png
#	designer/client/cypress/e2e/__image_snapshots__/electron/Linux/Fragment should allow adding input parameters and display used fragment graph in modal #7.png
#	designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/AnyValueWithSuggestionVariant.tsx
#	designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/StringBooleanVariants/FixedListVariant.tsx
#	designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/FixedValuesGroup.tsx
#	designer/client/src/components/graph/node-modal/fragment-input-definition/settings/variants/fields/StyledSettingsComponnets.tsx
#	docs/autoScreenshotChangeDocs/Auto Screenshot Change Docs - fragments - Inputs #2.png
  • Loading branch information
Dzuming committed Apr 10, 2024
2 parents 722543b + b7cc9ac commit 171cf2e
Show file tree
Hide file tree
Showing 96 changed files with 3,355 additions and 887 deletions.
18 changes: 16 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ val monocleV = "2.1.0"
val jmxPrometheusJavaagentV = "0.18.0"
val wireMockV = "2.35.0"
val findBugsV = "3.0.2"
val enumeratumV = "1.7.3"

// depending on scala version one of this jar lays in Flink lib dir
def flinkLibScalaDeps(scalaVersion: String, configurations: Option[String] = None) = forScalaVersion(
Expand Down Expand Up @@ -742,7 +743,12 @@ lazy val defaultModel = (project in (file("defaultModel")))
.settings(assemblyNoScala("defaultModel.jar"): _*)
.settings(publishAssemblySettings: _*)
.settings(
name := "nussknacker-default-model"
name := "nussknacker-default-model",
libraryDependencies ++= {
Seq(
"org.scalatest" %% "scalatest" % scalaTestV % Test
)
}
)
.dependsOn(defaultHelpers, extensionsApi % Provided)

Expand Down Expand Up @@ -1095,6 +1101,10 @@ lazy val testUtils = (project in utils("test-utils"))
"io.circe" %% "circe-parser" % circeV,
"org.testcontainers" % "testcontainers" % testContainersJavaV,
"com.lihaoyi" %% "ujson" % "3.1.2",
"com.github.erosb" % "everit-json-schema" % everitSchemaV exclude ("commons-logging", "commons-logging"),
"com.softwaremill.sttp.tapir" %% "tapir-core" % tapirV,
"com.softwaremill.sttp.tapir" %% "tapir-apispec-docs" % tapirV,
"com.softwaremill.sttp.apispec" %% "openapi-circe-yaml" % "0.7.4",
) ++ forScalaVersion(
scalaVersion.value,
Seq(),
Expand Down Expand Up @@ -1479,6 +1489,7 @@ lazy val componentsApi = (project in file("components-api"))
Seq(
"org.apache.commons" % "commons-text" % flinkCommonsTextV,
"org.typelevel" %% "cats-core" % catsV,
"com.beachape" %% "enumeratum" % enumeratumV,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.typesafe" % "config" % configV,
"com.vdurmont" % "semver4j" % "3.1.0",
Expand Down Expand Up @@ -1911,7 +1922,7 @@ lazy val designer = (project in file("designer/server"))
"org.postgresql" % "postgresql" % postgresV,
"org.flywaydb" % "flyway-core" % flywayV,
"org.apache.xmlgraphics" % "fop" % "2.8" exclude ("commons-logging", "commons-logging"),
"com.beachape" %% "enumeratum-circe" % "1.7.3",
"com.beachape" %% "enumeratum-circe" % enumeratumV,
"tf.tofu" %% "derevo-circe" % "0.13.0",
"com.softwaremill.sttp.apispec" %% "openapi-circe-yaml" % "0.7.4",
"com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % tapirV,
Expand All @@ -1930,6 +1941,8 @@ lazy val designer = (project in file("designer/server"))
"io.dropwizard.metrics5" % "metrics-core" % dropWizardV,
"io.dropwizard.metrics5" % "metrics-jmx" % dropWizardV,
"fr.davit" %% "akka-http-metrics-dropwizard-v5" % "1.7.1",
"org.scalacheck" %% "scalacheck" % scalaCheckV % Test,
"com.github.erosb" % "everit-json-schema" % everitSchemaV exclude ("commons-logging", "commons-logging"),
"org.apache.flink" % "flink-metrics-dropwizard" % flinkV % Test,
"com.github.tomakehurst" % "wiremock-jre8" % wireMockV % Test,
) ++ forScalaVersion(
Expand All @@ -1951,6 +1964,7 @@ lazy val designer = (project in file("designer/server"))
listenerApi,
testUtils % Test,
flinkTestUtils % Test,
componentsApi % "test->test",
// All DeploymentManager dependencies are added because they are needed to run NussknackerApp* with
// dev-application.conf. Currently, we doesn't have a separate classpath for DMs like we have for components.
// schemedKafkaComponentsUtils is added because loading the provided liteEmbeddedDeploymentManager causes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package pl.touk.nussknacker.engine.api.component

import cats.data.NonEmptySet
import com.typesafe.config.{Config, ConfigFactory}
import com.vdurmont.semver4j.Semver
import net.ceedubs.ficus.readers.{ArbitraryTypeReader, ValueReader}
import pl.touk.nussknacker.engine.api.component.Component._
import pl.touk.nussknacker.engine.api.process.ProcessObjectDependencies
import pl.touk.nussknacker.engine.version.BuildInfo

Expand All @@ -18,23 +20,54 @@ trait Component extends Serializable {
// like in Service case, but in other cases, Component class is only a factory that returns some other class
// and we don't know if this class allow given processing mode or not so the developer have to specify this
// by his/her own
def allowedProcessingModes: Option[Set[ProcessingMode]]
def allowedProcessingModes: AllowedProcessingModes
}

object Component {
sealed trait AllowedProcessingModes

object AllowedProcessingModes {
case object All extends AllowedProcessingModes
final case class SetOf(allowedProcessingModes: NonEmptySet[ProcessingMode]) extends AllowedProcessingModes

object SetOf {

def apply(processingMode: ProcessingMode, processingModes: ProcessingMode*): SetOf = {
new SetOf(NonEmptySet.of(processingMode, processingModes: _*))
}

}

}

implicit class ToProcessingModes(val allowedProcessingModes: AllowedProcessingModes) extends AnyVal {

def toProcessingModes: Set[ProcessingMode] = allowedProcessingModes match {
case AllowedProcessingModes.All => ProcessingMode.values.toSet
case AllowedProcessingModes.SetOf(allowedProcessingModesSet) => allowedProcessingModesSet.toSortedSet
}

}

}

trait UnboundedStreamComponent { self: Component =>
override def allowedProcessingModes: Option[Set[ProcessingMode]] = Some(Set(ProcessingMode.UnboundedStream))
override def allowedProcessingModes: AllowedProcessingModes =
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
}

trait BoundedStreamComponent { self: Component =>
override def allowedProcessingModes: Option[Set[ProcessingMode]] = Some(Set(ProcessingMode.BoundedStream))
override def allowedProcessingModes: AllowedProcessingModes =
AllowedProcessingModes.SetOf(ProcessingMode.BoundedStream)
}

trait RequestResponseComponent { self: Component =>
override def allowedProcessingModes: Option[Set[ProcessingMode]] = Some(Set(ProcessingMode.RequestResponse))
override def allowedProcessingModes: AllowedProcessingModes =
AllowedProcessingModes.SetOf(ProcessingMode.RequestResponse)
}

trait AllProcessingModesComponent { self: Component =>
override def allowedProcessingModes: Option[Set[ProcessingMode]] = None
override def allowedProcessingModes: AllowedProcessingModes = AllowedProcessingModes.All
}

object ComponentProviderConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
package pl.touk.nussknacker.engine.api.component

import cats.Order
import enumeratum._
import io.circe.{Decoder, Encoder}

sealed trait ProcessingMode {
def value: String
override def toString: String = value
}
import scala.collection.immutable

case object RequestResponseProcessingMode extends ProcessingMode {
override def value: String = "Request-Response"
}
sealed trait ProcessingMode extends EnumEntry

case class StreamProcessingMode(bounded: Boolean) extends ProcessingMode {
override def value: String = s"${if (bounded) "Bounded" else "Unbounded"}-Stream"
}
object ProcessingMode extends Enum[ProcessingMode] {
case object RequestResponse extends ProcessingMode
case object BoundedStream extends ProcessingMode
case object UnboundedStream extends ProcessingMode

object ProcessingMode {
override def values: immutable.IndexedSeq[ProcessingMode] = findValues

val RequestResponse: ProcessingMode = RequestResponseProcessingMode
val UnboundedStream: ProcessingMode = StreamProcessingMode(bounded = false)
val BoundedStream: ProcessingMode = StreamProcessingMode(bounded = true)
private val RequestResponseJsonValue = "Request-Response"
private val BoundedStreamJsonValue = "Bounded-Stream"
private val UnboundedStreamJsonValue = "Unbounded-Stream"

val all: Set[ProcessingMode] = Set(UnboundedStream, BoundedStream, RequestResponse)
implicit class ProcessingModeOps(processingMode: ProcessingMode) {

def toJsonString: String = processingMode match {
case ProcessingMode.RequestResponse => RequestResponseJsonValue
case ProcessingMode.BoundedStream => BoundedStreamJsonValue
case ProcessingMode.UnboundedStream => UnboundedStreamJsonValue
}

}

implicit val encoder: Encoder[ProcessingMode] = Encoder.encodeString.contramap(_.value)
implicit val processingModeEncoder: Encoder[ProcessingMode] = Encoder.encodeString.contramap(_.toJsonString)

implicit val decoder: Decoder[ProcessingMode] = Decoder.decodeString.map {
case str if str == RequestResponse.value => RequestResponseProcessingMode
case str if str == UnboundedStream.value => UnboundedStream
case str if str == BoundedStream.value => BoundedStream
case other => throw new IllegalArgumentException(s"Not known processing mode: $other")
implicit val processingModeDecoder: Decoder[ProcessingMode] = Decoder.decodeString.map {
case RequestResponseJsonValue => ProcessingMode.RequestResponse
case BoundedStreamJsonValue => ProcessingMode.BoundedStream
case UnboundedStreamJsonValue => ProcessingMode.UnboundedStream
case other => throw new IllegalArgumentException(s"Unknown processing mode: $other")
}

implicit val processingModeOrdering: Ordering[ProcessingMode] = Ordering.by(_.toJsonString)
implicit val processingModeOrder: Order[ProcessingMode] = Order.fromOrdering
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pl.touk.nussknacker.engine.api.process

import cats.data.NonEmptySet
import pl.touk.nussknacker.engine.api.component.Component._
import pl.touk.nussknacker.engine.api.component.{Component, ProcessingMode}
import pl.touk.nussknacker.engine.api.context.ContextTransformation
import pl.touk.nussknacker.engine.api.definition.{Parameter, WithExplicitTypesToExtract}
Expand Down Expand Up @@ -61,23 +63,39 @@ object SourceFactory {

// source is called by for making SourceFactory serialization easier
def noParamUnboundedStreamFactory(source: => Source, inputType: TypingResult): SourceFactory =
NoParamSourceFactory(_ => source, inputType, Some(Set(ProcessingMode.UnboundedStream)))
NoParamSourceFactory(
_ => source,
inputType,
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
)

def noParamUnboundedStreamFactory[T: TypeTag](source: => Source)(implicit ev: T =:!= Nothing): SourceFactory =
NoParamSourceFactory(_ => source, Typed.fromDetailedType[T], Some(Set(ProcessingMode.UnboundedStream)))
NoParamSourceFactory(
_ => source,
Typed.fromDetailedType[T],
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
)

def noParamUnboundedStreamFactory[T: TypeTag](createSource: NodeId => Source)(
implicit ev: T =:!= Nothing
): SourceFactory =
NoParamSourceFactory(createSource, Typed.fromDetailedType[T], Some(Set(ProcessingMode.UnboundedStream)))
NoParamSourceFactory(
createSource,
Typed.fromDetailedType[T],
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
)

def noParamUnboundedStreamFromClassTag[T: ClassTag](source: => Source)(implicit ev: T =:!= Nothing): SourceFactory =
NoParamSourceFactory(_ => source, Typed.apply[T], Some(Set(ProcessingMode.UnboundedStream)))
NoParamSourceFactory(
_ => source,
Typed.apply[T],
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
)

case class NoParamSourceFactory(
createSource: NodeId => Source,
inputType: TypingResult,
override val allowedProcessingModes: Option[Set[ProcessingMode]]
override val allowedProcessingModes: AllowedProcessingModes
) extends SourceFactory
with WithExplicitTypesToExtract {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pl.touk.nussknacker.engine.api.typed

import cats.data.Validated._
import cats.data.{NonEmptyList, NonEmptySet, ValidatedNel}
import cats.data.{NonEmptyList, ValidatedNel}
import cats.implicits.{catsSyntaxValidatedId, _}
import org.apache.commons.lang3.ClassUtils
import pl.touk.nussknacker.engine.api.typed.typing._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pl.touk.nussknacker.engine.api.typed.supertype
import cats.data.NonEmptyList
import cats.implicits.toTraverseOps
import pl.touk.nussknacker.engine.api.typed.supertype.CommonSupertypeFinder.{
Default,
SupertypeClassResolutionStrategy,
looseFinder
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object typing {
implicit val encoder: Encoder[TypingResult] = TypeEncoders.typingResultEncoder
}

// TODO: Rename to Typed
// TODO: Rename to Typed, maybe NuType?
sealed trait TypingResult {

// TODO: We should split this method into two or three methods:
Expand Down Expand Up @@ -133,7 +133,8 @@ object typing {
// Thanks to that we avoid nasty types like String | null (String type is nullable as well)
// We can avoid this case by changing this folding logic - see the comment there
case object TypedNull extends TypingResult {
override def withoutValue: TypedNull.type = TypedNull

override val withoutValue: TypingResult = this

// this value is intentionally `Some(null)` (and not `None`), as TypedNull represents null value
override val valueOpt: Some[Null] = Some(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package pl.touk.nussknacker.defaultmodel

import pl.touk.nussknacker.defaultmodel.migrations.{
GroupByMigration,
RequestResponseSinkValidationModeMigration,
SinkExpressionMigration
}
import pl.touk.nussknacker.defaultmodel.migrations._
import pl.touk.nussknacker.engine.migration.{ProcessMigration, ProcessMigrations}

class DefaultModelMigrations extends ProcessMigrations {
Expand All @@ -13,7 +9,8 @@ class DefaultModelMigrations extends ProcessMigrations {
.listOf(
GroupByMigration,
SinkExpressionMigration,
RequestResponseSinkValidationModeMigration
RequestResponseSinkValidationModeMigration,
DecisionTableParameterNamesMigration
)
.processMigrations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package pl.touk.nussknacker.defaultmodel.migrations

import pl.touk.nussknacker.engine.api.MetaData
import pl.touk.nussknacker.engine.api.parameter.ParameterName
import pl.touk.nussknacker.engine.graph.evaluatedparam.Parameter
import pl.touk.nussknacker.engine.graph.node
import pl.touk.nussknacker.engine.graph.node.Enricher
import pl.touk.nussknacker.engine.graph.service.ServiceRef
import pl.touk.nussknacker.engine.migration.NodeMigration

object DecisionTableParameterNamesMigration extends NodeMigration {

override val description: String = "Change Decision Table component parameter names"

override def migrateNode(metaData: MetaData): PartialFunction[node.NodeData, node.NodeData] = {
case enricher @ Enricher(_, service @ ServiceRef(_, params), _, _) =>
enricher.copy(service = service.copy(parameters = renameParams(params)))
}

private def renameParams(params: List[Parameter]) = {
params.map { param =>
param.name.value match {
case "Basic Decision Table" => param.copy(name = ParameterName("Decision Table"))
case "Expression" => param.copy(name = ParameterName("Filtering expression"))
case _ => param
}
}
}

}
Loading

0 comments on commit 171cf2e

Please sign in to comment.