Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nemo_gym/cli/setup_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def setup_env_command(dir_path: Path, global_config_dict: DictConfig, prefix: st

verbose_flag = "-v " if global_config_dict.get(PIP_INSTALL_VERBOSE_KEY_NAME) else ""

is_editable_install = (dir_path.resolve() / "../../pyproject.toml").exists()
# Servers sit two levels below the repo root, or three when nested (e.g. conversational_tool_use/simulation).
is_editable_install = any((dir_path.resolve() / up / "pyproject.toml").exists() for up in ("../..", "../../.."))

try:
has_pyproject_toml = (dir_path / "pyproject.toml").exists()
Expand Down
17 changes: 17 additions & 0 deletions tests/unit_tests/test_cli_setup_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ def test_uv_venv_dir_path_is_shared_with_cleanup(self, tmp_path: Path) -> None:

assert actual_path == uv_venv_dir / "first_level/second_level/.venv"

def test_nested_server_in_checkout_installs_editable(self, tmp_path: Path) -> None:
(tmp_path / "pyproject.toml").touch()
server_dir = (tmp_path / "first_level" / "second_level" / "third_level").absolute()
server_dir.mkdir(parents=True)
(server_dir / "requirements.txt").write_text("-e nemo-gym[dev] @ ../../../\n")

with patch("importlib.metadata.version") as version:
actual_command = setup_env_command(
dir_path=server_dir,
global_config_dict=self._debug_global_config_dict(tmp_path),
prefix="my server name",
)

version.assert_not_called()
assert "nemo-gym==" not in actual_command
assert "-r requirements.txt" in actual_command

@pytest.mark.parametrize("version", ["0.3.0", "0.3.0rc0", "1.0.0", "2.1.3rc1"])
def test_installs_from_pypi_when_not_editable(
self, tmp_path: Path, version: str, monkeypatch: MonkeyPatch
Expand Down
Loading