Skip to content

Commit

Permalink
Remove useless string join from providers (#33968)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei Lee <[email protected]>
  • Loading branch information
hussein-awala and Lee-W committed Sep 3, 2023
1 parent cf0c824 commit 47bd5dd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/log/s3_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def s3_write(self, log: str, remote_log_location: str, append: bool = True, max_
try:
if append and self.s3_log_exists(remote_log_location):
old_log = self.s3_read(remote_log_location)
log = "\n".join([old_log, log]) if old_log else log
log = f"{old_log}\n{log}" if old_log else log
except Exception:
self.log.exception("Could not verify previous log to append")
return False
Expand Down
12 changes: 5 additions & 7 deletions airflow/providers/cncf/kubernetes/decorators/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ def _generate_cmds(self) -> list[str]:
return [
"bash",
"-cx",
" && ".join(
[
write_local_script_file_cmd,
write_local_input_file_cmd,
make_xcom_dir_cmd,
exec_python_cmd,
]
(
f"{write_local_script_file_cmd} && "
f"{write_local_input_file_cmd} && "
f"{make_xcom_dir_cmd} && "
f"{exec_python_cmd}"
),
]

Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/log/gcs_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def gcs_write(self, log, remote_log_location) -> bool:
try:
blob = storage.Blob.from_string(remote_log_location, self.client)
old_log = blob.download_as_bytes().decode()
log = "\n".join([old_log, log]) if old_log else log
log = f"{old_log}\n{log}" if old_log else log
except Exception as e:
if not self.no_log_found(e):
log += self._add_message(
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/microsoft/azure/log/wasb_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def wasb_write(self, log: str, remote_log_location: str, append: bool = True) ->
"""
if append and self.wasb_log_exists(remote_log_location):
old_log = self.wasb_read(remote_log_location)
log = "\n".join([old_log, log]) if old_log else log
log = f"{old_log}\n{log}" if old_log else log

try:
self.hook.load_string(log, self.wasb_container, remote_log_location, overwrite=True)
Expand Down

0 comments on commit 47bd5dd

Please sign in to comment.