diff --git a/.azure/pipelines/linux-template.yml b/.azure/pipelines/linux-template.yml deleted file mode 100644 index 0e8f256d..00000000 --- a/.azure/pipelines/linux-template.yml +++ /dev/null @@ -1,46 +0,0 @@ -jobs: - - ${{ each vmImage in parameters.vmImages }}: - - ${{ each pythonVersion in parameters.pythonVersions }}: - - job: - displayName: ${{ format('OS:{0} PY:{1}', vmImage, pythonVersion) }} - pool: - vmImage: ${{ vmImage }} - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '${{ pythonVersion }}' - - - script: | - sudo apt update && sudo apt install -y --no-install-recommends graphviz - displayName: 'Install dependencies' - - - script: | - pip install --pre "textworld[full]" - condition: eq(variables.installFromSource, false) - displayName: 'Install a prerelease of TextWorld from PyPi' - - - script: | - setup.sh - pip install -r requirements-full.txt - pip install -e . - condition: eq(variables.installFromSource, true) - displayName: 'Install TextWorld from source' - - - script: | - pip install pytest pytest-azurepipelines pytest-cov - pytest --durations=10 --junitxml=junit/test-results.xml --cov=textworld --cov-report=xml --cov-report=html tests/ textworld/ - displayName: 'Run tests' - - - script: | - pip install codecov - for i in {1..5}; do codecov --required && break || sleep 30; done - env: - CODECOV_TOKEN: $(TEXTWORLD_CODECOV_TOKEN) - displayName: 'Publish coverage on Codecov' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' diff --git a/.azure/pipelines/macos-template.yml b/.azure/pipelines/macos-template.yml deleted file mode 100644 index 0a3903ca..00000000 --- a/.azure/pipelines/macos-template.yml +++ /dev/null @@ -1,39 +0,0 @@ -jobs: - - ${{ each vmImage in parameters.vmImages }}: - - ${{ each pythonVersion in parameters.pythonVersions }}: - - job: - displayName: ${{ format('OS:{0} PY:{1}', vmImage, pythonVersion) }} - pool: - vmImage: ${{ vmImage }} - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '${{ pythonVersion }}' - - - script: | - brew install graphviz - displayName: 'Install dependencies' - - - script: | - pip install --pre --use-pep517 textworld[full] - condition: eq(variables.installFromSource, false) - displayName: 'Install a prerelease of TextWorld from PyPi' - - - script: | - setup.sh - pip install -r requirements-full.txt - pip install -e . - condition: eq(variables.installFromSource, true) - displayName: 'Install TextWorld from source' - - - script: | - pip install pytest pytest-azurepipelines pytest-cov - pytest --junitxml=junit/test-results.xml --cov=textworld --cov-report=xml --cov-report=html tests/ textworld/ - displayName: 'Run tests' - - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml' - reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov' diff --git a/.azure/pipelines/prerelease.yml b/.azure/pipelines/prerelease.yml deleted file mode 100644 index d37c67a5..00000000 --- a/.azure/pipelines/prerelease.yml +++ /dev/null @@ -1,52 +0,0 @@ -# Release code in the main branch to PyPi as a release candidate - -stages: -- stage: Prerelease_on_PyPi - jobs: - - job: - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python' - - - script: | - pip install twine - - # Build the python distribution from source - - script: | - pip install -r requirements.txt - TEXTWORLD_PRERELEASE=true ./tools/package.sh - - - task: TwineAuthenticate@1 - displayName: 'Twine Authenticate' - inputs: - pythonUploadServiceConnection: pypi - - # Use command line script to 'twine upload', use -r to pass the repository name and --config-file to pass the environment variable set by the authenticate task. - - script: | - python -m twine upload -r pypi --config-file $(PYPIRC_PATH) dist/textworld-* - -- stage: Test_library - variables: - - name: installFromSource - value: false - readonly: true - jobs: - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-20.04' ] - pythonVersions: [ '3.9' ] - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-latest' ] - pythonVersions: [ '3.12' ] - - template: macos-template.yml - parameters: - vmImages: [ 'macOS-11' ] - pythonVersions: [ '3.9' ] - - template: macos-template.yml - parameters: - vmImages: [ 'macOS-latest' ] - pythonVersions: [ '3.12' ] \ No newline at end of file diff --git a/.azure/pipelines/release.yml b/.azure/pipelines/release.yml deleted file mode 100644 index 67d56b8a..00000000 --- a/.azure/pipelines/release.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Release code in the main branch to PyPi - -jobs: -- job: - displayName: Release_on_PyPi - pool: - vmImage: 'ubuntu-latest' - - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python' - - - script: | - pip install twine - - # Build the python distribution from source - - script: | - pip install -r requirements.txt - ./tools/package.sh - - - task: TwineAuthenticate@1 - displayName: 'Twine Authenticate' - inputs: - pythonUploadServiceConnection: pypi - - # Use command line script to 'twine upload', use -r to pass the repository name and --config-file to pass the environment variable set by the authenticate task. - - script: | - python -m twine upload -r pypi --config-file $(PYPIRC_PATH) dist/textworld-* diff --git a/.azure/pipelines/security.yml b/.azure/pipelines/security.yml deleted file mode 100644 index 6f9bf848..00000000 --- a/.azure/pipelines/security.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Run the Component Governance Detection task - -trigger: -- main - -pool: - vmImage: 'ubuntu-latest' - -steps: -- task: ComponentGovernanceComponentDetection@0 - inputs: - scanType: 'Register' - verbosity: 'Verbose' - alertWarningLevel: 'High' - failOnAlert: true \ No newline at end of file diff --git a/.azure/pipelines/tests.yml b/.azure/pipelines/tests.yml deleted file mode 100644 index 27bfce45..00000000 --- a/.azure/pipelines/tests.yml +++ /dev/null @@ -1,34 +0,0 @@ -trigger: -- main - -stages: -- stage: Test - variables: - - name: installFromSource - value: true - readonly: true - jobs: - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-latest' ] - pythonVersions: [ '3.9' ] - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-latest' ] - pythonVersions: [ '3.10' ] - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-latest' ] - pythonVersions: [ '3.11' ] - - template: linux-template.yml - parameters: - vmImages: [ 'ubuntu-latest' ] - pythonVersions: [ '3.12' ] - - template: macos-template.yml - parameters: - vmImages: [ 'macOS-latest' ] - pythonVersions: [ '3.9' ] - - template: macos-template.yml - parameters: - vmImages: [ 'macOS-latest' ] - pythonVersions: [ '3.12' ] diff --git a/.github/workflows/pep8.yml b/.github/workflows/pep8.yml index f6fd2989..f2dac956 100644 --- a/.github/workflows/pep8.yml +++ b/.github/workflows/pep8.yml @@ -4,11 +4,11 @@ jobs: run: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - name: Setup Python 3.7 - uses: actions/setup-python@master + - uses: actions/checkout@v5 + - name: Setup Python + uses: actions/setup-python@v5 with: - version: 3.7 + python-version: '3.12' - name: flake8 run: | pip install flake8 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5635c88f..7dd7338a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,10 +2,6 @@ name: Build and upload to PyPI on: workflow_dispatch: - pull_request: - push: - branches: - - main release: types: - published @@ -20,11 +16,6 @@ jobs: matrix: include: # Linux 64 bit manylinux2014 - - os: ubuntu-latest - python: '3.9' - cp: '39' - platform_id: manylinux_x86_64 - manylinux_image: manylinux2014 - os: ubuntu-latest python: '3.10' cp: '310' @@ -40,46 +31,64 @@ jobs: cp: '312' platform_id: manylinux_x86_64 manylinux_image: manylinux2014 + - os: ubuntu-latest + python: '3.13' + cp: '313' + platform_id: manylinux_x86_64 + manylinux_image: manylinux2014 + - os: ubuntu-latest + python: '3.14' + cp: '314' + platform_id: manylinux_x86_64 + manylinux_image: manylinux2014 # MacOS x86_64 - - os: macos-13 - python: '3.9' - cp: '39' - platform_id: macosx_x86_64 - - os: macos-13 + - os: macos-latest-large python: '3.10' cp: '310' platform_id: macosx_x86_64 - - os: macos-13 + - os: macos-latest-large python: '3.11' cp: '311' platform_id: macosx_x86_64 - - os: macos-13 + - os: macos-latest-large python: '3.12' cp: '312' platform_id: macosx_x86_64 + - os: macos-latest-large + python: '3.13' + cp: '313' + platform_id: macosx_x86_64 + - os: macos-latest-large + python: '3.14' + cp: '314' + platform_id: macosx_x86_64 # MacOS arm64 - - os: macos-14 - python: '3.9' - cp: '39' - platform_id: macosx_arm64 - - os: macos-14 + - os: macos-latest python: '3.10' cp: '310' platform_id: macosx_arm64 - - os: macos-14 + - os: macos-latest python: '3.11' cp: '311' platform_id: macosx_arm64 - - os: macos-14 + - os: macos-latest python: '3.12' cp: '312' platform_id: macosx_arm64 + - os: macos-latest + python: '3.13' + cp: '313' + platform_id: macosx_arm64 + - os: macos-latest + python: '3.14' + cp: '314' + platform_id: macosx_arm64 steps: - name: Checkout TextWorld - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Build Wheel uses: pypa/cibuildwheel@v2.22.0 @@ -127,7 +136,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/test_pypi.yml b/.github/workflows/test_pypi.yml index 517b6161..afdc0877 100644 --- a/.github/workflows/test_pypi.yml +++ b/.github/workflows/test_pypi.yml @@ -12,10 +12,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-13, macos-14] - python: ['3.9', '3.10', '3.11', '3.12', '3.13'] + os: [ubuntu-latest, macos-latest, macos-large] + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Use Python ${{ matrix.python }} uses: actions/setup-python@v5 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..a7236d35 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,38 @@ +name: "Run tests and coverage" + +on: + pull_request: + push: + branches: + - main + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, macos-latest-large] + python: ['3.10', '3.11', '3.12', '3.13', '3.14'] + steps: + - uses: actions/checkout@v5 + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies (Linux) + run: sudo apt update && sudo apt install -y --no-install-recommends graphviz + if: startsWith(matrix.os, 'ubuntu') + + - name: Install dependencies (MacOS) + run: brew install graphviz + if: startsWith(matrix.os, 'macos') + + - name: Install TextWorld from source + run: | + python -m pip install --upgrade pip + pip install -e .[dev] + - name: Run tests + run: | + pytest -n 16 --cov=textworld --cov-report=term-missing --cov-fail-under=85 tests/ textworld/ diff --git a/.gitignore b/.gitignore index c2aaddf5..91558630 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ build/* gen_games*/ experiments*/ /textworld/thirdparty/inform7-6M62 +/textworld/thirdparty/frotz gameinfo.dbg textworld_data/ Inform/ @@ -26,3 +27,5 @@ tmp/* /wheelhouse docs/build docs/src +*.code-workspace +.coverage \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4abfe4d0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + exclude: ^textworld/thirdparty/ diff --git a/docs/source/conf.py b/docs/source/conf.py index a4cac70e..a6b589e0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,9 +16,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -import os import sphinx_rtd_theme -import subprocess # -- Project information ----------------------------------------------------- diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..e869ea36 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,36 @@ +# Main dependencies +numpy>=1.14.5 +tqdm>=4.17.1 +cffi>=1.0.0 +networkx>=2 +more_itertools +tatsu==5.8.3 +hashids>=1.2.0 +jericho>=2.2.0 +mementos>=1.3.1 +termcolor + +# For advanced prompt +prompt_toolkit + +# For visualization +pybars3>=0.9.3 +flask>=1.0.2 +selenium>=3.12.0,<4.3 +greenlet>=0.4.13 +gevent>=1.3.5 +pillow>=5.1.0 +plotly>=4.0.0,<6.0.0 +pydot>=1.2.4 +psutil +matplotlib + +# For using PddlEnv (needed for ALFWorld) +fast-downward-textworld + +# For testing +pytest +pytest-asyncio +pytest-cov +pytest-xdist +pytest-timeout diff --git a/setup.py b/setup.py index cc66352e..e17f018e 100644 --- a/setup.py +++ b/setup.py @@ -70,5 +70,6 @@ def run(self): 'vis': open('requirements-vis.txt').readlines(), 'pddl': open('requirements-pddl.txt').readlines(), 'full': open('requirements-full.txt').readlines(), + 'dev': open('requirements-dev.txt').readlines(), } )