From f11f5bd8945c5bf81b721bc6fd190e267364d486 Mon Sep 17 00:00:00 2001 From: Ahmad Kiswani Date: Wed, 10 Dec 2025 14:12:18 -0800 Subject: [PATCH 1/2] Expose server host and port in dataset viewer CLI Signed-off-by: Ahmad Kiswani --- docs/get-started/rollout-collection.md | 16 +++++++++++++++- docs/reference/cli-commands.md | 15 ++++++++++++++- nemo_gym/dataset_viewer.py | 17 ++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/docs/get-started/rollout-collection.md b/docs/get-started/rollout-collection.md index aec586487..e5a52f51f 100644 --- a/docs/get-started/rollout-collection.md +++ b/docs/get-started/rollout-collection.md @@ -122,7 +122,21 @@ Launch the rollout viewer: ng_viewer +jsonl_fpath=results/simple_weather_rollouts.jsonl ``` -Then visit +The viewer starts on port 7860 and accepts requests only from localhost by default. Visit in your browser. + +:::{tip} +**Configuring Network Access** + +By default, the viewer accepts requests only from localhost (`server_host=127.0.0.1`). To make it accessible on your local network: + +```bash +# Accept requests from anywhere (e.g., for remote access) +ng_viewer +jsonl_fpath=results/simple_weather_rollouts.jsonl +server_host=0.0.0.0 + +# Use a custom port +ng_viewer +jsonl_fpath=results/simple_weather_rollouts.jsonl +server_port=8080 +``` +::: The viewer shows each rollout with: diff --git a/docs/reference/cli-commands.md b/docs/reference/cli-commands.md index 4aa4dc52f..73841677a 100644 --- a/docs/reference/cli-commands.md +++ b/docs/reference/cli-commands.md @@ -243,12 +243,25 @@ Launch a Gradio interface to view and explore dataset rollouts interactively. * - `jsonl_fpath` - str - Filepath to a local JSONL file to view. +* - `server_host` + - str + - Network address where the viewer accepts requests. Defaults to `"127.0.0.1"` (localhost only). Set to `"0.0.0.0"` to accept requests from anywhere. +* - `server_port` + - int + - Port where the viewer accepts requests. Defaults to `7860`. If the specified port is unavailable, Gradio will search for the next available port. ``` -**Example** +**Examples** ```bash +# Launch viewer with default settings (accessible from localhost only) ng_viewer +jsonl_fpath=weather_rollouts.jsonl + +# Accept requests from anywhere (e.g., for remote access) +ng_viewer +jsonl_fpath=weather_rollouts.jsonl +server_host=0.0.0.0 + +# Use a custom port +ng_viewer +jsonl_fpath=weather_rollouts.jsonl +server_port=8080 ``` --- diff --git a/nemo_gym/dataset_viewer.py b/nemo_gym/dataset_viewer.py index e08e85693..f820f3b7a 100644 --- a/nemo_gym/dataset_viewer.py +++ b/nemo_gym/dataset_viewer.py @@ -212,11 +212,26 @@ class JsonlDatasetViewerConfig(BaseNeMoGymCLIConfig): Examples: ```bash + # Launch viewer with default settings (accessible from localhost only) ng_viewer +jsonl_fpath=weather_rollouts.jsonl + + # Accept requests from anywhere (e.g., for remote access) + ng_viewer +jsonl_fpath=weather_rollouts.jsonl +server_host=0.0.0.0 + + # Use a custom port + ng_viewer +jsonl_fpath=weather_rollouts.jsonl +server_port=8080 ``` """ jsonl_fpath: str = Field(description="Filepath to a local jsonl file to view.") + server_host: str | None = Field( + default=None, + description='Network address where the viewer accepts requests. Defaults to "127.0.0.1" (localhost only). Set to "0.0.0.0" to accept requests from anywhere.', + ) + server_port: int | None = Field( + default=None, + description="Port where the viewer accepts requests. Defaults to 7860. If the specified port is unavailable, Gradio will search for the next available port.", + ) def get_aggregate_metrics(data: List[DatasetViewerVerifyResponse]) -> Dict[str, Any]: @@ -281,4 +296,4 @@ def select_item(value: int): def main(): # pragma: no cover config = JsonlDatasetViewerConfig.model_validate(get_global_config_dict()) demo = build_jsonl_dataset_viewer(config) - demo.launch(enable_monitoring=False) + demo.launch(server_name=config.server_host, server_port=config.server_port, enable_monitoring=False) From aa1de262b5498f55254bc15a1f81adfe21130c66 Mon Sep 17 00:00:00 2001 From: Ahmad Kiswani Date: Wed, 10 Dec 2025 14:51:00 -0800 Subject: [PATCH 2/2] fixed wording with `server_host` Signed-off-by: Ahmad Kiswani --- docs/get-started/rollout-collection.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/get-started/rollout-collection.md b/docs/get-started/rollout-collection.md index e5a52f51f..019200fb1 100644 --- a/docs/get-started/rollout-collection.md +++ b/docs/get-started/rollout-collection.md @@ -127,7 +127,7 @@ The viewer starts on port 7860 and accepts requests only from localhost by defau :::{tip} **Configuring Network Access** -By default, the viewer accepts requests only from localhost (`server_host=127.0.0.1`). To make it accessible on your local network: +By default, the viewer accepts requests only from localhost (`server_host=127.0.0.1`). To make it accessible from a different machine: ```bash # Accept requests from anywhere (e.g., for remote access)