mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-19 22:39:03 +00:00
[rocm-libraries] ROCm/rocm-libraries#4265 (commit 0f9b3b0)
[CK Tools] Auto-enable unbuffered output for Python commands (#4265) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ck-docker exec and ck-exec now automatically detect Python commands and set PYTHONUNBUFFERED=1 to enable live output streaming. This eliminates the need to manually set the environment variable when running Python scripts that print progress updates. The detection matches python, python3, or any .py file argument. This helps in watching live terminal output when a python script is running inside the container.
This commit is contained in:
committed by
assistant-librarian[bot]
parent
b688665d79
commit
06ad66b3e4
@@ -112,6 +112,19 @@ cmd_exec() {
|
||||
local docker_flags=()
|
||||
[ -t 0 ] && [ -t 1 ] && docker_flags+=("-it")
|
||||
|
||||
# Auto-detect Python commands and enable unbuffered output for live streaming
|
||||
local is_python=false
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "python" || "$arg" == "python3" || "$arg" == *.py ]]; then
|
||||
is_python=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$is_python" = true ]; then
|
||||
docker_flags+=("-e" "PYTHONUNBUFFERED=1")
|
||||
fi
|
||||
|
||||
docker exec "${docker_flags[@]}" "${CONTAINER_NAME}" "$@"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user