Spatial-Gym 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spatial_gym-0.1.1/.github/workflows/publish.yml +57 -0
- spatial_gym-0.1.1/.github/workflows/tests.yml +126 -0
- spatial_gym-0.1.1/.gitignore +10 -0
- spatial_gym-0.1.1/Final_Product.py +39 -0
- spatial_gym-0.1.1/LICENCE +21 -0
- spatial_gym-0.1.1/MIGRATION_NOTES.md +86 -0
- spatial_gym-0.1.1/PKG-INFO +381 -0
- spatial_gym-0.1.1/README.md +321 -0
- spatial_gym-0.1.1/Spatial_Gym/Spatial_Gym.py +1314 -0
- spatial_gym-0.1.1/Spatial_Gym/__init__.py +12 -0
- spatial_gym-0.1.1/Spatial_Gym/register_env.py +8 -0
- spatial_gym-0.1.1/Spatial_Gym/render/__init__.py +4 -0
- spatial_gym-0.1.1/Spatial_Gym/render/human_renderer.py +451 -0
- spatial_gym-0.1.1/Spatial_Gym/render/llm_renderer.py +229 -0
- spatial_gym-0.1.1/TEST_SUMMARY.md +237 -0
- spatial_gym-0.1.1/human_play.py +64 -0
- spatial_gym-0.1.1/llm_testing/llm_host.py +267 -0
- spatial_gym-0.1.1/llm_testing/parse_logs.py +233 -0
- spatial_gym-0.1.1/pyproject.toml +64 -0
- spatial_gym-0.1.1/pytest.ini +11 -0
- spatial_gym-0.1.1/tests/README.md +147 -0
- spatial_gym-0.1.1/tests/__init__.py +3 -0
- spatial_gym-0.1.1/tests/test_environment.py +269 -0
- spatial_gym-0.1.1/tests/test_predefined_paths.py +321 -0
- spatial_gym-0.1.1/tests/test_random_agent.py +220 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Publish Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch: # Allow manual triggering
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment:
|
|
16
|
+
name: pypi
|
|
17
|
+
url: https://pypi.org/p/Spatial-Gym
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
with:
|
|
22
|
+
fetch-depth: 0
|
|
23
|
+
|
|
24
|
+
- name: Check Git Version
|
|
25
|
+
run: git --version
|
|
26
|
+
|
|
27
|
+
- name: Set up Python
|
|
28
|
+
uses: actions/setup-python@v4
|
|
29
|
+
with:
|
|
30
|
+
python-version: '3.9'
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
pip install build hatchling
|
|
36
|
+
|
|
37
|
+
- name: Extract version from tag
|
|
38
|
+
run: |
|
|
39
|
+
# Extract version from git tag (format: v0.0.0 or 0.0.0)
|
|
40
|
+
PACKAGE_VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///' | sed 's/^v//')
|
|
41
|
+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
|
|
42
|
+
echo "Extracted version: $PACKAGE_VERSION"
|
|
43
|
+
|
|
44
|
+
- name: Update version in pyproject.toml
|
|
45
|
+
run: |
|
|
46
|
+
# Update the version field in pyproject.toml
|
|
47
|
+
sed -i "s/^version = \".*\"/version = \"$PACKAGE_VERSION\"/" pyproject.toml
|
|
48
|
+
echo "Updated pyproject.toml with version $PACKAGE_VERSION"
|
|
49
|
+
# Verify the change
|
|
50
|
+
grep "^version = " pyproject.toml
|
|
51
|
+
|
|
52
|
+
- name: Build package
|
|
53
|
+
run: |
|
|
54
|
+
python -m build
|
|
55
|
+
|
|
56
|
+
- name: Publish package to PyPI
|
|
57
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main, develop ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
os: [ubuntu-latest, macos-latest]
|
|
20
|
+
python-version: ['3.9', '3.10', '3.11']
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
26
|
+
uses: actions/setup-python@v4
|
|
27
|
+
with:
|
|
28
|
+
python-version: ${{ matrix.python-version }}
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
pip install -e ".[test]"
|
|
34
|
+
|
|
35
|
+
- name: Run basic environment tests
|
|
36
|
+
run: |
|
|
37
|
+
pytest tests/test_environment.py -v --tb=short
|
|
38
|
+
|
|
39
|
+
- name: Run random agent tests
|
|
40
|
+
run: |
|
|
41
|
+
pytest tests/test_random_agent.py -v --tb=short
|
|
42
|
+
|
|
43
|
+
- name: Run predefined path tests
|
|
44
|
+
run: |
|
|
45
|
+
pytest tests/test_predefined_paths.py -v --tb=short
|
|
46
|
+
|
|
47
|
+
- name: Run all tests with coverage
|
|
48
|
+
run: |
|
|
49
|
+
pytest tests/ -v --tb=short --cov=Spatial_Gym --cov-report=term-missing
|
|
50
|
+
|
|
51
|
+
- name: Test package installation
|
|
52
|
+
run: |
|
|
53
|
+
pip install -e .
|
|
54
|
+
python -c "import Spatial_Gym; import gymnasium as gym; env = gym.make('Spatial-Gym'); print('✓ Environment created successfully')"
|
|
55
|
+
|
|
56
|
+
integration-test:
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
needs: test
|
|
59
|
+
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v4
|
|
62
|
+
|
|
63
|
+
- name: Set up Python
|
|
64
|
+
uses: actions/setup-python@v4
|
|
65
|
+
with:
|
|
66
|
+
python-version: '3.10'
|
|
67
|
+
|
|
68
|
+
- name: Install dependencies
|
|
69
|
+
run: |
|
|
70
|
+
python -m pip install --upgrade pip
|
|
71
|
+
pip install -e ".[test]"
|
|
72
|
+
|
|
73
|
+
- name: Run extended integration test
|
|
74
|
+
run: |
|
|
75
|
+
python -c "
|
|
76
|
+
import gymnasium as gym
|
|
77
|
+
import Spatial_Gym
|
|
78
|
+
|
|
79
|
+
print('Running integration test with random agent...')
|
|
80
|
+
env = gym.make('Spatial-Gym', max_steps=100)
|
|
81
|
+
|
|
82
|
+
# Test multiple episodes
|
|
83
|
+
for episode in range(5):
|
|
84
|
+
obs, info = env.reset()
|
|
85
|
+
done = False
|
|
86
|
+
steps = 0
|
|
87
|
+
while not done:
|
|
88
|
+
action = env.action_space.sample()
|
|
89
|
+
obs, reward, terminated, truncated, info = env.step(action)
|
|
90
|
+
done = terminated or truncated
|
|
91
|
+
steps += 1
|
|
92
|
+
print(f'Episode {episode + 1}: {steps} steps')
|
|
93
|
+
|
|
94
|
+
env.close()
|
|
95
|
+
print('✓ Integration test passed')
|
|
96
|
+
"
|
|
97
|
+
|
|
98
|
+
- name: Test different configurations
|
|
99
|
+
run: |
|
|
100
|
+
python -c "
|
|
101
|
+
import gymnasium as gym
|
|
102
|
+
import Spatial_Gym
|
|
103
|
+
|
|
104
|
+
configs = [
|
|
105
|
+
{'observation': 'new', 'render_mode': None},
|
|
106
|
+
{'observation': 'SPaRC', 'render_mode': None},
|
|
107
|
+
{'observation': 'new', 'render_mode': 'llm'},
|
|
108
|
+
{'observation': 'new', 'traceback': True},
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
for i, config in enumerate(configs):
|
|
112
|
+
print(f'Testing configuration {i + 1}: {config}')
|
|
113
|
+
env = gym.make('Spatial-Gym', max_steps=50, **config)
|
|
114
|
+
obs, info = env.reset()
|
|
115
|
+
|
|
116
|
+
for _ in range(10):
|
|
117
|
+
action = env.action_space.sample()
|
|
118
|
+
obs, reward, terminated, truncated, info = env.step(action)
|
|
119
|
+
if terminated or truncated:
|
|
120
|
+
break
|
|
121
|
+
|
|
122
|
+
env.close()
|
|
123
|
+
print(f'✓ Configuration {i + 1} passed')
|
|
124
|
+
|
|
125
|
+
print('✓ All configurations tested successfully')
|
|
126
|
+
"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import gymnasium as gym
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import Spatial_Gym
|
|
4
|
+
from human_play import play_human
|
|
5
|
+
'''
|
|
6
|
+
This script initializes the Gym environment and runs a sample episode.
|
|
7
|
+
'''
|
|
8
|
+
|
|
9
|
+
# Initialize the Gym environment with the loaded puzzles
|
|
10
|
+
env = gym.make("Spatial-Gym", render_mode='human', observation='SPaRC', traceback=True, max_steps=1000)
|
|
11
|
+
|
|
12
|
+
# If you want to play the game using human inputs, use the play_human function.
|
|
13
|
+
# render_mode can now be set to either 'human' or 'llm' and both will work.
|
|
14
|
+
obs, reward, info = play_human(env, id='aa31d05ed8fdb273')
|
|
15
|
+
env.close()
|
|
16
|
+
|
|
17
|
+
#print(f"Reward: {reward}, info: {info} , obs: {obs}" )
|
|
18
|
+
|
|
19
|
+
'''
|
|
20
|
+
# Otherwise, you can run a sample episode automatically by uncommenting the following lines:
|
|
21
|
+
|
|
22
|
+
# The reset method resets the puzzle and returns the initial observation and info.
|
|
23
|
+
# Has to be called before starting the episode.
|
|
24
|
+
obs, info = env.reset()
|
|
25
|
+
|
|
26
|
+
while True:
|
|
27
|
+
# Sample a random action from the action space
|
|
28
|
+
# Can be replaced with a specific action if desired.
|
|
29
|
+
action = env.action_space.sample()
|
|
30
|
+
|
|
31
|
+
# Step the environment with the selected action
|
|
32
|
+
obs, reward, terminated, truncated, info = env.step(action)
|
|
33
|
+
|
|
34
|
+
# Check if the episode has ended
|
|
35
|
+
if terminated or truncated:
|
|
36
|
+
print(f"Reward: {reward}, info: {info}")
|
|
37
|
+
env.close()
|
|
38
|
+
break
|
|
39
|
+
'''
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tobias Kristoffer Mark
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Migration from SPaRC-Gym to Spatial-Gym
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This document summarizes the changes made when migrating from SPaRC-Gym to Spatial-Gym.
|
|
5
|
+
|
|
6
|
+
## Repository Changes
|
|
7
|
+
- **Old Repository**: `tobiTKM/SPaRC-Gym`
|
|
8
|
+
- **New Repository**: `lkaesberg/Spatial-Gym`
|
|
9
|
+
- **URL**: https://github.com/lkaesberg/Spatial-Gym
|
|
10
|
+
|
|
11
|
+
## Package Changes
|
|
12
|
+
- **Package Name**: `SPaRC-Gym` → `Spatial-Gym`
|
|
13
|
+
- **Module Name**: `SPaRC_Gym` → `Spatial_Gym`
|
|
14
|
+
- **Version**: `0.2.0` → `1.0.0`
|
|
15
|
+
|
|
16
|
+
## File Structure Changes
|
|
17
|
+
```
|
|
18
|
+
SPaRC_Gym/ → Spatial_Gym/
|
|
19
|
+
├── SPaRC_Gym.py → Spatial_Gym.py
|
|
20
|
+
├── __init__.py (updated imports)
|
|
21
|
+
└── register_env.py (updated registration)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Code Changes
|
|
25
|
+
All occurrences of `SPaRC` have been replaced with `Spatial` in:
|
|
26
|
+
- Python files (`.py`)
|
|
27
|
+
- Configuration files (`pyproject.toml`, `.yml`)
|
|
28
|
+
- Documentation (`README.md`)
|
|
29
|
+
- Comments and docstrings
|
|
30
|
+
|
|
31
|
+
## Updated Components
|
|
32
|
+
|
|
33
|
+
### 1. README.md
|
|
34
|
+
- Rewritten for ACL-style conference submission
|
|
35
|
+
- Added abstract and key features
|
|
36
|
+
- Comprehensive environment specification
|
|
37
|
+
- API reference with examples
|
|
38
|
+
- Citation information (BibTeX format)
|
|
39
|
+
- Enhanced documentation structure
|
|
40
|
+
|
|
41
|
+
### 2. pyproject.toml
|
|
42
|
+
- Updated package metadata
|
|
43
|
+
- Added keywords and classifiers
|
|
44
|
+
- Enhanced project URLs
|
|
45
|
+
- Updated authors list
|
|
46
|
+
- Bumped version to 1.0.0
|
|
47
|
+
|
|
48
|
+
### 3. GitHub Actions Pipeline
|
|
49
|
+
- Modernized to latest action versions (v4)
|
|
50
|
+
- Added manual workflow trigger
|
|
51
|
+
- Updated PyPI publishing action
|
|
52
|
+
- Added hatchling to build dependencies
|
|
53
|
+
|
|
54
|
+
## Usage Changes
|
|
55
|
+
|
|
56
|
+
### Old Usage
|
|
57
|
+
```python
|
|
58
|
+
import gymnasium as gym
|
|
59
|
+
import SPaRC_Gym
|
|
60
|
+
env = gym.make("SPaRC-Gym", ...)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### New Usage
|
|
64
|
+
```python
|
|
65
|
+
import gymnasium as gym
|
|
66
|
+
import Spatial_Gym
|
|
67
|
+
env = gym.make("Spatial-Gym", ...)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Installation Changes
|
|
71
|
+
|
|
72
|
+
### Old
|
|
73
|
+
```bash
|
|
74
|
+
pip install SPaRC-Gym
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### New
|
|
78
|
+
```bash
|
|
79
|
+
pip install Spatial-Gym
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Notes
|
|
83
|
+
- Git history was reset (clean start, not a fork)
|
|
84
|
+
- All functionality preserved
|
|
85
|
+
- API remains backward compatible
|
|
86
|
+
- Dataset references (`lkaesberg/SPaRC`) remain unchanged
|