Skip to content

Commit 5b40e95

Browse files
authored
Use unique file name for tmp tar file for patterns in git packager (#121)
Signed-off-by: Hemil Desai <[email protected]>
1 parent 7145bbc commit 5b40e95

File tree

2 files changed

+132
-216
lines changed

2 files changed

+132
-216
lines changed

src/nemo_run/core/packaging/git.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import shlex
1919
import subprocess
20+
import uuid
2021
from dataclasses import dataclass
2122
from pathlib import Path
2223

@@ -136,6 +137,8 @@ def package(self, path: Path, job_dir: str, name: str) -> str:
136137
"include_pattern and include_pattern_relative_path should have the same length"
137138
)
138139

140+
pattern_file_id = uuid.uuid4()
141+
pattern_tar_file_name = f"additional_{pattern_file_id}.tmp"
139142
for include_pattern, include_pattern_relative_path in zip(
140143
self.include_pattern, self.include_pattern_relative_path
141144
):
@@ -149,9 +152,11 @@ def package(self, path: Path, job_dir: str, name: str) -> str:
149152
)
150153
include_pattern_cmd = (
151154
f"find {relative_include_pattern} -type f | "
152-
f"tar -cf {os.path.join(git_base_path, 'additional.tmp')} -T -"
155+
f"tar -cf {os.path.join(git_base_path, pattern_tar_file_name)} -T -"
156+
)
157+
tar_concatenate_cmd = (
158+
f"cat {pattern_tar_file_name} >> {output_file}.tmp && rm {pattern_tar_file_name}"
153159
)
154-
tar_concatenate_cmd = f"cat additional.tmp >> {output_file}.tmp && rm additional.tmp"
155160

156161
with ctx.cd(include_pattern_relative_path):
157162
ctx.run(include_pattern_cmd)

0 commit comments

Comments
 (0)