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
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ OpenEnv provides a standard for interacting with agentic execution environments

In addition to making it easier for researchers and RL framework writers, we also provide tools for environment creators making it easier for them to create richer environments and make them available over familar protocols like HTTP and packaged using canonical technologies like docker. Environment creators can use the OpenEnv framework to create environments that are isolated, secure, and easy to deploy and use.

The OpenEnv CLI (`openenv`) provides commands to initialize new environments and deploy them to Hugging Face Spaces.

> ⚠️ **Early Development Warning** OpenEnv is currently in an experimental
> stage. You should expect bugs, incomplete features, and APIs that may change
> in future versions. The project welcomes bugfixes, but to make sure things are
Expand Down Expand Up @@ -117,14 +119,21 @@ Type-safe data structures:

### For Environment Creators

When building a new environment, create the following structure:
Use the CLI to quickly scaffold a new environment:

```bash
openenv init my_env
```

This creates the following structure:

```
src/envs/your_env/
my_env/
├── __init__.py # Export YourAction, YourObservation, YourEnv
├── models.py # Define Action, Observation, State dataclasses
├── client.py # Implement YourEnv(HTTPEnvClient)
├── README.md # Document your environment
├── openenv.yaml # Environment manifest
└── server/
├── your_environment.py # Implement YourEnvironment(Environment)
├── app.py # Create FastAPI app
Expand All @@ -143,6 +152,26 @@ To use an environment:

See example scripts in `examples/` directory.

## CLI Commands

The OpenEnv CLI provides commands to manage environments:

- **`openenv init <env_name>`** - Initialize a new environment from template
- **`openenv push [--repo-id <repo>] [--private]`** - Deploy environment to Hugging Face Spaces

### Quick Start

```bash
# Create a new environment
openenv init my_game_env

# Deploy to Hugging Face (will prompt for login if needed)
cd my_game_env
openenv push
```

For detailed options: `openenv init --help` and `openenv push --help`.

## Design Principles

1. **Separation of Concerns**: Clear client-server boundaries
Expand Down
26 changes: 25 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,35 @@ dependencies = [
"requests>=2.25.0",
"fastapi>=0.104.0",
"uvicorn>=0.24.0",
"smolagents>=1.22.0,<2"
"smolagents>=1.22.0,<2",
"typer>=0.9.0",
"rich>=13.0.0",
"pyyaml>=6.0",
"huggingface_hub>=0.20.0"
]

[project.scripts]
openenv = "openenv_cli.__main__:main"

[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]

[tool.coverage.run]
omit = [
"openenv_cli/templates/**",
"**/templates/**",
"openenv_cli/__main__.py",
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
10 changes: 10 additions & 0 deletions src/openenv_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""OpenEnv CLI package."""

__version__ = "0.1.0"

47 changes: 47 additions & 0 deletions src/openenv_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""
OpenEnv CLI entry point.

This module provides the main entry point for the OpenEnv command-line interface,
following the Hugging Face CLI pattern.
"""

import sys

import typer

from openenv_cli.commands import init
from openenv_cli.commands import push

# Create the main CLI app
app = typer.Typer(
name="openenv",
help="OpenEnv - An e2e framework for creating, deploying and using isolated execution environments for agentic RL training",
no_args_is_help=True,
)

# Register commands
app.command(name="init", help="Initialize a new OpenEnv environment")(init.init)
app.command(name="push", help="Push an OpenEnv environment to Hugging Face Spaces")(push.push)


# Entry point for setuptools
def main() -> None:
"""Main entry point for the CLI."""
try:
app()
except KeyboardInterrupt:
print("\nOperation cancelled by user.")
sys.exit(130)
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)


if __name__ == "__main__":
main()
13 changes: 13 additions & 0 deletions src/openenv_cli/_cli_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""CLI utilities for OpenEnv command-line interface."""

from rich.console import Console

# Create a console instance for CLI output
console = Console()

12 changes: 12 additions & 0 deletions src/openenv_cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""OpenEnv CLI commands."""

from openenv_cli.commands import init, push

__all__ = ["init", "push"]

Loading