Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/predicators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
restore-keys: |
pip-${{ matrix.python-version }}-
- run: |
pip install -e .
pip install -e .[ml]
pip install pytest-cov==2.12.1 pytest-split
- name: Pytest (group ${{ matrix.group }}/8)
run: |
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
pip-${{ matrix.python-version }}-
- name: Install dependencies
run: |
pip install -e .
pip install -e .[ml]
pip install mypy==1.8.0
- name: Mypy
run: |
Expand All @@ -109,7 +109,7 @@ jobs:
pip-${{ matrix.python-version }}-
- name: Install dependencies
run: |
pip install -e .
pip install -e .[ml]
pip install pytest-pylint==0.18.0
- name: Pylint
run: |
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: web

on: [push]

jobs:
import-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10.14
uses: actions/setup-python@v5
with:
python-version: "3.10.14"

- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-3.10.14-${{ hashFiles('setup.py') }}
restore-keys: |
pip-3.10.14-

- name: Set up Node 24
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install predicators + build tools
run: |
pip install -e .
pip install build

- name: Build predicators + gym shim wheels
run: |
PYTHON=$(which python) ./web/app/bundle.sh

# Pre-built pybullet WASM wheel from BasisResearch/pybullet-pyodide.
# That repo's CI builds the wheel as a release asset; we just
# download it. Override `PYBULLET_WASM_WHEEL_URL` via a repo
# variable to bump the version without editing this file.
- name: Download pybullet WASM wheel
env:
WHEEL_URL: ${{ vars.PYBULLET_WASM_WHEEL_URL || 'https://github.com/BasisResearch/pybullet-pyodide/releases/latest/download/pybullet-3.2.7-cp313-cp313-pyemscripten_2025_0_wasm32.whl' }}
run: |
curl -L --fail -o web/wheels/pybullet-3.2.7-cp313-cp313-pyemscripten_2025_0_wasm32.whl \
"$WHEEL_URL"
ls -lh web/wheels/

- name: Install Node deps (pyodide + puppeteer-core)
working-directory: web
run: |
npm ci

# The cheap gate: boot Pyodide in Node, install the three wheels,
# and verify every env named in the dropdown shows up as a
# registered BaseEnv subclass. No Chromium, no env construction,
# no asset extraction. ~30 s wall, vs. ~12 min for per-env smoke.
- name: Pyodide import check
run: |
node web/app/import_check.mjs
2 changes: 1 addition & 1 deletion .predicators_pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension-pkg-whitelist=numpy,pybullet,torch,tensorflow,pyrealsense2
ignore=CVS

# Add paths to the blacklist.
ignore-paths=predicators/envs/assets,predicators/third_party,venv
ignore-paths=predicators/envs/assets,predicators/third_party,venv,web

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
strict_equality = True
disallow_untyped_calls = True
warn_unreachable = True
exclude = (predicators/envs/assets|venv|prompts|logs)
exclude = (predicators/envs/assets|venv|prompts|logs|web)

[mypy-predicators.*]
disallow_untyped_defs = True
Expand Down
7 changes: 4 additions & 3 deletions predicators/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import logging
from typing import Any

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.base_env import BaseEnv

__all__ = ["BaseEnv"]
_MOST_RECENT_ENV_INSTANCE = {}

# Find the subclasses.
utils.import_submodules(__path__, __name__)
# Find the subclasses. Tolerate missing optional deps so constrained
# runtimes (e.g. Pyodide) can still load the envs that don't need them.
utils.import_submodules(__path__, __name__, tolerate_import_errors=True)


def create_new_env(name: str,
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/ball_and_cup_sticky_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Expand Down
5 changes: 3 additions & 2 deletions predicators/envs/base_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators.pretrained_model_interface import OpenAILLM
from predicators import utils_lite as utils
from predicators.settings import CFG
from predicators.structs import Action, DefaultEnvironmentTask, \
EnvironmentTask, GroundAtom, Object, Observation, Predicate, State, Task, \
Expand Down Expand Up @@ -319,6 +318,8 @@ def _parse_language_goal_from_json(
object_names = set(id_to_obj)
prompt_prefix = self._get_language_goal_prompt_prefix(object_names)
prompt = prompt_prefix + f"\n# {language_goal}"
from predicators.pretrained_model_interface import \
OpenAILLM # pylint: disable=import-outside-toplevel
llm = OpenAILLM(CFG.llm_model_name)
responses = llm.sample_completions(prompt,
None,
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from gym.spaces import Box
from matplotlib import patches

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, Array, EnvironmentTask, GroundAtom, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/burger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from gym.spaces import Box
from PIL import Image

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, DefaultEnvironmentTask, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/cluttered_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, Array, EnvironmentTask, GroundAtom, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/coffee.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.pybullet_helpers.objects import \
sample_collision_free_2d_positions
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, Array, EnvironmentTask, GroundAtom, \
Expand Down
4 changes: 2 additions & 2 deletions predicators/envs/doors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from gym.spaces import Box
from numpy.typing import NDArray

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, Array, EnvironmentTask, GroundAtom, \
Object, Predicate, State, Type
from predicators.utils import Rectangle, StateWithCache, _Geom2D
from predicators.utils_lite import Rectangle, StateWithCache, _Geom2D


class DoorsEnv(BaseEnv):
Expand Down
4 changes: 2 additions & 2 deletions predicators/envs/exit_garage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Predicate, State, Type
from predicators.utils import _Geom2D
from predicators.utils_lite import _Geom2D


class ExitGarageEnv(BaseEnv):
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/grid_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Expand Down
5 changes: 3 additions & 2 deletions predicators/envs/gymnasium_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def _ensure_cfg_initialized() -> None:
required fields like ``seed`` are missing and ``BaseEnv.__init__``
would crash.
"""
from predicators import utils # pylint: disable=import-outside-toplevel
from predicators import \
utils_lite as utils # pylint: disable=import-outside-toplevel
from predicators.settings import \
CFG # pylint: disable=import-outside-toplevel
if not hasattr(CFG, "seed"):
Expand Down Expand Up @@ -88,7 +89,7 @@ def __init__(
_ensure_cfg_initialized()
if cfg_overrides:
from predicators import \
utils # pylint: disable=import-outside-toplevel
utils_lite as utils # pylint: disable=import-outside-toplevel
utils.update_config(cfg_overrides)
resolved_cls = _resolve_cls(env_cls)
self._env = resolved_cls(use_gui=use_gui, **env_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/kitchen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
_MJKITCHEN_IMPORTED = True
except (ImportError, RuntimeError):
_MJKITCHEN_IMPORTED = False
from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, Image, Object, \
Expand Down
4 changes: 2 additions & 2 deletions predicators/envs/narrow_passage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Predicate, State, Type
from predicators.utils import _Geom2D
from predicators.utils_lite import _Geom2D


class NarrowPassageEnv(BaseEnv):
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/noisy_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as np
from gym.spaces import Box

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Expand Down
3 changes: 2 additions & 1 deletion predicators/envs/painting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from predicators.settings import CFG
from predicators.structs import Action, EnvironmentTask, GroundAtom, Object, \
Predicate, State, Type
from predicators.utils import EnvironmentFailure, HumanDemonstrationFailure
from predicators.utils_lite import EnvironmentFailure, \
HumanDemonstrationFailure


class PaintingEnv(BaseEnv):
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pddl_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pyperplan.pddl.pddl import Domain as PyperplanDomain
from pyperplan.pddl.pddl import Type as PyperplanType

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs import BaseEnv
from predicators.envs.pddl_procedural_generation import \
create_blocks_pddl_generator, create_delivery_pddl_generator, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/playroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from gym.spaces import Box
from matplotlib import patches

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.blocks import BlocksEnv, BlocksEnvClear
from predicators.settings import CFG
from predicators.structs import Action, Array, EnvironmentTask, GroundAtom, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.objects import create_object, \
create_pybullet_block, sample_collision_free_2d_positions, update_object
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from predicators.settings import CFG
from predicators.structs import Action, Array, ConceptPredicate, \
EnvironmentTask, GroundAtom, NSPredicate, Object, Predicate, State, Type
from predicators.utils import VLMQuery
from predicators.utils_lite import VLMQuery


class PyBulletBalanceEnv(PyBulletEnv):
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_barrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
from predicators.pybullet_helpers.objects import create_object, \
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.blocks import BlocksEnv
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_boil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers import retry_pybullet_call
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
from predicators.pybullet_helpers.objects import create_object
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_coffee.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.coffee import CoffeeEnv
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/pybullet_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.cover import CoverEnv
from predicators.envs.pybullet_env import PyBulletEnv
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import numpy as np
import pybullet as p

from predicators import utils
from predicators import utils_lite as utils
from predicators.envs.pybullet_domino.components.base_component import \
DominoEnvComponent
from predicators.pybullet_helpers.geometry import Pose3D, Quaternion
Expand Down
Loading
Loading