Modernization - Python 3.12, uv, Gymnasium #55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Modernize WebShop.AI infrastructure to use Python 3.12+, uv package manager, and Gymnasium API, improving performance, maintainability, and developer experience.
Description of Changes
Core Infrastructure Modernization
1. Python Package Management
requirements.txtto modernpyproject.tomlconfigurationuv.lockfor reproducible dependency resolutionsetup.sh,setup_arm.sh,run_dev.sh,run_prod.sh, etc.)requirements_arm.txt)2. Build System & Tooling
Makefilewith organized targets for:make setup,make install-uv,make sync-deps,make install-spacy-modelmake setup-data-small,make setup-data-all,make setup-search-enginemake run-dev,make run-prod,make run-web-agent-site,make run-web-agent-textmake clean,make check-uv,make check-search-engine3. Gymnasium Migration (formerly OpenAI Gym)
Updated
web_agent_site/envs/web_agent_site_env.py:import gym→import gymnasium as gymstep()method to return 5 values:(observation, reward, terminated, truncated, info)Byclass:find_element_by_id()→find_element(By.ID, ...)find_element_by_class_name()→find_element(By.CLASS_NAME, ...)Updated
web_agent_site/envs/web_agent_text_env.py:import gym→import gymnasium as gymaction_spaceandobservation_spacedefinitions usingspaces.Textstep()method to return 5 values per Gymnasium v1.0+ APIreset()method withseedandoptionsparameters for reproducibilityNone, now{})Updated
web_agent_site/envs/__init__.pyto use Gymnasium registration4. Dependency Updates
5. ChromeDriver Management
chromedriverbinary (16.6 MB)6. Documentation Improvements
README.mdwith modern setup instructionsweb_agent_site/envs/README.mdwith detailed environment documentation7. Script Updates
run_envs/run_web_agent_site_env.pyto use Gymnasium APIrun_envs/run_web_agent_text_env.pyto use Gymnasium APIstep()and newreset()signatureTesting
Manual testing performed:
Breaking Changes
For users migrating from the old version:
Python version: Now requires Python 3.12+ (was 3.8.13)
Gymnasium API:
env.step()now returns 5 values instead of 4:Reset API:
env.reset()now acceptsseedandoptionsparameters:Setup process: Use
make setupinstead of./setup.shRunning: Use
make run-devinstead of./run_dev.shScreenshots
N/A - Infrastructure/backend changes only
Checklist
Note: Test suite updates are recommended as a follow-up task to ensure all tests work with the new Gymnasium API and Python 3.12+.
Files Changed Summary
Key Files Modified:
pyproject.toml(new) - Modern Python project configurationuv.lock(new) - Dependency lock file for reproducible buildsmakefile(new) - Comprehensive build automationREADME.md- Complete rewrite with modern setup instructionsweb_agent_site/envs/web_agent_site_env.py- Gymnasium migration + Selenium updatesweb_agent_site/envs/web_agent_text_env.py- Gymnasium migration + proper spacesweb_agent_site/envs/__init__.py- Gymnasium registrationrun_envs/run_web_agent_site_env.py- Updated for new APIrun_envs/run_web_agent_text_env.py- Updated for new APIFiles Removed:
requirements.txtrequirements_arm.txtsetup.shsetup_arm.shrun_dev.shrun_prod.shrun_web_agent_site_env.shrun_web_agent_text_env.shweb_agent_site/envs/chromedriver(binary)Migration Guide for Developers
If you're using WebShop in your own projects, here's how to migrate:
1. Update Your Environment Setup
Before:
After:
2. Update Your Code
Before:
After:
3. Update Your Dependencies
If you're installing WebShop as a dependency:
Before:
After:
Benefits of This Modernization