Skip to content

Commit

Permalink
TRUE streaming
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Eyceoz <[email protected]>
  • Loading branch information
Maxusmusti committed Jul 10, 2024
1 parent 4f391d7 commit 07c7f63
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/instructlab/training/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ def __init__(self, output_file, *args, **kwargs):
super().__init__(
*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs
)
with open(output_file, "w") as full_log_file:
for line in self.stdout:
sys.stdout.write(line)
full_log_file.write(line)
if self.poll() is not None:
with open(output_file, "wb") as full_log_file:
while True:
byte = self.stdout.read(1)
if byte:
sys.stdout.buffer.write(byte)
sys.stdout.flush()
full_log_file.write(byte)
else:
break


Expand Down

0 comments on commit 07c7f63

Please sign in to comment.