chore(lora): Add real-time log buffering fix for nohup execution

Disable Python stdout buffering to ensure logs appear in nohup.out in real-time instead of only after script completion.
This commit is contained in:
Pierre-Louis 2025-02-28 10:54:16 -05:00 committed by GitHub
parent eb73549631
commit ae0a39d1b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,7 @@
# Copyright © 2023-2024 Apple Inc.
import os
import sys
import argparse
import json
import math
@ -15,6 +17,12 @@ from mlx.utils import tree_flatten
from models import LoRALinear
# Disable output buffering to see print statements in real-time
if sys.version_info >= (3, 7):
sys.stdout.reconfigure(line_buffering=True)
else:
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
def build_parser():
parser = argparse.ArgumentParser(description="LoRA or QLoRA finetuning.")
parser.add_argument(