Repository navigation
Gym CLI refactor #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Gym CLI refactor #1630
Changes from 20 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
0b159e3
chore: move all cli functions into a single location
marta-sd 7cdcb8e
feat: add basic 'gym' command router
marta-sd cba678a
feat: add --config and --storage flags to the gym router
marta-sd 82e3505
fix: don't pass unknown --flag or -f args to hydra
marta-sd b075b92
chore: add basic tests for testing new cli
marta-sd 95ddd2f
feat: run all tests if no resource server was passed
marta-sd 0519f87
feat: add flags to eval run
marta-sd e013525
feat: add flags to dataset commands
marta-sd 6a79259
feat: add flags for other eval commands
marta-sd bed6576
feat: add flags for env commands
marta-sd 4a05371
chore: print deprecation notice for all legacy commands
marta-sd 17b79ae
chore: add tests for checking that all ng_ and nemo_gym_ commands pri…
marta-sd 6288170
feat: add --verbose flag
marta-sd 6a2cd5c
feat: allow to select relevant config through passing server name
marta-sd 16431a6
feat: add --json flag for machine-readable output (+ move diagnostics…
marta-sd 02967e0
feat: add 'did you mean?' hints for typos
marta-sd 81fca19
feat: add --search-dir for loading user configs from custom location
marta-sd ba6dc10
feat: add gym search command
marta-sd c53e912
feat: add generic deployment config and --model-checkpoint flag
marta-sd 4b97e8a
fix: unify rendundant --model-name and --model-checkpoint flags into …
marta-sd c0747bd
feat: add --benchmark flag to gym env run command
marta-sd efed901
chore: migrate docs, skills and READMEs to use new cli
marta-sd 8d72078
fix: handle ng_ commands with no registered gym command
marta-sd 26be13d
fix: add QUERY_KEY_NAME constant and make it a reserved key
marta-sd f83f70a
fix: more descriptive error message when no benchmark configs found f…
marta-sd a4c13b0
fix: add backward compatibility for import used in RL
marta-sd 628086e
Merge branch 'main' into martas/1434
marta-sd 89c2009
Merge branch 'main' into martas/1434
marta-sd dd821a1
fix: use year 2026 in SPDX header for new files
marta-sd 7549fe7
fix: rename --resource-server -> --resources-server (typo)
marta-sd 68d5fb6
fix: add backward compatible imports for moved functions
marta-sd e1f416e
chore: remove legacy display_help (is not used anywhere)
marta-sd ac9e791
chore: move cli_setup_command.py to cli submodule
marta-sd 46a8f0e
feat: add --environment flag and update commands in READMEs for envs
marta-sd 993bf7e
fix: name gym env run -> gym env start
marta-sd 534ea80
chore: polish docs
marta-sd 82a7835
Merge branch 'main' into martas/1434
marta-sd e150edd
Update nemo_gym/cli/main.py
marta-sd 4deeb4f
Merge branch 'main' into martas/1434
marta-sd e552e3a
fix: add --input-glob flag to gym eval aggregate
marta-sd 34b57f1
fix: update comment
marta-sd 7e1525f
feat: add unit tests for dispatch
marta-sd 14a790c
chore: update docstrings to point to new commands
marta-sd 2775550
feat: test if legacy commands point to real new commands
marta-sd 5067752
Merge branch 'main' into martas/1434
marta-sd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
wprazuch marked this conversation as resolved.
Resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from nemo_gym.config_types import ( | ||
| DeleteJsonlDatasetGitlabConfig, | ||
| DownloadJsonlDatasetGitlabConfig, | ||
| DownloadJsonlDatasetHuggingFaceConfig, | ||
| UploadJsonlDatasetGitlabConfig, | ||
| UploadJsonlDatasetHuggingFaceConfig, | ||
| UploadJsonlDatasetHuggingFaceMaybeDeleteConfig, | ||
| ) | ||
| from nemo_gym.dataset_orchestrator import ( | ||
| delete_jsonl_dataset_from_gitlab, | ||
| upload_jsonl_dataset_to_hf_maybe_delete, | ||
| ) | ||
| from nemo_gym.gitlab_utils import download_jsonl_dataset, upload_jsonl_dataset | ||
| from nemo_gym.global_config import GlobalConfigDictParserConfig, get_global_config_dict | ||
| from nemo_gym.hf_utils import download_hf_dataset_as_jsonl | ||
| from nemo_gym.prompt import MaterializePromptsConfig, materialize_prompts | ||
| from nemo_gym.train_data_utils import TrainDataProcessor | ||
|
|
||
|
|
||
| def upload_jsonl_dataset_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = UploadJsonlDatasetGitlabConfig.model_validate(global_config) | ||
| upload_jsonl_dataset(config) | ||
|
|
||
|
|
||
| def download_jsonl_dataset_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = DownloadJsonlDatasetGitlabConfig.model_validate(global_config) | ||
| download_jsonl_dataset(config) | ||
|
|
||
|
|
||
| def upload_jsonl_dataset_to_hf_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = UploadJsonlDatasetHuggingFaceMaybeDeleteConfig.model_validate(global_config) | ||
| upload_jsonl_dataset_to_hf_maybe_delete(config, delete_from_gitlab=config.delete_from_gitlab) | ||
|
|
||
|
|
||
| def download_jsonl_dataset_from_hf_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = DownloadJsonlDatasetHuggingFaceConfig.model_validate(global_config) | ||
|
|
||
| if config.artifact_fpath: | ||
| print(f"Downloading file '{config.artifact_fpath}' from '{config.repo_id}'...") | ||
| else: | ||
| print(f"Downloading '{config.split or 'all'}' split(s) from '{config.repo_id}'...") | ||
|
|
||
| download_hf_dataset_as_jsonl(config) | ||
|
|
||
|
|
||
| def delete_jsonl_dataset_from_gitlab_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = DeleteJsonlDatasetGitlabConfig.model_validate(global_config) | ||
| delete_jsonl_dataset_from_gitlab(config.dataset_name) | ||
|
|
||
|
|
||
| def upload_jsonl_dataset_to_hf_and_delete_gitlab_cli() -> None: # pragma: no cover | ||
| global_config = get_global_config_dict() | ||
| config = UploadJsonlDatasetHuggingFaceConfig.model_validate(global_config) | ||
| upload_jsonl_dataset_to_hf_maybe_delete(config, delete_from_gitlab=True) | ||
|
|
||
|
|
||
| def materialize_prompts_cli() -> None: # pragma: no cover | ||
| """CLI entry point for ng_materialize_prompts.""" | ||
| global_config_dict = get_global_config_dict( | ||
| global_config_dict_parser_config=GlobalConfigDictParserConfig( | ||
| initial_global_config_dict=GlobalConfigDictParserConfig.NO_MODEL_GLOBAL_CONFIG_DICT, | ||
| ) | ||
| ) | ||
| config = MaterializePromptsConfig.model_validate(global_config_dict) | ||
| materialize_prompts(config.input_jsonl_fpath, config.prompt_config, config.output_jsonl_fpath) | ||
|
|
||
|
|
||
| def prepare_data(): # pragma: no cover | ||
| global_config_dict = get_global_config_dict( | ||
| global_config_dict_parser_config=GlobalConfigDictParserConfig( | ||
| initial_global_config_dict=GlobalConfigDictParserConfig.NO_MODEL_GLOBAL_CONFIG_DICT, | ||
| ) | ||
| ) | ||
|
|
||
| data_processor = TrainDataProcessor() | ||
| data_processor.run(global_config_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from subprocess import Popen | ||
|
|
||
| from nemo_gym.config_types import BaseNeMoGymCLIConfig | ||
| from nemo_gym.global_config import get_global_config_dict | ||
|
|
||
|
|
||
| def dev_test(): # pragma: no cover | ||
| """ | ||
| Run core NeMo Gym tests with coverage reporting (runs pytest with --cov flag). | ||
|
|
||
| Examples: | ||
|
|
||
| ```bash | ||
| ng_dev_test | ||
| ``` | ||
| """ | ||
| global_config_dict = get_global_config_dict() | ||
| # Just here for help | ||
| BaseNeMoGymCLIConfig.model_validate(global_config_dict) | ||
|
|
||
| proc = Popen("pytest --cov=. --durations=10", shell=True) | ||
| exit(proc.wait()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.