Skip to content

Commit

Permalink
Merge branch 'dev' into baselines-diffusion-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneT2000 committed Feb 26, 2024
2 parents 4c6b56a + a14b416 commit 6809abe
Show file tree
Hide file tree
Showing 620 changed files with 621,993 additions and 7,205 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ videos/

# testing
.coverage*
htmlcov/
htmlcov/
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-ast
- id: check-merge-conflict
- id: check-toml
# - id: check-yaml
- id: end-of-file-fixer
files: \.py$
- id: trailing-whitespace
files: \.py$
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
exclude: 'warp_maniskill/.*|docs/.*|examples/.*'
args:
- --line-length=88
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
exclude: 'warp_maniskill/.*|docs/.*|examples/.*'
args:
- --profile=black
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
exclude: 'warp_maniskill/.*|docs/.*|examples/.*'
args:
- -r
- --in-place
- --remove-unused-variables
# - --remove-all-unused-imports
21 changes: 19 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,34 @@ pip install -e . # install MS2 locally
pip install pytest coverage stable-baselines3 # add development dependencies for testing purposes
```

Then to setup pre-commit, run

```
pre-commit install
```

## Testing

Testing is currently semi-automated and a WIP. We currently rely on coverage.py and pytest to test ManiSkill2.

After you make changes, be sure to add any necessary tests to cover any new code in the `tests/` folder and run all the tests with the following command

```
coverage run --source=mani_skill2/ -a -m pytest tests # run tests
coverage html --include=mani_skill2/**/*.py # see the test coverage results
pytest tests/ -m "not slow and gpu_sim"
pytest tests/ -m "not slow and not gpu_sim"
```

Note that we add a "not slow" argument which is to prevent testing on slow tests like download utility testing. There is also the "gpu_sim" pytest mark, which marks some tests as having to use the GPU simulation. These tests are separated as CPU simulation cannot run once GPU simulation has started and vice versa. With that in mind, any test that uses GPU simulation must add the `@pytest.mark.gpu_sim` decorator.

<!-- ```
coverage run --source=mani_skill2/ -a -m pytest tests -m "not slow" # run tests
coverage html --include=mani_skill2/**/*.py # see the test coverage results
``` -->
<!--
To skip generating a coverage report and also for easy debugging you can just run
```
pytest tests/ --pdb --pdbcls=IPython.terminal.debugger:Pdb -m "not slow"
``` -->

## Building

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Please refer to our [documentation](https://haosulab.github.io/ManiSkill2) to le
From pip:

```bash
pip install mani-skill2
# This is temporary in order to install a in-dev version of sapien 3
pip install manualtest/sapien-3.0.0.dev20240221+fa245b5-cp39-cp39-manylinux2014_x86_64.whl
```

From github:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/concepts/observation.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ For `obs_mode="pointcloud"`:
An "actor" is a fundamental object that represents a physical entity (rigid body) that can be simulated in SAPIEN (the backend of ManiSkill2). An articulated object is a collection of links interconnected by joints, and each link is also an actor. In SAPIEN, `scene.get_all_actors()` will return all the actors that are not links of articulated objects. The examples are the ground, the cube in [PickCube](./environments.md#pickcube-v0), and the YCB objects in [PickSingleYCB](./environments.md#picksingleycb-v0). `scene.get_all_articulations()` will return all the articulations. The examples are the robots, the cabinets in [OpenCabinetDoor](./environments.md#opencabinetdoor-v1), and the chairs in [PushChair](./environments.md#pushchair-v1). Below is an example of how to get actors and articulations in SAPIEN.

```python
import sapien.core as sapien
import sapien

scene: sapien.Scene = ...
actors = scene.get_all_actors() # actors excluding links
Expand Down
1 change: 1 addition & 0 deletions examples/baselines/decision-transformer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
decisiontransformer.ipynb
4 changes: 4 additions & 0 deletions examples/baselines/decision-transformer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ag2897387/maniskill2
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
32 changes: 32 additions & 0 deletions examples/baselines/decision-transformer/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Decision Transformer

This baseline is adapted from the `gym` example provided [here](https://github.com/kzl/decision-transformer/tree/master). This folder provides both a jupyter notebook version that can be run on Google Colab as well as a python script that can be used for training a model. A few environments have already been trained on and these runs can be viewed [here](https://wandb.ai/ag115115/decision-transformer).

## Run Training Using Python Script

### Using Docker

1. Pull the docker image

`docker pull ag2897387/dec_tr_mani:latest`

2. Run the training script

`docker run --rm -it --gpus all ag2897387/dec_tr_mani:latest python train.py --env LiftCube-v0 --dataset demos/v0/rigid_body/LiftCube-v0/trajectory.state.pd_ee_delta_pose.h5`

There are additional arguments that specify parameters for the model and such.

Results can also be logged to [Wandb](https://wandb.ai/) using the follow arguments.

`docker run --rm -it --gpus all ag2897387/dec_tr_mani python train.py --dataset demos/v0/rigid_body/{env_id}/trajectory.state.pd_ee_delta_pose.h5 --log_to_wandb true --wandb_key <insert_wandb_key>`

### Without Docker
1. Install dependencies
```
pip install mani_skill2
pip install -r requirements.txt
```
2. Run the training script
```
python train.py --env LiftCube-v0 --dataset demos/v0/rigid_body/LiftCube-v0/trajectory.state.pd_ee_delta_pose.h5
```
Loading

0 comments on commit 6809abe

Please sign in to comment.