Skip to content

Commit c38a5f3

Browse files
Added escape characters to translated bash_command strings.
1 parent ea69721 commit c38a5f3

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

wfcommons/wfbench/translator/airflow.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def translate(self, output_folder: pathlib.Path) -> None:
9595
def _prep_commands(self, output_folder: pathlib.Path) -> None:
9696
self.task_commands = {}
9797

98-
98+
9999

100100
for task in self.tasks.values():
101101
# input_files = [str(output_folder.joinpath(f"data/{f.file_id}")) for f in task.input_files]
@@ -117,12 +117,17 @@ def _prep_commands(self, output_folder: pathlib.Path) -> None:
117117
args.append(a)
118118

119119
command_str = " ".join([str(program)] + args)
120-
# Prepends { and } with \" (i.e. {hi} -> \"{hi\"}
121-
# command_str = re.sub(r"(\{|\})", r"\"\1", command_str)
122-
# Prepends txt filenames with absolute path
123-
# command_str = re.sub(r"([\w\-]+\.txt)",
124-
# lambda m: f"{self.input_file_directory.absolute().as_posix()}/{m.group(1)}",
125-
# command_str)
120+
121+
# Escapes all double quotes
122+
command_str = command_str.replace('"', '\\\\"')
123+
124+
# Wraps --output-files and --input-files arguments in double quotes
125+
command_str = re.sub(
126+
r'(--output-files) (\{.*\}) (--input-files) (\[.*?\])',
127+
lambda m: f'{m.group(1)} "{m.group(2)}" {m.group(3)} "{m.group(4)}"',
128+
command_str
129+
)
130+
126131
self.task_commands[task.task_id] = command_str
127132

128133

0 commit comments

Comments
 (0)