Skip to content

Commit 9bbd7f1

Browse files
committed
feat(cli): inline field docs in generated resources-server config
Annotate the config emitted by ng_init_resources_server with inline comments explaining each non-obvious field (domain, resources_server, policy_model magic name, datasets/source), addressing friction #7 (no inline documentation in generated configs). Also modernize the scaffold to emit the canonical `source:` dataset block instead of the now-deprecated `gitlab_identifier`, so a freshly created server starts on the recommended schema. Addresses M6a (epic #1205). Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
1 parent 87ab634 commit 9bbd7f1

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

nemo_gym/cli/env.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,36 +751,48 @@ def init_resources_server(): # pragma: no cover
751751

752752
config_fpath = configs_dirpath / f"{server_type_name}.yaml"
753753
with open(config_fpath, "w") as f:
754-
f.write(f"""{server_type_name}_resources_server:
754+
f.write(f"""# Resources server: implements verification and any task-specific tools/state.
755+
{server_type_name}_resources_server:
755756
{server_type}:
756757
{server_type_name}:
758+
# Module (relative to this server dir) that defines the FastAPI app.
757759
entrypoint: app.py
760+
# Task category, used by `gym list environments`. See the Domain enum for valid values.
758761
domain: other
762+
# Agent server: drives the model and talks to the resources server above.
759763
{server_type_name}_simple_agent:
760764
responses_api_agents:
761765
simple_agent:
762766
entrypoint: app.py
767+
# The resources server this agent uses for tools + verification.
763768
resources_server:
764769
type: resources_servers
765770
name: {server_type_name}_resources_server
771+
# The model the agent drives. `policy_model` is a magic name resolved at run time
772+
# from your --model-name/--model-url flags (or a model-server config).
766773
model_server:
767774
type: responses_api_models
768775
name: policy_model
776+
# One entry per dataset split. `source:` declares where the JSONL is fetched from;
777+
# `type` selects the backend (gitlab | huggingface). Omit `source` for a purely local file.
769778
datasets:
770779
- name: train
771780
type: train
772781
jsonl_fpath: resources_servers/{server_type_name}/data/train.jsonl
773782
num_repeats: 1
774-
gitlab_identifier:
783+
source:
784+
type: gitlab
775785
dataset_name: {server_type_name}
776786
version: 0.0.1
777787
artifact_fpath: train.jsonl
788+
# A license is required for train/validation splits.
778789
license: Apache 2.0
779790
- name: validation
780791
type: validation
781792
jsonl_fpath: resources_servers/{server_type_name}/data/validation.jsonl
782793
num_repeats: 1
783-
gitlab_identifier:
794+
source:
795+
type: gitlab
784796
dataset_name: {server_type_name}
785797
version: 0.0.1
786798
artifact_fpath: validation.jsonl

tests/unit_tests/test_cli.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import shutil
1616
import sys
1717
import tomllib
18+
import warnings
1819
from importlib import import_module
1920
from io import StringIO
2021
from pathlib import Path
@@ -35,7 +36,7 @@
3536
init_resources_server,
3637
)
3738
from nemo_gym.cli.general import display_help_legacy
38-
from nemo_gym.config_types import ResourcesServerInstanceConfig
39+
from nemo_gym.config_types import DatasetConfig, ResourcesServerInstanceConfig
3940

4041

4142
# TODO: Eventually we want to add more tests to ensure that the CLI flows do not break
@@ -122,6 +123,23 @@ def test_init_resources_server_includes_domain(self) -> None:
122123
# This should not raise an assertion error about missing domain
123124
instance_config = ResourcesServerInstanceConfig.model_validate(full_config_dict)
124125
assert instance_config is not None
126+
127+
# The generated config carries inline field documentation (friction #7).
128+
config_text = config_file.read_text()
129+
assert "# Task category" in config_text
130+
assert "policy_model" in config_text and "magic name" in config_text
131+
132+
# The scaffold emits the canonical `source:` block, not the deprecated
133+
# `gitlab_identifier`, so a fresh server starts on the recommended schema.
134+
datasets = config_dict[f"{server_name}_simple_agent"]["responses_api_agents"]["simple_agent"][
135+
"datasets"
136+
]
137+
train = next(d for d in datasets if d["name"] == "train")
138+
assert "gitlab_identifier" not in train
139+
assert train["source"]["type"] == "gitlab"
140+
with warnings.catch_warnings():
141+
warnings.simplefilter("error", DeprecationWarning)
142+
DatasetConfig.model_validate(OmegaConf.to_container(train, resolve=True))
125143
finally:
126144
# Clean up the test server directory
127145
if server_path.exists():

0 commit comments

Comments
 (0)