Skip to content

Commit

Permalink
fix: put TaskRunner back to v1 to enable build
Browse files Browse the repository at this point in the history
  • Loading branch information
mgabelle committed Sep 25, 2024
1 parent a38e33a commit cedef15
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.fasterxml.jackson.annotation.JsonSetter;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.*;
import io.kestra.core.models.tasks.runners.AbstractLogConsumer;
Expand Down Expand Up @@ -85,11 +87,12 @@ public abstract class AbstractDbt extends Task implements RunnableTask<ScriptOut
If you change from the default one, be careful to also configure the entrypoint to an empty list if needed."""
)
@Builder.Default
@PluginProperty
@Valid
protected Property<TaskRunner> taskRunner = Property.of(Docker.builder()
protected TaskRunner taskRunner = Docker.builder()
.type(Docker.class.getName())
.entryPoint(Collections.emptyList())
.build());
.build();

@Schema(title = "The task runner container image, only used if the task runner is container-based.")
@Builder.Default
Expand Down Expand Up @@ -141,14 +144,14 @@ public void setDockerOptions(Property<DockerOptions> dockerOptions) {
@Override
public ScriptOutput run(RunContext runContext) throws Exception {
CommandsWrapper commandsWrapper = new CommandsWrapper(runContext)
.withEnv(this.getEnv().asMap(runContext, String.class, String.class))
.withEnv(this.getEnv() != null ? this.getEnv().asMap(runContext, String.class, String.class) : Collections.emptyMap())
.withNamespaceFiles(namespaceFiles)
.withInputFiles(inputFiles)
.withOutputFiles(outputFiles)
.withRunnerType(this.getRunner().as(runContext, RunnerType.class))
.withDockerOptions(this.getDocker().as(runContext, DockerOptions.class))
.withRunnerType(this.getRunner() != null ? this.getRunner().as(runContext, RunnerType.class) : null)
.withDockerOptions(this.getDocker() != null ? this.getDocker().as(runContext, DockerOptions.class) : null)
.withContainerImage(this.containerImage.as(runContext, String.class))
.withTaskRunner(this.taskRunner.as(runContext, TaskRunner.class))
.withTaskRunner(this.taskRunner)
.withLogConsumer(new AbstractLogConsumer() {
@Override
public void accept(String line, Boolean isStdErr) {
Expand All @@ -158,7 +161,7 @@ public void accept(String line, Boolean isStdErr) {
.withEnableOutputDirectory(true); //force output files on task runners
Path workingDirectory = commandsWrapper.getWorkingDirectory();

String profileString = profiles.as(runContext, String.class);
String profileString = profiles != null ? profiles.as(runContext, String.class) : null;
if (profileString != null && !profileString.isEmpty()) {
if (Files.exists(Path.of(".profiles/profiles.yml"))) {
runContext.logger().warn("A 'profiles.yml' file already exist in the task working directory, it will be overridden.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/kestra/plugin/dbt/cli/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public ScriptOutput run(RunContext runContext) throws Exception {
// noinspection ResultOfMethodCallIgnored
profileDir.mkdirs();

String profilesContent = profilesContent(runContext, profiles);
String profilesContent = profilesContent(runContext, profiles.as(runContext, Object.class));
FileUtils.writeStringToFile(
new File(profileDir, "profiles.yml"),
profilesContent,
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kestra/plugin/dbt/cli/BuildTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void run() throws Exception {
env.put("GOOGLE_APPLICATION_CREDENTIALS", runContext.workingDir().resolve(Path.of("sa.json")).toString());
Build task = Build.builder()
.thread((Property.of(8)))
.taskRunner(Property.of(Process.instance()))
.taskRunner(Process.instance())
.env(Property.of(env))
.build();

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void run() throws Exception {
location: US
method: service-account
priority: interactive
project: kestra-dev
project: kestra-unit-test
threads: 1
timeout_seconds: 300
type: bigquery
Expand Down

0 comments on commit cedef15

Please sign in to comment.