[diffusion] chore: minor improvements and typo-fixing (#15556)
This commit is contained in:
@@ -99,7 +99,7 @@ def run_pytest(files, filter_expr=None):
|
||||
print("No files to run.")
|
||||
return 0
|
||||
|
||||
base_cmd = [sys.executable, "-m", "pytest", "-s", "-v", "--log-cli-level=INFO"]
|
||||
base_cmd = [sys.executable, "-m", "pytest", "-s", "-v"]
|
||||
|
||||
# Add pytest -k filter if provided
|
||||
if filter_expr:
|
||||
@@ -124,20 +124,20 @@ def run_pytest(files, filter_expr=None):
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
bufsize=1,
|
||||
bufsize=0,
|
||||
)
|
||||
|
||||
output_lines = []
|
||||
output_bytes = bytearray()
|
||||
while True:
|
||||
line = process.stdout.readline()
|
||||
if not line and process.poll() is not None:
|
||||
chunk = process.stdout.read(4096)
|
||||
if not chunk:
|
||||
break
|
||||
if line:
|
||||
sys.stdout.write(line)
|
||||
output_lines.append(line)
|
||||
sys.stdout.buffer.write(chunk)
|
||||
sys.stdout.buffer.flush()
|
||||
output_bytes.extend(chunk)
|
||||
|
||||
returncode = process.poll()
|
||||
process.wait()
|
||||
returncode = process.returncode
|
||||
|
||||
if returncode == 0:
|
||||
return 0
|
||||
@@ -152,7 +152,7 @@ def run_pytest(files, filter_expr=None):
|
||||
return 0
|
||||
|
||||
# check if the failure is due to an assertion in test_server_utils.py
|
||||
full_output = "".join(output_lines)
|
||||
full_output = output_bytes.decode("utf-8", errors="replace")
|
||||
is_perf_assertion = (
|
||||
"multimodal_gen/test/server/test_server_utils.py" in full_output
|
||||
and "AssertionError" in full_output
|
||||
|
||||
@@ -322,6 +322,7 @@ class ServerManager:
|
||||
with pipe:
|
||||
for line in iter(pipe.readline, ""):
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
file.write(line)
|
||||
file.flush()
|
||||
except Exception as e:
|
||||
@@ -360,6 +361,8 @@ class ServerManager:
|
||||
"""Wait for server to become ready."""
|
||||
start = time.time()
|
||||
ready_message = "Application startup complete."
|
||||
log_period = 30
|
||||
prev_log_period_count = 0
|
||||
|
||||
while time.time() - start < self.wait_deadline:
|
||||
if process.poll() is not None:
|
||||
@@ -378,8 +381,10 @@ class ServerManager:
|
||||
logger.debug("Could not read log yet: %s", e)
|
||||
|
||||
elapsed = int(time.time() - start)
|
||||
logger.info("[server-test] Waiting for server... elapsed=%ss", elapsed)
|
||||
time.sleep(5)
|
||||
if (elapsed // log_period) > prev_log_period_count:
|
||||
prev_log_period_count = elapsed // log_period
|
||||
logger.info("[server-test] Waiting for server... elapsed=%ss", elapsed)
|
||||
time.sleep(1)
|
||||
|
||||
tail = self._get_log_tail(stdout_path)
|
||||
raise TimeoutError(f"Server not ready within {self.wait_deadline}s.\n{tail}")
|
||||
|
||||
Reference in New Issue
Block a user