Skip to content

Commit b120611

Browse files
authored
Wrap setup code in helpers for remote logging (#264)
* add util * fix
1 parent cc7b4fa commit b120611

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

eval_protocol/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from .pytest.parameterize import DefaultParameterIdGenerator
3535
from .log_utils.elasticsearch_direct_http_handler import ElasticsearchDirectHttpHandler
3636
from .log_utils.rollout_id_filter import RolloutIdFilter
37+
from .log_utils.util import setup_rollout_logging_for_elasticsearch_handler
3738

3839
from .types.remote_rollout_processor import (
3940
InitRequest,
@@ -68,6 +69,7 @@
6869
__all__ = [
6970
"ElasticsearchDirectHttpHandler",
7071
"RolloutIdFilter",
72+
"setup_rollout_logging_for_elasticsearch_handler",
7173
"DataLoaderConfig",
7274
"Status",
7375
"RemoteRolloutProcessor",

eval_protocol/log_utils/util.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
from eval_protocol.types.remote_rollout_processor import ElasticsearchConfig
3+
from .elasticsearch_direct_http_handler import ElasticsearchDirectHttpHandler
4+
5+
6+
def setup_rollout_logging_for_elasticsearch_handler(
7+
handler: ElasticsearchDirectHttpHandler, rollout_id: str, elastic_search_config: ElasticsearchConfig
8+
) -> None:
9+
"""
10+
Whenever a new subprocess is created, we need to setup the rollout context
11+
for the subprocess. This is useful when implementing your own remote server
12+
for rollout processing.
13+
14+
1. Set the EP_ROLLOUT_ID environment variable
15+
2. Configure the Elasticsearch handler with the Elasticsearch config
16+
"""
17+
18+
# this should only affect this subprocess so logs from this subprocess can
19+
# be correlated to the rollout
20+
os.environ["EP_ROLLOUT_ID"] = rollout_id
21+
22+
handler.configure(elasticsearch_config=elastic_search_config)

0 commit comments

Comments
 (0)