vchiapaikeo commented on code in PR #28942:
URL: https://github.com/apache/airflow/pull/28942#discussion_r1081969377
##########
airflow/providers/cncf/kubernetes/decorators/kubernetes.py:
##########
@@ -82,11 +83,42 @@ def _get_python_source(self):
res = remove_task_decorator(res, "@task.kubernetes")
return res
+ def _generate_cmds(self) -> list[str]:
+ script_filename = "/tmp/script.py"
+ input_filename = "/tmp/script.in"
+ output_filename = "/airflow/xcom/return.json"
+
+ write_local_script_file_cmd = (
+ f"{_generate_decoded_command(quote(_PYTHON_SCRIPT_ENV),
quote(script_filename))}"
+ )
+ write_local_input_file_cmd = (
+ f"{_generate_decoded_command(quote(_PYTHON_INPUT_ENV),
quote(input_filename))}"
+ )
+ make_xcom_dir_cmd = "mkdir -p /airflow/xcom"
+ exec_python_cmd = f"python {script_filename} {input_filename}
{output_filename}"
+ return [
+ "bash",
+ "-cx",
+ " && ".join(
+ [
+ write_local_script_file_cmd,
+ write_local_input_file_cmd,
+ make_xcom_dir_cmd,
+ exec_python_cmd,
+ ]
+ ),
+ ]
+
def execute(self, context: Context):
with TemporaryDirectory(prefix="venv") as tmp_dir:
script_filename = os.path.join(tmp_dir, "script.py")
- py_source = self._get_python_source()
+ input_filename = os.path.join(tmp_dir, "script.in")
+
+ with open(input_filename, "wb") as file:
+ if self.op_args or self.op_kwargs:
+ self.pickling_library.dump({"args": self.op_args,
"kwargs": self.op_kwargs}, file)
Review Comment:
That is expected because we do need to write some file, but you're right
that the check is unnecessary. Removing and updating tests to simplify.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]