10 changed files with 81 additions and 125 deletions
@@ -1,26 +0,0 @@
name: Ensure Tagged Commits on Release
on:
pull_request:
branches:
- release
jobs:
check_tag:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if base commit of PR is tagged
run: |
BASE_COMMIT=$(jq -r .pull_request.base.sha < "$GITHUB_EVENT_PATH")
TAG=$(git tag --contains $BASE_COMMIT)
if [ -z "$TAG" ]; then
echo "Base commit of PR is not tagged. PRs onto release must be tagged with the version number."
exit 1
fi
echo "Base commit of PR is tagged. Check passed."
@@ -0,0 +1,52 @@
name: Ensure Version Consistency on PR to Release
on:
pull_request:
branches:
- release
jobs:
check_version_and_tag:
runs-on: ubuntu-latest
strategy:
fail-fast: true # Terminate the job immediately if any step fails
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Necessary to fetch all tags for comparison
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install toml
- name: Extract version from pyproject.toml
run: |
echo "Extracting version from pyproject.toml"
VERSION=$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')
echo "Version in pyproject.toml is $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get tag for the PR's head commit
run: |
PR_HEAD_SHA=$(jq -r .pull_request.head.sha < "$GITHUB_EVENT_PATH")
TAG=$(git tag --contains $PR_HEAD_SHA)
echo "Tag on PR's head commit is $TAG"
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Compare version and tag
run: |
if [ -z "$TAG" ]; then
echo "Head commit of PR is not tagged. Ensure the head commit of PRs onto release is tagged with the version number."
exit 1
elif [ "$VERSION" != "$TAG" ]; then
echo "Version in pyproject.toml ($VERSION) does not match the git tag ($TAG)."
exit 1
else
echo "Version and git tag match. Check passed."
fi
-40
View File
@@ -1,40 +0,0 @@
name: Deploy static docs to Pages
on:
push:
branches: ["release"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build/html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
+14 -10
View File
@@ -8,6 +8,8 @@ on:
jobs: jobs:
publish: publish:
name: Publish to PyPI name: Publish to PyPI
strategy:
fail-fast: true # Terminate the job immediately if any step fails
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
@@ -15,19 +17,24 @@ jobs:
with: with:
fetch-depth: 0 # This fetches all history for all branches and tags fetch-depth: 0 # This fetches all history for all branches and tags
- name: Check if commit is tagged - name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Validate version against tag
run: | run: |
VERSION=$(python -c 'import toml; print(toml.load("pyproject.toml")["project"]["version"])')
TAG=$(git tag --contains HEAD) TAG=$(git tag --contains HEAD)
if [ -z "$TAG" ]; then if [ -z "$TAG" ]; then
echo "Commit is not tagged. Failing the workflow." echo "Commit is not tagged. Failing the workflow."
exit 1 exit 1
fi fi
echo "Commit is tagged. Proceeding with the workflow." if [ "$VERSION" != "$TAG" ]; then
echo "Version in pyproject.toml ($VERSION) does not match the git tag ($TAG). Failing the workflow."
- name: Set up Python exit 1
uses: actions/setup-python@v4 fi
with: echo "Version and commit tag match. Proceeding with the workflow."
python-version: "3.x"
- name: Install pypa/build/setuptools/twine - name: Install pypa/build/setuptools/twine
run: >- run: >-
@@ -36,9 +43,6 @@ jobs:
build setuptools twine build setuptools twine
--user --user
- name: Prevent fallback onto setup.py
run: rm setup.py
- name: Build a binary wheel and a source tarball - name: Build a binary wheel and a source tarball
run: python3 -m build run: python3 -m build
-32
View File
@@ -1,32 +0,0 @@
name: Run pytest
on:
push:
branches:
# - master
- release
pull_request:
branches:
# - master
- release
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install package dependencies
run: pip install .[testing]
- name: Install Metaworld
run: pip install metaworld@git+https://github.com/Farama-Foundation/Metaworld.git@d155d0051630bb365ea6a824e02c66c068947439#egg=metaworld
- name: Run pytest
run: pytest
+6 -2
View File
@@ -1,13 +1,17 @@
# This conf.py is in large parts inspired by the oen used by stable-baselines 3 # This conf.py is in large parts inspired by the oen used by stable-baselines 3
import toml
import datetime import datetime
project = 'Fancy Gym' project = 'Fancy Gym'
author = 'Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou' author = 'Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou'
copyright = f'2020-{datetime.date.today().year}, {author}' copyright = f'2020-{datetime.date.today().year}, {author}'
release = '0.2' # The full version, including alpha/beta/rc tags pyproject_content = toml.load("../../pyproject.toml")
version = '0.2' # The short X.Y version proj_version = pyproject_content["project"]["version"]
release = proj_version # The full version, including alpha/beta/rc tags
version = proj_version # The short X.Y version
extensions = [ extensions = [
'myst_parser', 'myst_parser',
+2 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "fancy_gym" name = "fancy_gym"
version = "0.1.4" version = "0.3.0"
description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches." description = "Fancy Gym: Unifying interface for various RL benchmarks with support for Black Box approaches."
readme = "README.md" readme = "README.md"
authors = [ authors = [
@@ -26,6 +26,7 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"toml",
"mp_pytorch<=0.1.3", "mp_pytorch<=0.1.3",
"mujoco==2.3.3", "mujoco==2.3.3",
"gymnasium[mujoco]>=0.26.0" "gymnasium[mujoco]>=0.26.0"
+6 -1
View File
@@ -1,5 +1,6 @@
# We still provide a setup.py for backwards compatability. # We still provide a setup.py for backwards compatability.
# But the pyproject.toml should be prefered. # But the pyproject.toml should be prefered.
import toml
import itertools import itertools
from pathlib import Path from pathlib import Path
from typing import List from typing import List
@@ -8,6 +9,9 @@ from setuptools import setup, find_packages
print('[!] You are currently installing/building fancy_gym via setup.py. This is only provided for backwards-compatability. Please use the pyproject.toml instead.') print('[!] You are currently installing/building fancy_gym via setup.py. This is only provided for backwards-compatability. Please use the pyproject.toml instead.')
pyproject_content = toml.load("pyproject.toml")
project_version = pyproject_content["project"]["version"]
# Environment-specific dependencies for dmc and metaworld # Environment-specific dependencies for dmc and metaworld
extras = { extras = {
'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'], 'dmc': ['shimmy[dm-control]', 'Shimmy==1.0.0'],
@@ -38,7 +42,7 @@ def find_package_data(extensions_to_include: List[str]) -> List[str]:
setup( setup(
author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou', author='Fabian Otto, Onur Celik, Dominik Roth, Hongyi Zhou',
name='fancy_gym', name='fancy_gym',
version='0.1.0', version=project_version,
classifiers=[ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research', 'Intended Audience :: Science/Research',
@@ -55,6 +59,7 @@ setup(
], ],
extras_require=extras, extras_require=extras,
install_requires=[ install_requires=[
'toml',
'mp_pytorch<=0.1.3', 'mp_pytorch<=0.1.3',
'mujoco==2.3.3', 'mujoco==2.3.3',
'gymnasium[mujoco]>=0.26.0' 'gymnasium[mujoco]>=0.26.0'
-6
View File
@@ -21,21 +21,15 @@ GYM_MP_IDS = fancy_gym.ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all']
SEED = 1 SEED = 1
known_fail_functionality = ['LunarLander-v2', 'Blackjack-v1', 'CliffWalking-v0']
@pytest.mark.parametrize('env_id', GYM_IDS) @pytest.mark.parametrize('env_id', GYM_IDS)
def test_step_gym_functionality(env_id: str): def test_step_gym_functionality(env_id: str):
"""Tests that step environments run without errors using random actions.""" """Tests that step environments run without errors using random actions."""
if env_id in known_fail_functionality:
pytest.xfail(f"{env_id} is expected to fail the functionality test")
run_env(env_id) run_env(env_id)
known_fail_deteminism = ['LunarLanderContinuous-v2', 'CliffWalking-v0']
@pytest.mark.parametrize('env_id', GYM_IDS) @pytest.mark.parametrize('env_id', GYM_IDS)
def test_step_gym_determinism(env_id: str): def test_step_gym_determinism(env_id: str):
"""Tests that for step environments identical seeds produce identical trajectories.""" """Tests that for step environments identical seeds produce identical trajectories."""
if env_id in known_fail_deteminism:
pytest.xfail(f"{env_id} is expected to fail the determinism test")
run_env_determinism(env_id, SEED) run_env_determinism(env_id, SEED)
-6
View File
@@ -15,21 +15,15 @@ DMC_MP_IDS = fancy_gym.ALL_DMC_MOVEMENT_PRIMITIVE_ENVIRONMENTS['all']
SEED = 1 SEED = 1
known_fail_functionality = []
@pytest.mark.parametrize('env_id', DMC_IDS) @pytest.mark.parametrize('env_id', DMC_IDS)
def test_step_dm_control_functionality(env_id: str): def test_step_dm_control_functionality(env_id: str):
"""Tests that suite step environments run without errors using random actions.""" """Tests that suite step environments run without errors using random actions."""
if env_id in known_fail_functionality:
pytest.xfail(f"{env_id} is expected to fail the functionality test")
run_env(env_id, 5000, wrappers=[gym.wrappers.FlattenObservation]) run_env(env_id, 5000, wrappers=[gym.wrappers.FlattenObservation])
known_fail_deteminism = ['dm_control/CmuHumanoidMazeForage-v0', 'dm_control/CmuHumanoidHeterogeneousForage-v0', 'dm_control/RodentMazeForage-v0', 'dm_control/RodentTwoTouch-v0']
@pytest.mark.parametrize('env_id', DMC_IDS) @pytest.mark.parametrize('env_id', DMC_IDS)
def test_step_dm_control_determinism(env_id: str): def test_step_dm_control_determinism(env_id: str):
"""Tests that for step environments identical seeds produce identical trajectories.""" """Tests that for step environments identical seeds produce identical trajectories."""
if env_id in known_fail_deteminism:
pytest.xfail(f"{env_id} is expected to fail the determinism test")
run_env_determinism(env_id, SEED, 5000, wrappers=[gym.wrappers.FlattenObservation]) run_env_determinism(env_id, SEED, 5000, wrappers=[gym.wrappers.FlattenObservation])