Skip to content

Commit a18f996

Browse files
committed
Address 'command' referenced before assignment error in tests
1 parent e220924 commit a18f996

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

tests/test_diffusion.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,25 @@ def _write_command(self, bash_file, test_f) -> None:
118118
inference.final_step=48
119119
"""
120120
out_lines=[]
121+
command_lines = []
122+
in_command = False
121123
with open(bash_file, "r") as f:
122-
lines = f.readlines()
123-
for line in lines:
124-
if not (line.startswith("python") or line.startswith("../")):
124+
for line in f:
125+
stripped = line.strip()
126+
if stripped.startswith("python") or stripped.startswith("../"):
127+
in_command = True
128+
if in_command:
129+
# Remove trailing line continuation slashes
130+
if stripped.endswith("\\"):
131+
command_lines.append(stripped[:-1].strip())
132+
else:
133+
command_lines.append(stripped)
134+
in_command = False # End of command
135+
else:
125136
out_lines.append(line)
126-
else:
127-
command = line.strip()
128-
if not command.startswith("python"):
129-
command = f'python {command}'
137+
if not command_lines:
138+
raise ValueError(f"No valid python command found in {bash_file}")
139+
command = " ".join(command_lines)
130140
# get the partial_T
131141
if "partial_T" in command:
132142
final_step = int(command.split("partial_T=")[1].split(" ")[0]) - 2

0 commit comments

Comments
 (0)