Skip to content

fix(cli): keep requested Gym extras when installing servers from PyPI - #4295

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/pypi-keep-server-extras
Oct 9, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/pypi-keep-server-extras

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

What changed

When Gym is installed from PyPI rather than a source checkout, setup_env_command builds each requirements.txt server's venv by:

  1. replacing the server's local -e nemo-gym[...] @ ../../ line with a nemo-gym==<version> requirement;
  2. installing the rest of the file unchanged.

The extras on the local line were dropped in that replacement. A new helper, _local_nemo_gym_extras(), now reads them and carries them onto the PyPI requirement. For example, -e nemo-gym[dev,sandbox] @ ../../ now installs nemo-gym[dev,sandbox]==<version>.

Servers with a pyproject.toml already keep their extras, because their second install resolves the server's own nemo-gym[...] dependency. Editable installs from a checkout are unchanged.

Why

37 servers request [sandbox] or [dev,sandbox] on that line. On PyPI installs they got neither extra, so the sandbox dependencies were missing from their venvs.

This also unblocks making Ray optional (#3669): servers that use Ray will request a [ray] extra, which has to survive PyPI installs.

Validation

  • pytest tests/unit_tests/test_cli_setup_command.py
  • New tests:
    • parsing extras from the forms Gym's requirement files use: with and without -e, ../.. and ../../, spaces, trailing comments, nemo_gym, the bare -e ../../ line, unrelated local paths, and repeated lines;
    • the PyPI install command for a server requesting [dev,sandbox]. It fails without this change;
    • every shipped requirements.txt line naming nemo-gym with ../.. is recognized, so a new format can't silently drop extras again.
  • Real uv check, run offline against hand-built wheels: a fake nemo-gym 0.3.0 whose dev and sandbox extras each pull in a marker package.
    • The old command installed nemo-gym and the server's own dependency, but neither marker package.
    • The new command installed both marker packages.
    • Installing nemo-gym[dev,sandbox] after a plain nemo-gym also installed both, which confirms the pyproject.toml path already keeps extras.
  • pre-commit run scoped to the changed files.

Rollout evidence

N/A. This changes which packages a server venv installs on PyPI-based setups. It doesn't change prompts, model requests, trajectories, verification or rewards.

Compatibility

PyPI-based setups now install the extras each server already asks for. Servers that request [sandbox] get the sandbox dependencies, which makes their venvs larger and their first install slower. Editable checkouts are unaffected.

When Gym runs from a PyPI install, a requirements.txt server's local
`nemo-gym[...] @ ../../` line is dropped and replaced with a plain
`nemo-gym==<version>` requirement. The extras on that line were lost,
so servers requesting `[sandbox]` never got the sandbox dependencies.

Read the extras from the local Gym requirement and carry them onto the
PyPI requirement. pyproject.toml servers already keep their extras,
because their second install resolves the server's own `nemo-gym[...]`
dependency.

Part of #3669: servers that use Ray will request a `[ray]` extra once
Ray is optional, which depends on this.

Signed-off-by: Ananth Subramaniam <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ananthsub
ananthsub enabled auto-merge October 9, 2026 16:44
@ananthsub
ananthsub added this pull request to the merge queue Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37961395487

Merged via the queue into main with commit b373001 Oct 9, 2026
51 of 54 checks passed
@ananthsub
ananthsub deleted the ananthsub/pypi-keep-server-extras branch October 9, 2026 17:01
ehosseiniasl pushed a commit to ehosseiniasl/Gym that referenced this pull request Oct 9, 2026
…A-NeMo#4301)

## What changed

Every server implementation that declares `ray_enabled = True` now
requests nemo-gym's `ray` extra (added in NVIDIA-NeMo#4300) in its own manifest:

| Manifest | Change | Servers |
|---|---|---|
| `requirements.txt` | `-e nemo-gym[dev,ray] @ ../../` | `code_gen`,
`evalplus`, `legal_agent_bench`, `longmt_eval`, `spider2_lite`,
`swerl_gen`, `wmt_translation`, `mini_swe_agent`, `osworld_agent`,
`stirrup_agent`, `swe_agents` |
| `requirements.txt` | `-e nemo-gym[dev,ray,sandbox] @ ../../` |
`anyterminal_agent`, `harbor_agent`, `mini_swe_agent_2` |
| `pyproject.toml` | `"nemo-gym[dev,ray]"` | `code_fim`,
`harbor_agent_general` |
| `setup.py` | `"nemo-gym[dev,ray]"` | `local_vllm_model`, `genrm_model`
|

A new audit in `tests/unit_tests/test_ray_opt_out.py` fails when a
server directory containing a class that declares `ray_enabled = True`
doesn't request the extra in any of its manifests. The FAQ's "Installing
Ray" section now describes the convention.

## Why

This is the third step of making Ray optional (NVIDIA-NeMo#3669). After NVIDIA-NeMo#4300, a
server venv gets Ray only when the server's own dependencies ask for it;
the parent's version is applied as a constraint, not installed. Once Ray
leaves nemo-gym's core dependencies, these servers need to request it
themselves, and NVIDIA-NeMo#4295 makes sure the extra survives PyPI installs.

## Validation

- `pytest tests/unit_tests/test_ray_opt_out.py`. With the manifests
reverted, the new audit lists every Ray server.
- **Resolution:** `uv pip install --dry-run` from each server's
directory resolves with Ray included, for one server per manifest
format: `code_gen` (`requirements.txt`), `anyterminal_agent`
(`requirements.txt` with `sandbox`), `code_fim` (`pyproject.toml`), and
`local_vllm_model` (`setup.py`).
- `pytest
responses_api_agents/osworld_agent/tests/test_dependency_policy.py`,
which reads that server's dependency files.
- `fern check` passes.
- `pre-commit run` scoped to the changed files.

## Rollout evidence

N/A. Ray is still a core dependency of nemo-gym, so these servers
install the same packages as before. This doesn't change prompts, model
requests, trajectories, verification or rewards.

## Compatibility

No change for any install today. External servers that use Ray should
request `nemo-gym[ray]` the same way before Ray becomes optional.

Signed-off-by: Ananth Subramaniam <[email protected]>

This branch was previously deployed

1 inactive deployment
public — ad10860b Deployed Oct 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #4866
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants