Skip to content

Commit 04f4d16

Browse files
authored
fix: disable usage stats more forcefully since container env took precedence (#25)
Signed-off-by: Terry Kong <terryk@nvidia.com>
1 parent fc79f59 commit 04f4d16

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ RUN apt-get update && sudo apt-get install -y jq
99

1010
RUN pip install uv
1111
RUN echo "unset RAY_RUNTIME_ENV_HOOK" >> /home/ray/.bashrc
12+
# Disable usage stats by default for users who are sensitive to sharing usage.
13+
# Users are encouraged to enable if the wish.
14+
ENV RAY_USAGE_STATS_ENABLED=0
1215

1316
FROM base AS hermetic
1417
# hermetic creates a virtual environment with the default dependencies pre-installed for convenience
@@ -38,4 +41,4 @@ EOF
3841
COPY --chown=ray --chmod=755 . /opt/reinforcer
3942
RUN uv pip install --no-deps --editable /opt/reinforcer
4043

41-
FROM base
44+
FROM base

nemo_reinforcer/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from nemo_reinforcer.package_info import (
23
__contact_emails__,
34
__contact_names__,
@@ -11,3 +12,5 @@
1112
__shortversion__,
1213
__version__,
1314
)
15+
16+
os.environ["RAY_USAGE_STATS_ENABLED"] = "0"

ray.sub

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ MOUNTS=$MOUNTS
1919
COMMAND=${COMMAND:-} # This is a script relative to the SLURM_SUBMIT_DIR. If left empty, it will leave the cluster idle after it's brought up.
2020
########################################################
2121

22-
########################################################
23-
# Global settings
24-
########################################################
25-
# Disable usage stats by default so that it's opt-in
26-
export RAY_USAGE_STATS_ENABLED=${RAY_USAGE_STATS_ENABLED:-0}
27-
########################################################
28-
2922
COMMON_SRUN_ARGS=""
3023
COMMON_SRUN_ARGS+=" --export=ALL"
3124
COMMON_SRUN_ARGS+=" --no-container-mount-home"
@@ -70,6 +63,7 @@ head_cmd=$(cat <<EOF
7063
env
7164
cat <<EOFINNER | tee /launch-head.sh
7265
ray start --head \
66+
--disable-usage-stats \
7367
--num-cpus=0 \
7468
--num-gpus=0 \
7569
--node-ip-address="$head_node_ip" \
@@ -104,9 +98,11 @@ for ((i = 0; i < SLURM_JOB_NUM_NODES; i++)); do
10498
env
10599
cat <<EOFINNER | tee /launch-worker.sh
106100
ray start --address "$ip_head" \
101+
--disable-usage-stats \
107102
--resources="{\"worker_units\": $gpus_per_node}" \
108103
--min-worker-port=$min_worker_port \
109-
--max-worker-port=$max_worker_port --block
104+
--max-worker-port=$max_worker_port \
105+
--block
110106
EOFINNER
111107
112108
count=0

tests/unit/test_meta.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This module tests things outside of any package (e.g., things in the root __init__.py)
16+
17+
import pytest
18+
import os
19+
20+
21+
def test_usage_stats_disabled_by_default():
22+
import nemo_reinforcer
23+
24+
assert os.environ["RAY_USAGE_STATS_ENABLED"] == "0", (
25+
f"Our dockerfile, slurm submission script and default environment setting when importing reinforcer should all disable usage stats collection. This failing is not expected."
26+
)
27+
28+
29+
def test_usage_stats_disabled_in_tests():
30+
import tests
31+
32+
assert os.environ["RAY_USAGE_STATS_ENABLED"] == "0", (
33+
f"Our dockerfile, slurm submission script and default environment setting when importing reinforcer should all disable usage stats collection. This failing is not expected."
34+
)

0 commit comments

Comments
 (0)