diff --git a/plugin-script-python/src/main/resources/kestra.py b/plugin-script-python/src/main/resources/kestra.py index e256cd4c..68860edf 100644 --- a/plugin-script-python/src/main/resources/kestra.py +++ b/plugin-script-python/src/main/resources/kestra.py @@ -22,10 +22,20 @@ def _metrics(name, type, value, tags=None): ] }) + @staticmethod + def _convert_booleans(obj): + if isinstance(obj, bool): + return str(obj) + elif isinstance(obj, dict): + return {k: Kestra._convert_booleans(v) for k, v in obj.items()} + elif isinstance(obj, list): + return [Kestra._convert_booleans(item) for item in obj] + return obj + @staticmethod def outputs(map): Kestra._send({ - "outputs": map + "outputs": Kestra._convert_booleans(map) }) @staticmethod diff --git a/plugin-script-python/src/test/java/io/kestra/core/tasks/scripts/PythonTest.java b/plugin-script-python/src/test/java/io/kestra/core/tasks/scripts/PythonTest.java index d549e157..0325e21c 100644 --- a/plugin-script-python/src/test/java/io/kestra/core/tasks/scripts/PythonTest.java +++ b/plugin-script-python/src/test/java/io/kestra/core/tasks/scripts/PythonTest.java @@ -110,7 +110,7 @@ void noVirtualEnv() throws Exception { ScriptOutput run = python.run(runContext); assertThat(run.getExitCode(), is(0)); - assertThat(run.getVars().get("ok"), is(true)); + assertThat(run.getVars().get("ok"), is("True")); } @Test @@ -244,12 +244,12 @@ void outputs() throws Exception { assertThat(run.getVars().get("test"), is("value")); assertThat(run.getVars().get("int"), is(2)); - assertThat(run.getVars().get("bool"), is(true)); + assertThat(run.getVars().get("bool"), is("True")); assertThat(run.getVars().get("float"), is(3.65)); assertThat(run.getVars().get("test"), is("value")); assertThat(run.getVars().get("int"), is(2)); - assertThat(run.getVars().get("bool"), is(true)); + assertThat(run.getVars().get("bool"), is("True")); assertThat(run.getVars().get("float"), is(3.65)); assertThat(getMetrics(runContext, "count").getValue(), is(1D)); diff --git a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java index dfaac832..64dbe4d7 100644 --- a/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java +++ b/plugin-script-python/src/test/java/io/kestra/plugin/scripts/python/ScriptTest.java @@ -287,7 +287,7 @@ void kestraLibs(RunnerType runner, DockerOptions dockerOptions) throws Exception assertThat(run.getVars().get("test"), is("value")); assertThat(run.getVars().get("int"), is(2)); - assertThat(run.getVars().get("bool"), is(true)); + assertThat(run.getVars().get("bool"), is("True")); assertThat(run.getVars().get("float"), is(3.65)); assertThat(getMetrics(runContext, "count").getValue(), is(1D));