Unverified Commit 8f1ba9aa authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes docs building for the `orbit.envs` submodule (#438)

# Description

With recent upgrade to Python 3.10, the linter was forcing changing of
types to use the new syntax that uses "|" operator.

This means that the line in `base_env.py` was getting converted to this
type as well:

```python
# old
VecEnvObs = Dict[str, torch.Tensor | Dict[str, torch.Tensor]]

# new
VecEnvObs = dict[str, torch.Tensor | dict[str, torch.Tensor]]
```

Unfortunately, Pytorch does not support this type of alias yet. This
leads to errors when building the documentation. The MR reverts to the
old setting and disables `pyupgrade` linter check for that file
(currently not possible to disable the linter for a line itself).

Fixes #432

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have run all the tests with `./orbit.sh --test` and they pass
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent 71c81cbf
...@@ -35,6 +35,8 @@ repos: ...@@ -35,6 +35,8 @@ repos:
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ["--py310-plus"] args: ["--py310-plus"]
# FIXME: This is a hack because Pytorch does not like: torch.Tensor | dict aliasing
exclude: "source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/base_env.py"
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.2.6 rev: v2.2.6
hooks: hooks:
......
...@@ -232,8 +232,11 @@ class. ...@@ -232,8 +232,11 @@ class.
The ``source/standalone`` directory contains various standalone applications designed using the extensions The ``source/standalone`` directory contains various standalone applications designed using the extensions
provided by ``orbit``. These applications are written in python and are structured as follows: provided by ``orbit``. These applications are written in python and are structured as follows:
* **demo**: Contains various demo applications that showcase the core framework ``omni.isaac.orbit``. * **demos**: Contains various demo applications that showcase the core framework ``omni.isaac.orbit``.
* **environments**: Contains applications for running environments defined in ``omni.isaac.orbit_tasks`` with different agents. * **environments**: Contains applications for running environments defined in ``omni.isaac.orbit_tasks`` with different agents.
These include a random policy, zero-action policy, teleoperation or scripted state machines. These include a random policy, zero-action policy, teleoperation or scripted state machines.
* **tools**: Contains applications for using the tools provided by the framework. These include converting assets, generating
datasets, etc.
* **tutorials**: Contains step-by-step tutorials for using the APIs provided by the framework.
* **workflows**: Contains applications for using environments with various learning-based frameworks. These include different * **workflows**: Contains applications for using environments with various learning-based frameworks. These include different
reinforcement learning or imitation learning libraries. reinforcement learning or imitation learning libraries.
...@@ -8,7 +8,7 @@ from __future__ import annotations ...@@ -8,7 +8,7 @@ from __future__ import annotations
import builtins import builtins
import torch import torch
from collections.abc import Sequence from collections.abc import Sequence
from typing import Any from typing import Any, Dict
import omni.isaac.core.utils.torch as torch_utils import omni.isaac.core.utils.torch as torch_utils
...@@ -20,7 +20,7 @@ from omni.isaac.orbit.utils.timer import Timer ...@@ -20,7 +20,7 @@ from omni.isaac.orbit.utils.timer import Timer
from .base_env_cfg import BaseEnvCfg from .base_env_cfg import BaseEnvCfg
from .ui import ViewportCameraController from .ui import ViewportCameraController
VecEnvObs = dict[str, torch.Tensor | dict[str, torch.Tensor]] VecEnvObs = Dict[str, torch.Tensor | Dict[str, torch.Tensor]]
"""Observation returned by the environment. """Observation returned by the environment.
The observations are stored in a dictionary. The keys are the group to which the observations belong. The observations are stored in a dictionary. The keys are the group to which the observations belong.
......
...@@ -46,7 +46,7 @@ class RobomimicDataCollector: ...@@ -46,7 +46,7 @@ class RobomimicDataCollector:
filename: str = "test", filename: str = "test",
num_demos: int = 1, num_demos: int = 1,
flush_freq: int = 1, flush_freq: int = 1,
env_config: dict = None, env_config: dict | None = None,
): ):
"""Initializes the data collection wrapper. """Initializes the data collection wrapper.
...@@ -183,7 +183,7 @@ class RobomimicDataCollector: ...@@ -183,7 +183,7 @@ class RobomimicDataCollector:
# add data to key # add data to key
self._dataset[f"env_{i}"][sub_keys[0]].append(value[i]) self._dataset[f"env_{i}"][sub_keys[0]].append(value[i])
def flush(self, env_ids: Iterable[int] = (0)): def flush(self, env_ids: Iterable[int] = (0,)):
"""Flush the episode data based on environment indices. """Flush the episode data based on environment indices.
Args: Args:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment