Skip to content

Commit

Permalink
fix/ci (#56)
Browse files Browse the repository at this point in the history
* fix: remove unnecessary validation annotation

* fix: remove unnecessary validation annotation, move some properties to dynamic
  • Loading branch information
mgabelle authored Jan 10, 2025
1 parent af2b84b commit 75e4a58
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
20 changes: 9 additions & 11 deletions src/main/java/io/kestra/plugin/soda/AbstractSoda.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ public abstract class AbstractSoda extends Task {
title = "Runner to use",
description = "Deprecated, use 'taskRunner' instead"
)
@PluginProperty
@Deprecated
protected RunnerType runner;
protected Property<RunnerType> runner;

@Schema(
title = "Deprecated, use 'taskRunner' instead"
Expand All @@ -69,9 +68,8 @@ public abstract class AbstractSoda extends Task {
private TaskRunner<?> taskRunner = Docker.instance();

@Schema(title = "The task runner container image, only used if the task runner is container-based.")
@PluginProperty(dynamic = true)
@Builder.Default
private String containerImage = DEFAULT_IMAGE;
private Property<String> containerImage = Property.of(DEFAULT_IMAGE);

@Schema(title = "Deprecated, use the `docker` property instead", deprecated = true)
@PluginProperty
Expand Down Expand Up @@ -99,7 +97,6 @@ public void setDockerOptions(DockerOptions dockerOptions) {
title = "List of python dependencies to add to the python execution process",
description = "Python dependencies list to setup in the virtualenv, in the same format than requirements.txt. It must at least provides dbt."
)
@NotNull
protected Property<List<String>> requirements;

@Schema(
Expand All @@ -110,15 +107,16 @@ public void setDockerOptions(DockerOptions dockerOptions) {
@Schema(
title = "The configuration file"
)
@PluginProperty(dynamic = true)
@NotNull
@NotEmpty
Map<String, Object> configuration;
Property<@NotEmpty Map<String, Object>> configuration;

protected Map<String, String> finalInputFiles(RunContext runContext, Path workingDirectory) throws IOException, IllegalVariableEvaluationException {
Map<String, String> map = this.inputFiles != null ? new HashMap<>(PluginUtilsService.transformInputFiles(runContext, this.inputFiles)) : new HashMap<>();

map.put("configuration.yml", MAPPER.writeValueAsString(runContext.render(configuration)));
var renderedConfig = runContext.render(configuration).asMap(String.class, Object.class);
if (!renderedConfig.isEmpty()) {
map.put("configuration.yml", MAPPER.writeValueAsString(renderedConfig));
}

return map;
}
Expand All @@ -127,9 +125,9 @@ public CommandsWrapper start(RunContext runContext) throws Exception {
var env = runContext.render(this.getEnv()).asMap(String.class, String.class);
CommandsWrapper commandsWrapper = new CommandsWrapper(runContext)
.withEnv(env.isEmpty() ? new HashMap<>() : env)
.withRunnerType(this.getRunner())
.withRunnerType(runContext.render(this.getRunner()).as(RunnerType.class).orElse(null))
.withTaskRunner(this.taskRunner)
.withContainerImage(this.getContainerImage())
.withContainerImage(runContext.render(this.getContainerImage()).as(String.class).orElse(null))
.withOutputFiles(List.of("result.json"))
.withDockerOptions(injectDefaults(this.getDocker()));
Path workingDirectory = commandsWrapper.getWorkingDirectory();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/kestra/plugin/soda/Scan.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public Scan.Output run(RunContext runContext) throws Exception {
.result(scanResult)
.stdOutLineCount(output.getStdOutLineCount())
.stdErrLineCount(output.getStdOutLineCount())
.configuration(runContext.render(configuration))
.configuration(runContext.render(configuration).asMap(String.class, Object.class))
.exitCode((Integer) output.getVars().get("exitCode"))
.build();
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/io/kestra/plugin/soda/ScanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void run() throws Exception {
.id("unit-test")
.type(Scan.class.getName())
.taskRunner(Docker.builder().type(Docker.class.getName()).build())
.configuration(JacksonMapper.ofYaml().readValue(
.configuration(Property.of(JacksonMapper.ofYaml().readValue(
"data_source kestra:\n" +
" type: bigquery\n" +
" connection:\n" +
Expand All @@ -43,7 +43,7 @@ void run() throws Exception {
" account_info_json: |\n" +
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
TYPE_REFERENCE
))
)))
.checks(JacksonMapper.ofYaml().readValue("checks for orderDetail:\n" +
" - row_count > 0\n" +
" - max(unitPrice):\n" +
Expand All @@ -70,7 +70,7 @@ void failed() throws Exception {
.id("unit-test")
.type(Scan.class.getName())
.taskRunner(Docker.builder().type(Docker.class.getName()).build())
.configuration(JacksonMapper.ofYaml().readValue(
.configuration(Property.of(JacksonMapper.ofYaml().readValue(
"data_source kestra:\n" +
" type: bigquery\n" +
" connection:\n" +
Expand All @@ -79,7 +79,7 @@ void failed() throws Exception {
" account_info_json: |\n" +
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
TYPE_REFERENCE
))
)))
.checks(JacksonMapper.ofYaml().readValue("checks for territory:\n" +
" - row_count > 0\n" +
" - failed rows:\n" +
Expand All @@ -104,7 +104,7 @@ void error() throws Exception {
.id("unit-test")
.type(Scan.class.getName())
.taskRunner(Docker.builder().type(Docker.class.getName()).build())
.configuration(JacksonMapper.ofYaml().readValue(
.configuration(Property.of(JacksonMapper.ofYaml().readValue(
"data_source kestra:\n" +
" type: bigquery\n" +
" connection:\n" +
Expand All @@ -113,7 +113,7 @@ void error() throws Exception {
" account_info_json: |\n" +
" " + StringUtils.replace(UtilsTest.serviceAccount(), "\n", "\n "),
TYPE_REFERENCE
))
)))
.checks(JacksonMapper.ofYaml().readValue("checks for orderDetail:\n" +
"checks for invalid_table:\n" +
" - row_count > 0",
Expand Down

0 comments on commit 75e4a58

Please sign in to comment.