Skip to content

Commit 5e9d480

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 db8b03c commit 5e9d480

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
@@ -750,36 +750,48 @@ def init_resources_server(): # pragma: no cover
750750

751751
config_fpath = configs_dirpath / f"{server_type_name}.yaml"
752752
with open(config_fpath, "w") as f:
753-
f.write(f"""{server_type_name}_resources_server:
753+
f.write(f"""# Resources server: implements verification and any task-specific tools/state.
754+
{server_type_name}_resources_server:
754755
{server_type}:
755756
{server_type_name}:
757+
# Module (relative to this server dir) that defines the FastAPI app.
756758
entrypoint: app.py
759+
# Task category, used by `gym list environments`. See the Domain enum for valid values.
757760
domain: other
761+
# Agent server: drives the model and talks to the resources server above.
758762
{server_type_name}_simple_agent:
759763
responses_api_agents:
760764
simple_agent:
761765
entrypoint: app.py
766+
# The resources server this agent uses for tools + verification.
762767
resources_server:
763768
type: resources_servers
764769
name: {server_type_name}_resources_server
770+
# The model the agent drives. `policy_model` is a magic name resolved at run time
771+
# from your --model-name/--model-url flags (or a model-server config).
765772
model_server:
766773
type: responses_api_models
767774
name: policy_model
775+
# One entry per dataset split. `source:` declares where the JSONL is fetched from;
776+
# `type` selects the backend (gitlab | huggingface). Omit `source` for a purely local file.
768777
datasets:
769778
- name: train
770779
type: train
771780
jsonl_fpath: resources_servers/{server_type_name}/data/train.jsonl
772781
num_repeats: 1
773-
gitlab_identifier:
782+
source:
783+
type: gitlab
774784
dataset_name: {server_type_name}
775785
version: 0.0.1
776786
artifact_fpath: train.jsonl
787+
# A license is required for train/validation splits.
777788
license: Apache 2.0
778789
- name: validation
779790
type: validation
780791
jsonl_fpath: resources_servers/{server_type_name}/data/validation.jsonl
781792
num_repeats: 1
782-
gitlab_identifier:
793+
source:
794+
type: gitlab
783795
dataset_name: {server_type_name}
784796
version: 0.0.1
785797
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
@@ -138,6 +139,23 @@ def test_init_resources_server_includes_domain(self) -> None:
138139
# This should not raise an assertion error about missing domain
139140
instance_config = ResourcesServerInstanceConfig.model_validate(full_config_dict)
140141
assert instance_config is not None
142+
143+
# The generated config carries inline field documentation (friction #7).
144+
config_text = config_file.read_text()
145+
assert "# Task category" in config_text
146+
assert "policy_model" in config_text and "magic name" in config_text
147+
148+
# The scaffold emits the canonical `source:` block, not the deprecated
149+
# `gitlab_identifier`, so a fresh server starts on the recommended schema.
150+
datasets = config_dict[f"{server_name}_simple_agent"]["responses_api_agents"]["simple_agent"][
151+
"datasets"
152+
]
153+
train = next(d for d in datasets if d["name"] == "train")
154+
assert "gitlab_identifier" not in train
155+
assert train["source"]["type"] == "gitlab"
156+
with warnings.catch_warnings():
157+
warnings.simplefilter("error", DeprecationWarning)
158+
DatasetConfig.model_validate(OmegaConf.to_container(train, resolve=True))
141159
finally:
142160
# Clean up the test server directory
143161
if server_path.exists():

0 commit comments

Comments
 (0)