From 5ab62d14f4bb4e2c6484bc803fbde84b575e7123 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Fri, 3 May 2024 15:17:25 +0200 Subject: [PATCH 1/4] Move dev/test deps as extras --- poetry.lock | 48 ++++++++++++++++++++++++++---------------------- pyproject.toml | 20 ++++++++------------ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/poetry.lock b/poetry.lock index a293551..23857a3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "absl-py" @@ -15,7 +15,7 @@ files = [ name = "cfgv" version = "3.4.0" description = "Validate configuration and produce human readable error messages." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, @@ -37,7 +37,7 @@ files = [ name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -optional = false +optional = true python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, @@ -48,7 +48,7 @@ files = [ name = "coverage" version = "7.4.4" description = "Code coverage measurement for Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "coverage-7.4.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0be5efd5127542ef31f165de269f77560d6cdef525fffa446de6f7e9186cfb2"}, @@ -115,7 +115,7 @@ toml = ["tomli"] name = "debugpy" version = "1.8.1" description = "An implementation of the Debug Adapter Protocol for Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "debugpy-1.8.1-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:3bda0f1e943d386cc7a0e71bfa59f4137909e2ed947fb3946c506e113000f741"}, @@ -146,7 +146,7 @@ files = [ name = "distlib" version = "0.3.8" description = "Distribution utilities" -optional = false +optional = true python-versions = "*" files = [ {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, @@ -157,7 +157,7 @@ files = [ name = "exceptiongroup" version = "1.2.0" description = "Backport of PEP 654 (exception groups)" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, @@ -182,7 +182,7 @@ files = [ name = "filelock" version = "3.13.3" description = "A platform independent file lock." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "filelock-3.13.3-py3-none-any.whl", hash = "sha256:5ffa845303983e7a0b7ae17636509bc97997d58afeafa72fb141a17b152284cb"}, @@ -272,7 +272,7 @@ testing = ["Jinja2 (>=3.0.3)", "PettingZoo (>=1.23.0)", "cython (<3)", "mujoco-p name = "identify" version = "2.5.35" description = "File identification library for Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, @@ -318,7 +318,7 @@ tifffile = ["tifffile"] name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, @@ -455,7 +455,7 @@ pyopengl = "*" name = "nodeenv" version = "1.8.0" description = "Node.js virtual environment builder" -optional = false +optional = true python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" files = [ {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, @@ -514,7 +514,7 @@ files = [ name = "packaging" version = "24.0" description = "Core utilities for Python packages" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, @@ -635,7 +635,7 @@ xmp = ["defusedxml"] name = "platformdirs" version = "4.2.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, @@ -650,7 +650,7 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest- name = "pluggy" version = "1.4.0" description = "plugin and hook calling mechanisms for python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, @@ -665,7 +665,7 @@ testing = ["pytest", "pytest-benchmark"] name = "pre-commit" version = "3.7.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." -optional = false +optional = true python-versions = ">=3.9" files = [ {file = "pre_commit-3.7.0-py2.py3-none-any.whl", hash = "sha256:5eae9e10c2b5ac51577c3452ec0a490455c45a0533f7960f993a0d01e59decab"}, @@ -694,7 +694,7 @@ files = [ name = "pytest" version = "8.1.1" description = "pytest: simple powerful testing with Python" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pytest-8.1.1-py3-none-any.whl", hash = "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7"}, @@ -716,7 +716,7 @@ testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygm name = "pytest-cov" version = "5.0.0" description = "Pytest plugin for measuring coverage." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "pytest-cov-5.0.0.tar.gz", hash = "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"}, @@ -734,7 +734,7 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -793,7 +793,7 @@ files = [ name = "setuptools" version = "69.2.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "setuptools-69.2.0-py3-none-any.whl", hash = "sha256:c21c49fb1042386df081cb5d86759792ab89efca84cf114889191cd09aacc80c"}, @@ -809,7 +809,7 @@ testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jar name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, @@ -831,7 +831,7 @@ files = [ name = "virtualenv" version = "20.25.1" description = "Virtual Python Environment builder" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, @@ -847,7 +847,11 @@ platformdirs = ">=3.9.1,<5" docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] +[extras] +dev = ["debugpy", "pre-commit"] +test = ["pytest", "pytest-cov"] + [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "2951c13617f3be51d46e8c65dc60a2e1e632f6da3166e659cbd5fba6ccc763a8" +content-hash = "9088e590d88c2cfa83037e536431f2628a137d1d820a1c049254b9b13d1ae01e" diff --git a/pyproject.toml b/pyproject.toml index d95a3a8..35259b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,26 +26,22 @@ python = "^3.10" mujoco = "^2.3.7" gymnasium = "^0.29.1" gymnasium-robotics = "^1.2.4" +pre-commit = {version = "^3.7.0", optional = true} +debugpy = {version = "^1.8.1", optional = true} +pytest = {version = "^8.1.0", optional = true} +pytest-cov = {version = "^5.0.0", optional = true} -[tool.poetry.group.dev] -optional = true - - -[tool.poetry.group.dev.dependencies] -pre-commit = "^3.6.2" -debugpy = "^1.8.1" - - -[tool.poetry.group.test.dependencies] -pytest = "^8.1.0" -pytest-cov = "^5.0.0" +[tool.poetry.extras] +dev = ["pre-commit", "debugpy"] +test = ["pytest", "pytest-cov"] [tool.ruff] line-length = 110 target-version = "py310" exclude = [ + "example.py", ".bzr", ".direnv", ".eggs", From 4c95262e81f7e25feea093e81e66087203b29b22 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Fri, 3 May 2024 15:18:21 +0200 Subject: [PATCH 2/4] Update workflows --- .github/workflows/publish.yml | 18 ----- .github/workflows/quality.yml | 55 ++++++++++++++++ .github/workflows/test.yml | 119 +++++++++------------------------- 3 files changed, 87 insertions(+), 105 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/quality.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 728cf0c..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Publish - -on: - push: - tags: - - "v*.*.*" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build and publish to pypi - uses: JRubics/poetry-publish@v2.0 - with: - pypi_token: ${{ secrets.PYPI_TOKEN }} - poetry_install_options: "--without dev" diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..3b13a9a --- /dev/null +++ b/.github/workflows/quality.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 068cc50..4629013 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,105 +4,50 @@ on: pull_request: branches: - main + paths: + - "gym_xarm/**" + - "tests/**" + - "examples.py" + - ".github/**" + - "poetry.lock" push: branches: - main + paths: + - "gym_xarm/**" + - "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 - - - 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 }} + - uses: actions/checkout@v4 - - 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 EGL + run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev - - 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') }} + python-version: "3.10" + cache: "poetry" - - name: Install libegl1-mesa-dev - run: sudo apt-get update && sudo apt-get install -y libegl1-mesa-dev - - #---------------------------------------------- - # 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_xarm 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_xarm --durations=0 From add791f43c9bb280a6fd8e38a961e85a92d987b3 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Fri, 3 May 2024 15:18:47 +0200 Subject: [PATCH 3/4] pre-commit autoupdate --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb3fc90..e1bb763 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: python: python3.10 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files args: ['--maxkb=5000'] @@ -19,7 +19,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.4.2 hooks: - id: ruff args: [--fix] From 3d724e1e6958655734a6dcf2afc03c9eecf99c24 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Fri, 3 May 2024 15:34:41 +0200 Subject: [PATCH 4/4] Update readme --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 4312704..115cf90 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,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