Skip to content

Commit

Permalink
Merge pull request #8 from huggingface/user/aliberts/2024_05_03_publi…
Browse files Browse the repository at this point in the history
…sh_v0.1.0

Publish v0.1.0
  • Loading branch information
aliberts authored May 3, 2024
2 parents e0684ff + 7b24d99 commit d1d21c8
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 160 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/publish.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Quality

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

env:
PYTHON_VERSION: "3.10"

jobs:
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Get Ruff Version from pre-commit-config.yaml
id: get-ruff-version
run: |
RUFF_VERSION=$(awk '/repo: https:\/\/github.com\/astral-sh\/ruff-pre-commit/{flag=1;next}/rev:/{if(flag){print $2;exit}}' .pre-commit-config.yaml)
echo "RUFF_VERSION=${RUFF_VERSION}" >> $GITHUB_ENV
- name: Install Ruff
run: python -m pip install "ruff==${{ env.RUFF_VERSION }}"

- name: Ruff check
run: ruff check

- name: Ruff format
run: ruff format --diff


poetry_check:
name: Poetry check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Poetry check
run: poetry check
118 changes: 31 additions & 87 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,50 @@ on:
pull_request:
branches:
- main
paths:
- "gym_pusht/**"
- "tests/**"
- "examples.py"
- ".github/**"
- "poetry.lock"
push:
branches:
- main
paths:
- "gym_pusht/**"
- "tests/**"
- "examples.py"
- ".github/**"
- "poetry.lock"

jobs:
tests:
pytest:
name: Pytest
runs-on: ubuntu-latest
env:
POETRY_VERSION: 1.8.2
DATA_DIR: tests/data
MUJOCO_GL: egl
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
with:
lfs: true
- uses: actions/checkout@v4

- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'

#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Load cached Poetry installation
id: restore-poetry-cache
uses: actions/cache/restore@v3
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}

- name: Install Poetry
if: steps.restore-poetry-cache.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
installer-parallel: true

- name: Save cached Poetry installation
if: |
steps.restore-poetry-cache.outputs.cache-hit != 'true' &&
github.ref_name == 'main'
id: save-poetry-cache
uses: actions/cache/save@v3
with:
path: ~/.local
key: poetry-${{ env.POETRY_VERSION }}
- name: Install EGL
run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

#----------------------------------------------
# install dependencies
#----------------------------------------------
- name: Load cached venv
id: restore-dependencies-cache
uses: actions/cache/restore@v3
with:
path: .venv
key: venv-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.restore-dependencies-cache.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --without dev
- name: Install poetry
run: |
pipx install poetry && poetry config virtualenvs.in-project true
echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
- name: Save cached venv
if: |
steps.restore-dependencies-cache.outputs.cache-hit != 'true' &&
github.ref_name == 'main'
id: save-dependencies-cache
uses: actions/cache/save@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
path: .venv
key: venv-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}

# - name: Install libegl1-mesa-dev (to use MUJOCO_GL=egl)
# run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev
python-version: "3.10"
cache: "poetry"

#----------------------------------------------
# install project
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction --without dev

#----------------------------------------------
# run tests & coverage
#----------------------------------------------
- name: Run tests
- name: Install poetry dependencies
run: |
source .venv/bin/activate
pytest --cov=./gym_pusht --cov-report=xml tests
poetry install --all-extras
# TODO(aliberts): Link with HF Codecov account
# - name: Upload coverage reports to Codecov with GitHub Action
# uses: codecov/codecov-action@v4
# with:
# files: ./coverage.xml
# verbose: true
- name: Test with pytest
run: |
pytest tests -v --cov=./gym_pusht --durations=0
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.4.2
hooks:
- id: ruff
args: [--fix]
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,21 @@ The episode terminates when the block is at least 95% in the goal zone.
<TimeLimit<OrderEnforcing<PassiveEnvChecker<PushTEnv<gym_pusht/PushT-v0>>>>>
```

* `obs_type`: (str) The observation type. Can be either `state` or `pixels`. Default is `state`.
* `obs_type`: (str) The observation type. Can be either `state`, `pixels` or `pixels_agent_pos`. Default is `state`.

* `block_cog`: (tuple) The center of gravity of the block if different from the center of mass. Default is `None`.

* `damping`: (float) The damping factor of the environment if different from 0. Default is `None`.

* `render_action`: (bool) Whether to render the action on the image. Default is `True`.
* `render_mode`: (str) The rendering mode. Can be either `human` or `rgb_array`. Default is `rgb_array`.

* `render_size`: (int) The size of the rendered image. Default is `96`.
* `observation_width`: (int) The width of the observed image. Default is `96`.

* `render_mode`: (str) The rendering mode. Can be either `human` or `rgb_array`. Default is `None`.
* `observation_height`: (int) The height of the observed image. Default is `96`.

* `visualization_width`: (int) The width of the visualized image. Default is `680`.

* `visualization_height`: (int) The height of the visualized image. Default is `680`.

### Reset Arguments

Expand Down Expand Up @@ -132,14 +136,7 @@ If you don't have it already, follow the [instructions](https://python-poetry.or

Install the project with dev dependencies:
```bash
poetry install --with dev
```

### Add dependencies

The equivalent of `pip install some-package` would just be:
```bash
poetry add some-package
poetry install --all-extras
```

### Follow our style
Expand Down
2 changes: 1 addition & 1 deletion gym_pusht/envs/pusht.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PushTEnv(gym.Env):
<TimeLimit<OrderEnforcing<PassiveEnvChecker<PushTEnv<gym_pusht/PushT-v0>>>>>
```
* `obs_type`: (str) The observation type. Can be either `state` or `pixels`. Default is `state`.
* `obs_type`: (str) The observation type. Can be either `state`, `pixels` or `pixels_agent_pos`. Default is `state`.
* `block_cog`: (tuple) The center of gravity of the block if different from the center of mass. Default is `None`.
Expand Down
Loading

0 comments on commit d1d21c8

Please sign in to comment.