Hi streamlit developer community, hope you’re doing great.
I wanted to build an application that streams the output training ( I.e generated by the PyTorch trainer ) shown in the container but with limited number of lines at specific time.
I have written the function that stores the output lines in the deque and then flushes them after the given number of logged lines
def stream_output(command: str, maxlen: int) -> None:
"""
Streams the output of docker commands linewise for an executed runtime command.
Args:
command: The docker command to stream the output.
maxlen: number of lines to be displayed at a time in the output.
"""
output = deque(maxlen=maxlen)
try:
with Popen(command,stdout=PIPE,stderr=PIPE,shell=True) as process:
while len(output) < maxlen:
line = process.stdout.readline()
if not line:
break
line = line.decode("utf-8")
st.write(line)
output.clean()
process.wait()
if process.returncode != 0:
raise Exception(f"Command failed: {command}")
except Exception as ex:
print(f"Exception occurred while streaming output: {ex}")
but issue is that st.write()
creates every time a new container and I am not able to get output refreshed in the given container . so can anyone give me the reference regarding how to build this component (with some examples), that will be great . thanks.