Skip to content

Commit

Permalink
[core] Add an example for RAY_DEDUP_LOGS_SKIP_REGEX (#47913)
Browse files Browse the repository at this point in the history
Signed-off-by: kaihsun <kaihsun@anyscale.com>
  • Loading branch information
kevin85421 authored Oct 16, 2024
1 parent c8dae96 commit 84fde99
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .vale/styles/config/vocabularies/General/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ GKE
namespace
ARM
breakpoint
deduplicate[s]
deduplication
61 changes: 53 additions & 8 deletions doc/source/ray-observability/user-guides/configure-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ System logs may include information about your applications. For example, ``runt
This is the log file of the agent containing logs of create or delete requests and cache hits and misses.
For the logs of the actual installations (for example, ``pip install`` logs), see the ``runtime_env_setup-[job_id].log`` file (see below).
- ``runtime_env_setup-ray_client_server_[port].log``: Logs from installing {ref}`Runtime Environments <runtime-environments>` for a job when connecting with {ref}`Ray Client <ray-client-ref>`.
- ``runtime_env_setup-[job_id].log``: Logs from installing {ref}`Runtime Environments <runtime-environments>` for a Task, Actor or Job. This file is only present if a Runtime Environment is installed.
- ``runtime_env_setup-[job_id].log``: Logs from installing {ref}`runtime environments <runtime-environments>` for a Task, Actor, or Job. This file is only present if you install a runtime environment.


(log-redirection-to-driver)=
Expand Down Expand Up @@ -136,13 +136,58 @@ The output is as follows:
(task pid=534174) Hello there, I am a task 0.17536720316370757 [repeated 99x across cluster] (Ray deduplicates logs by default. Set RAY_DEDUP_LOGS=0 to disable log deduplication)
```

This feature is especially useful when importing libraries such as `tensorflow` or `numpy`, which may emit many verbose warning messages when imported. Configure this feature as follows:

1. Set ``RAY_DEDUP_LOGS=0`` to disable this feature entirely.
2. Set ``RAY_DEDUP_LOGS_AGG_WINDOW_S=<int>`` to change the agggregation window.
3. Set ``RAY_DEDUP_LOGS_ALLOW_REGEX=<string>`` to specify log messages to never deduplicate.
4. Set ``RAY_DEDUP_LOGS_SKIP_REGEX=<string>`` to specify log messages to skip printing.

This feature is useful when importing libraries such as `tensorflow` or `numpy`, which may emit many verbose warning messages when you import them.

Configure the following environment variables on the driver process **before importing Ray** to customize log deduplication:

* Set ``RAY_DEDUP_LOGS=0`` to turn off this feature entirely.
* Set ``RAY_DEDUP_LOGS_AGG_WINDOW_S=<int>`` to change the aggregation window.
* Set ``RAY_DEDUP_LOGS_ALLOW_REGEX=<string>`` to specify log messages to never deduplicate.
* Example:
```python
import os
os.environ["RAY_DEDUP_LOGS_ALLOW_REGEX"] = "ABC"

import ray

@ray.remote
def f():
print("ABC")
print("DEF")

ray.init()
ray.get([f.remote() for _ in range(5)])

# 2024-10-10 17:54:19,095 INFO worker.py:1614 -- Connecting to existing Ray cluster at address: 172.31.13.10:6379...
# 2024-10-10 17:54:19,102 INFO worker.py:1790 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
# (f pid=1574323) ABC
# (f pid=1574323) DEF
# (f pid=1574321) ABC
# (f pid=1574318) ABC
# (f pid=1574320) ABC
# (f pid=1574322) ABC
# (f pid=1574322) DEF [repeated 4x across cluster] (Ray deduplicates logs by default. Set RAY_DEDUP_LOGS=0 to disable log deduplication, or see https://docs.ray.io/en/master/ray-observability/user-guides/configure-logging.html#log-deduplication for more options.)
```
* Set ``RAY_DEDUP_LOGS_SKIP_REGEX=<string>`` to specify log messages to skip printing.
* Example:
```python
import os
os.environ["RAY_DEDUP_LOGS_SKIP_REGEX"] = "ABC"

import ray

@ray.remote
def f():
print("ABC")
print("DEF")

ray.init()
ray.get([f.remote() for _ in range(5)])
# 2024-10-10 17:55:05,308 INFO worker.py:1614 -- Connecting to existing Ray cluster at address: 172.31.13.10:6379...
# 2024-10-10 17:55:05,314 INFO worker.py:1790 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
# (f pid=1574317) DEF
# (f pid=1575229) DEF [repeated 4x across cluster] (Ray deduplicates logs by default. Set RAY_DEDUP_LOGS=0 to disable log deduplication, or see https://docs.ray.io/en/master/ray-observability/user-guides/configure-logging.html#log-deduplication for more options.)
```


## Distributed progress bars (tqdm)
Expand Down

0 comments on commit 84fde99

Please sign in to comment.