-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deployments for scenarios with dict editors after model reload (#…
- Loading branch information
Showing
35 changed files
with
447 additions
and
66 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common-api/src/main/scala/pl/touk/nussknacker/engine/api/parameter/ParameterName.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package pl.touk.nussknacker.engine.api.parameter | ||
|
||
import io.circe.generic.extras.semiauto.{deriveUnwrappedDecoder, deriveUnwrappedEncoder} | ||
import io.circe.{Decoder, Encoder, KeyDecoder, KeyEncoder} | ||
|
||
final case class ParameterName(value: String) { | ||
def withBranchId(branchId: String): ParameterName = ParameterName(s"$value for branch $branchId") | ||
} | ||
|
||
object ParameterName { | ||
implicit val encoder: Encoder[ParameterName] = deriveUnwrappedEncoder | ||
implicit val decoder: Decoder[ParameterName] = deriveUnwrappedDecoder | ||
|
||
implicit val keyEncoder: KeyEncoder[ParameterName] = KeyEncoder.encodeKeyString.contramap(_.value) | ||
implicit val keyDecoder: KeyDecoder[ParameterName] = KeyDecoder.decodeKeyString.map(ParameterName(_)) | ||
} |
This file contains 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
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
...scala/pl/touk/nussknacker/engine/util/AdditionalComponentConfigsForRuntimeExtractor.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package pl.touk.nussknacker.engine.util | ||
|
||
import pl.touk.nussknacker.engine.api.component.{ComponentAdditionalConfig, DesignerWideComponentId} | ||
import pl.touk.nussknacker.engine.api.parameter.ValueInputWithDictEditor | ||
|
||
object AdditionalComponentConfigsForRuntimeExtractor { | ||
|
||
// This is done to reduce data sent to Flink | ||
def getRequiredAdditionalConfigsForRuntime( | ||
additionalComponentConfigs: Map[DesignerWideComponentId, ComponentAdditionalConfig] | ||
): Map[DesignerWideComponentId, ComponentAdditionalConfig] = { | ||
getAdditionalConfigsWithDictParametersEditors(additionalComponentConfigs) | ||
} | ||
|
||
// This function filters additional configs provided by AdditionalUIConfigProvider | ||
// to include only component and parameter configs with Dictionary editors. | ||
private def getAdditionalConfigsWithDictParametersEditors( | ||
additionalComponentConfigs: Map[DesignerWideComponentId, ComponentAdditionalConfig] | ||
): Map[DesignerWideComponentId, ComponentAdditionalConfig] = additionalComponentConfigs | ||
.map { case (componentId, componentAdditionalConfig) => | ||
val parametersWithDictEditors = componentAdditionalConfig.parameterConfigs.filter { | ||
case (_, additionalUiConfig) => | ||
additionalUiConfig.valueEditor match { | ||
case Some(_: ValueInputWithDictEditor) => true | ||
case _ => false | ||
} | ||
} | ||
componentId -> componentAdditionalConfig.copy(parameterConfigs = parametersWithDictEditors) | ||
} | ||
.filter(_._2.parameterConfigs.nonEmpty) | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
...a/pl/touk/nussknacker/engine/util/AdditionalComponentConfigsForRuntimeExtractorTest.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package pl.touk.nussknacker.engine.util | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.should.Matchers | ||
import pl.touk.nussknacker.engine.api.component.{ | ||
ComponentAdditionalConfig, | ||
ComponentGroupName, | ||
DesignerWideComponentId, | ||
ParameterAdditionalUIConfig | ||
} | ||
import pl.touk.nussknacker.engine.api.definition.FixedExpressionValue | ||
import pl.touk.nussknacker.engine.api.parameter.{ParameterName, ValueInputWithDictEditor} | ||
import pl.touk.nussknacker.engine.util.AdditionalComponentConfigsForRuntimeExtractorTest.{ | ||
componentConfigWithDictionaryEditorInParameter, | ||
componentConfigWithOnlyDictEditorParameters, | ||
componentConfigWithoutDictionaryEditorInParameter | ||
} | ||
|
||
class AdditionalComponentConfigsForRuntimeExtractorTest extends AnyFunSuite with Matchers { | ||
|
||
test("should filter only components and parameters with dictionary editors") { | ||
val additionalConfig = Map( | ||
DesignerWideComponentId("componentA") -> componentConfigWithDictionaryEditorInParameter, | ||
DesignerWideComponentId("componentB") -> componentConfigWithoutDictionaryEditorInParameter, | ||
) | ||
val filteredResult = | ||
AdditionalComponentConfigsForRuntimeExtractor.getRequiredAdditionalConfigsForRuntime(additionalConfig) | ||
|
||
filteredResult shouldBe Map( | ||
DesignerWideComponentId("componentA") -> componentConfigWithOnlyDictEditorParameters | ||
) | ||
} | ||
|
||
} | ||
|
||
object AdditionalComponentConfigsForRuntimeExtractorTest { | ||
|
||
private val parameterAWithDictEditor = ( | ||
ParameterName("parameterA"), | ||
ParameterAdditionalUIConfig( | ||
required = true, | ||
initialValue = Some(FixedExpressionValue("'someInitialValueExpression'", "someInitialValueLabel")), | ||
hintText = None, | ||
valueEditor = Some(ValueInputWithDictEditor("someDictA", allowOtherValue = true)), | ||
valueCompileTimeValidation = None | ||
) | ||
) | ||
|
||
private val parameterBWithDictEditor = ( | ||
ParameterName("parameterB"), | ||
ParameterAdditionalUIConfig( | ||
required = false, | ||
initialValue = None, | ||
hintText = Some("someHint"), | ||
valueEditor = Some(ValueInputWithDictEditor("someDictB", allowOtherValue = false)), | ||
valueCompileTimeValidation = None | ||
) | ||
) | ||
|
||
private val parameterWithoutDictEditor = ( | ||
ParameterName("parameterC"), | ||
ParameterAdditionalUIConfig( | ||
required = true, | ||
initialValue = None, | ||
hintText = None, | ||
valueEditor = None, | ||
valueCompileTimeValidation = None | ||
) | ||
) | ||
|
||
private val componentConfigWithDictionaryEditorInParameter = ComponentAdditionalConfig( | ||
parameterConfigs = Map( | ||
parameterAWithDictEditor, | ||
parameterBWithDictEditor, | ||
parameterWithoutDictEditor | ||
), | ||
icon = Some("someIcon"), | ||
docsUrl = Some("someDocUrl"), | ||
componentGroup = Some(ComponentGroupName("Service")) | ||
) | ||
|
||
private val componentConfigWithoutDictionaryEditorInParameter = ComponentAdditionalConfig( | ||
parameterConfigs = Map(parameterWithoutDictEditor), | ||
icon = Some("someOtherIcon"), | ||
docsUrl = Some("someOtherDocUrl"), | ||
componentGroup = Some(ComponentGroupName("Service")) | ||
) | ||
|
||
private val componentConfigWithOnlyDictEditorParameters = ComponentAdditionalConfig( | ||
parameterConfigs = Map( | ||
parameterAWithDictEditor, | ||
parameterBWithDictEditor | ||
), | ||
icon = Some("someIcon"), | ||
docsUrl = Some("someDocUrl"), | ||
componentGroup = Some(ComponentGroupName("Service")) | ||
) | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.