[Core] Persist the Driver Console Log When Job Execution Not Through Job API #49452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Currently, when user submitting a Ray job through interactive shell or running a python script, the job's log will be output to the console and will not be persisted anywhere. This causes loss of log information in the case where the user disconnected from the console.
This PR added the logic to persist the log information at the same time, still output the log information to the console. To be specific:
RAY_DRIVER_CONSOLE_LOG_TO_FILE
will be used as a switch to the behavior. Only when (1) the env var is set to"1"
AND (2) The job is not submitted using Job API (meaning both thesys.stderr
andsys.stdout
are not redirected), will the log be persisted.console_{datetime (%Y-%m-%d_%H-%M-%S_%f)}.log
stdour
andstderr
will be redirected to the above file. At the same time, aConsoleLogTailer
will be executed in a thread to tail the console log file and output the logs to the console. The same function used in job log tailing is reused.Related issue number
Changes needed on the Ray Core side for https://github.com/anyscale/rayturbo/issues/720
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.