diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a30f68d3..a499bdfb5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,12 @@ Copy and pasting the git commit messages is __NOT__ enough. ### Changed ### Deprecated ### Fixed +- Fixed an issue where `SMARTS` might not be explicitly destroyed in the `ros_driver`. - Fixed issue where `SumoTrafficSimulation` could get locked up on reset if a scenario had only 1 map but multiple scenario variations. +- Fixed an issue where an out-of-scope method reference caused a pickling error. +- Fixed an issue where the `EnvisionDataFormatterArgs` default would use a locally defined lambda and cause a serialization failure. +- Fixed an issue where user configuration was being overridden. +- Fixed a `pkg_resources` deprecation warning in `python3.10` and up. ### Removed ### Security diff --git a/docs/setup.rst b/docs/setup.rst index 09d3163f16..851ae5bef1 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -15,12 +15,32 @@ Demo Video Prerequisites ------------- -+ ``python3 (3.8 or 3.9)`` ++ ``python3 (3.8, 3.9, 3.10, 3.11)`` + ``ubuntu (>=16.04)`` Installation ------------ +Package +^^^^^^^ + +This includes SMARTS but none of the examples. + +.. code-block:: bash + + # For Mac OS X users, ensure XQuartz is pre-installed. + # Install the system requirements. You may use the `-y` option to enable + # automatic assumption of "yes" to all prompts to avoid timeout from + # waiting for user input. + $ bash utils/setup/install_deps.sh + + # This should install the latest version of SMARTS from package index (generally PyPI). + $ pip install 'smarts[camera_obs,sumo,example]' + + +Development +^^^^^^^^^^^ + Run the following commands to setup the SMARTS simulator. .. code-block:: bash @@ -61,9 +81,11 @@ Run the following commands to setup the SMARTS simulator. # Install smarts with extras as needed. Extras include the following: # `camera_obs` - needed for rendering camera observations, and for testing. # `sumo` - needed for using SUMO scenarios. - # `test` - needed for testing. + # `test` - needed for running tests. # `example` - needed for running examples. - $ pip install -e .[camera_obs,sumo,test,example] + # `--config-settings editable_mode=strict` - may be needed depending on version of setuptools. + # See https://github.com/huawei-noah/SMARTS/issues/2090. + $ pip install -e '.[camera_obs,sumo,test,example]' --config-settings editable_mode=strict # Run sanity-test and verify they are passing. # If tests fail, check './sanity_test_result.xml' for test report. diff --git a/envision/client_config.py b/envision/client_config.py index 9e5078a055..b5e6155cbf 100644 --- a/envision/client_config.py +++ b/envision/client_config.py @@ -36,6 +36,10 @@ class SingleAttributeOverride(NamedTuple): """The maximum number of elements an iterable attribute can contain.""" +def _default_override(): + return SingleAttributeOverride(True, None) + + @dataclass(frozen=True) class EnvisionStateFilter: """A state filtering tool.""" @@ -49,7 +53,4 @@ class EnvisionStateFilter: def default(cls): """Give a new default filter.""" - def default_override(): - return SingleAttributeOverride(True, None) - - return cls(defaultdict(default_override), defaultdict(default_override)) + return cls(defaultdict(_default_override), defaultdict(_default_override)) diff --git a/envision/data_formatter.py b/envision/data_formatter.py index 1a0dae4e36..3e8a124bac 100644 --- a/envision/data_formatter.py +++ b/envision/data_formatter.py @@ -75,6 +75,10 @@ class Operation(IntEnum): _primitives = {int, float, str, VehicleType, TrafficActorType} +def _passthrough_method_1_arg(v): + return v + + class ReductionContext: """Mappings between an object and its reduction to an ID.""" @@ -126,7 +130,7 @@ class EnvisionDataFormatterArgs(NamedTuple): """Data formatter configurations.""" id: Optional[str] - serializer: Callable[[list], Any] = lambda d: d + serializer: Callable[[list], Any] = _passthrough_method_1_arg float_decimals: int = 2 bool_as_int: bool = True enable_reduction: bool = True diff --git a/envision/server.py b/envision/server.py index 8069a6177f..065b898940 100644 --- a/envision/server.py +++ b/envision/server.py @@ -50,9 +50,6 @@ from envision.web import dist as web_dist from smarts.core.utils.file import path2hash -logging.basicConfig(level=logging.WARNING) - - # Mapping of simulation IDs to a set of web client run loops WEB_CLIENT_RUN_LOOPS = {} diff --git a/envision/tests/test_data_replay.py b/envision/tests/test_data_replay.py index a98bbe5c2c..5ac7b44a5c 100644 --- a/envision/tests/test_data_replay.py +++ b/envision/tests/test_data_replay.py @@ -42,11 +42,13 @@ TIMESTEP_SEC = 0.1 +class KeepLaneAgent(Agent): + def act(self, obs): + return "keep_lane" + + @pytest.fixture def agent_spec(): - class KeepLaneAgent(Agent): - def act(self, obs): - return "keep_lane" return AgentSpec( interface=AgentInterface.from_type( diff --git a/examples/e2_single_agent.py b/examples/e2_single_agent.py index 07d34570c1..da3d223761 100644 --- a/examples/e2_single_agent.py +++ b/examples/e2_single_agent.py @@ -1,11 +1,17 @@ """This example shows how you might run a SMARTS environment for single-agent work. SMARTS is natively multi-agent so a single-agent wrapper is used.""" import argparse +import logging import random import sys +import warnings from pathlib import Path from typing import Final +logging.basicConfig(level=logging.ERROR) +warnings.filterwarnings("ignore") + + import gymnasium as gym SMARTS_REPO_PATH = Path(__file__).parents[1].absolute() diff --git a/examples/replay/replay_klws_agent.py b/examples/replay/replay_klws_agent.py index b94c92c459..ae2abfeb34 100644 --- a/examples/replay/replay_klws_agent.py +++ b/examples/replay/replay_klws_agent.py @@ -14,8 +14,6 @@ from smarts.env.utils.observation_conversion import ObservationOptions from smarts.zoo.registry import make as zoo_make -logging.basicConfig(level=logging.INFO) - AGENT_ID = "Agent-007" @@ -116,6 +114,7 @@ def main(scenarios, sim_name, headless, seed, speed, max_steps, save_dir, write) if __name__ == "__main__": + logging.basicConfig(level=logging.INFO) parser = default_argument_parser("klws-agent-example") parser.add_argument( "--speed", diff --git a/requirements.txt b/requirements.txt index 0b08c89a22..94e85ed919 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,46 +3,45 @@ aiosignal==1.3.1 astunparse==1.6.3 attrs==23.1.0 Automat==22.10.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 -charset-normalizer==3.2.0 +charset-normalizer==3.3.2 click==8.1.7 -cloudpickle==2.2.1 -cmake==3.27.5 -constantly==15.1.0 -coverage==7.3.1 +cloudpickle==3.0.0 +constantly==23.10.4 +coverage==7.3.2 decorator==5.1.1 dm-tree==0.1.8 exceptiongroup==1.1.3 execnet==2.0.2 -filelock==3.12.4 +filelock==3.13.1 flatbuffers==23.5.26 frozenlist==1.4.0 +fsspec==2023.10.0 future==0.18.3 gast==0.4.0 -google-auth==2.23.1 +google-auth==2.23.4 google-auth-oauthlib==1.0.0 google-pasta==0.2.0 grpcio==1.51.3 Gymnasium==0.26.3 gymnasium-notices==0.0.1 -h5py==3.9.0 +h5py==3.10.0 hyperlink==21.0.0 idna==3.4 -imageio==2.31.4 +imageio==2.32.0 importlib-metadata==6.8.0 -importlib-resources==6.1.0 +importlib-resources==6.1.1 incremental==22.10.0 iniconfig==2.0.0 Jinja2==3.1.2 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 keras==2.13.1 lazy_loader==0.3 libclang==16.0.6 -lit==17.0.1 lz4==4.3.2 -Markdown==3.4.4 +Markdown==3.5.1 markdown-it-py==3.0.0 MarkupSafe==2.1.3 mdurl==0.1.2 @@ -50,22 +49,23 @@ mpmath==1.3.0 msgpack==1.0.7 networkx==3.1 numpy==1.24.3 -nvidia-cublas-cu11==11.10.3.66 -nvidia-cuda-cupti-cu11==11.7.101 -nvidia-cuda-nvrtc-cu11==11.7.99 -nvidia-cuda-runtime-cu11==11.7.99 -nvidia-cudnn-cu11==8.5.0.96 -nvidia-cufft-cu11==10.9.0.58 -nvidia-curand-cu11==10.2.10.91 -nvidia-cusolver-cu11==11.4.0.1 -nvidia-cusparse-cu11==11.7.4.91 -nvidia-nccl-cu11==2.14.3 -nvidia-nvtx-cu11==11.7.91 +nvidia-cublas-cu12==12.1.3.1 +nvidia-cuda-cupti-cu12==12.1.105 +nvidia-cuda-nvrtc-cu12==12.1.105 +nvidia-cuda-runtime-cu12==12.1.105 +nvidia-cudnn-cu12==8.9.2.26 +nvidia-cufft-cu12==11.0.2.54 +nvidia-curand-cu12==10.3.2.106 +nvidia-cusolver-cu12==11.4.5.107 +nvidia-cusparse-cu12==12.1.0.106 +nvidia-nccl-cu12==2.18.1 +nvidia-nvjitlink-cu12==12.3.52 +nvidia-nvtx-cu12==12.1.105 oauthlib==3.2.2 opencv-python==4.8.1.78 opencv-python-headless==4.8.1.78 opt-einsum==3.3.0 -packaging==23.1 +packaging==23.2 Panda3D==1.10.13 panda3d-gltf==0.13 panda3d-simplepbr==0.10 @@ -73,16 +73,16 @@ pandas==2.0.3 Pillow==10.0.1 pkgutil_resolve_name==1.3.10 pluggy==1.3.0 -protobuf==4.24.3 -psutil==5.9.5 +protobuf==4.25.0 +psutil==5.9.6 py==1.11.0 py-cpuinfo==9.0.0 -pyarrow==13.0.0 +pyarrow==14.0.1 pyasn1==0.5.0 pyasn1-modules==0.3.0 pybullet==3.2.5 Pygments==2.16.1 -pytest==7.4.2 +pytest==7.4.3 pytest-benchmark==4.0.0 pytest-cov==4.1.0 pytest-forked==1.6.0 @@ -95,17 +95,17 @@ ray==2.5.1 referencing==0.30.2 requests==2.31.0 requests-oauthlib==1.3.1 -rich==13.5.3 -rpds-py==0.10.3 +rich==13.6.0 +rpds-py==0.12.0 rsa==4.9 scikit-image==0.21.0 scipy==1.10.1 -shapely==2.0.1 +shapely==2.0.2 six==1.16.0 sympy==1.12 tableprint==0.9.1 tensorboard==2.13.0 -tensorboard-data-server==0.7.1 +tensorboard-data-server==0.7.2 tensorboardX==2.6.2.2 tensorflow==2.13.1 tensorflow-estimator==2.13.0 @@ -114,18 +114,18 @@ tensorflow-probability==0.21.0 termcolor==2.3.0 tifffile==2023.7.10 tomli==2.0.1 -torch==2.0.1 -torchvision==0.15.2 -trimesh==3.23.5 -triton==2.0.0 -Twisted==23.8.0 +torch==2.1.0 +torchvision==0.16.0 +trimesh==4.0.3 +triton==2.1.0 +Twisted==23.10.0 typer==0.9.0 typing_extensions==4.5.0 tzdata==2023.3 -urllib3==2.0.5 -wcwidth==0.2.6 -Werkzeug==2.3.7 -wrapt==1.15.0 -yattag==1.15.1 +urllib3==2.0.7 +wcwidth==0.2.9 +Werkzeug==3.0.1 +wrapt==1.16.0 +yattag==1.15.2 zipp==3.17.0 -zope.interface==6.0 +zope.interface==6.1 diff --git a/smarts/__init__.py b/smarts/__init__.py index 607d6c6631..23907bd163 100644 --- a/smarts/__init__.py +++ b/smarts/__init__.py @@ -18,8 +18,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +try: + from importlib.metadata import version -import pkg_resources + VERSION = version("smarts") +except: + # This is now deprecated `https://setuptools.pypa.io/en/latest/pkg_resources.html` + import pkg_resources -# The full version, including alpha/beta/rc tags -VERSION = pkg_resources.get_distribution("smarts").version + # The full version, including alpha/beta/rc tags + VERSION = pkg_resources.get_distribution("smarts").version diff --git a/smarts/core/agent.py b/smarts/core/agent.py index 0116125067..9b0b3bee37 100644 --- a/smarts/core/agent.py +++ b/smarts/core/agent.py @@ -21,8 +21,6 @@ import warnings from typing import Any, Callable -warnings.simplefilter("once") - logger = logging.getLogger(__name__) diff --git a/smarts/ros/src/smarts_ros/scripts/ros_driver.py b/smarts/ros/src/smarts_ros/scripts/ros_driver.py index 1a06e461e4..5ab09ef319 100755 --- a/smarts/ros/src/smarts_ros/scripts/ros_driver.py +++ b/smarts/ros/src/smarts_ros/scripts/ros_driver.py @@ -684,15 +684,15 @@ def run_forever(self): self._publish_state() self._publish_agents(observations, dones) - except Exception as e: - if isinstance(e, rospy.ROSInterruptException): - raise e + except Exception as ex: + if isinstance(ex, rospy.ROSInterruptException): + raise ex batch_mode = rospy.get_param("~batch_mode", False) if not batch_mode: - raise e + raise ex import traceback - rospy.logerr(f"SMARTS raised exception: {e}") + rospy.logerr(f"SMARTS raised exception: {ex}") rospy.logerr(traceback.format_exc()) rospy.logerr("Will wait for next reset...") self._smarts = None @@ -712,8 +712,8 @@ def run_forever(self): except rospy.ROSInterruptException: rospy.loginfo("ROS interrupted. exiting...") - - self._reset() # cleans up the SMARTS instance... + finally: + self._reset() # cleans up the SMARTS instance... if __name__ == "__main__": diff --git a/smarts/zoo/agent_spec.py b/smarts/zoo/agent_spec.py index b44f23e4f6..70a0505fe5 100644 --- a/smarts/zoo/agent_spec.py +++ b/smarts/zoo/agent_spec.py @@ -27,8 +27,6 @@ from smarts.core.agent import Agent from smarts.core.agent_interface import AgentInterface -warnings.simplefilter("once") - @dataclass class AgentSpec(object): diff --git a/utils/setup/mac_requirements.txt b/utils/setup/mac_requirements.txt index a240aaf5a0..b301bfa7d0 100644 --- a/utils/setup/mac_requirements.txt +++ b/utils/setup/mac_requirements.txt @@ -3,44 +3,45 @@ aiosignal==1.3.1 astunparse==1.6.3 attrs==23.1.0 Automat==22.10.0 -cachetools==5.3.1 +cachetools==5.3.2 certifi==2023.7.22 -charset-normalizer==3.3.0 +charset-normalizer==3.3.2 click==8.1.7 -cloudpickle==2.2.1 -constantly==15.1.0 +cloudpickle==3.0.0 +constantly==23.10.4 coverage==7.3.2 decorator==5.1.1 dm-tree==0.1.8 exceptiongroup==1.1.3 execnet==2.0.2 -filelock==3.12.4 +filelock==3.13.1 flatbuffers==23.5.26 frozenlist==1.4.0 +fsspec==2023.10.0 future==0.18.3 gast==0.4.0 -google-auth==2.23.2 +google-auth==2.23.4 google-auth-oauthlib==1.0.0 google-pasta==0.2.0 grpcio==1.49.1 Gymnasium==0.26.3 gymnasium-notices==0.0.1 -h5py==3.9.0 +h5py==3.10.0 hyperlink==21.0.0 idna==3.4 -imageio==2.31.5 +imageio==2.32.0 importlib-metadata==6.8.0 -importlib-resources==6.1.0 +importlib-resources==6.1.1 incremental==22.10.0 iniconfig==2.0.0 Jinja2==3.1.2 -jsonschema==4.19.1 +jsonschema==4.19.2 jsonschema-specifications==2023.7.1 keras==2.13.1 lazy_loader==0.3 libclang==16.0.6 lz4==4.3.2 -Markdown==3.4.4 +Markdown==3.5.1 markdown-it-py==3.0.0 MarkupSafe==2.1.3 mdurl==0.1.2 @@ -60,20 +61,20 @@ pandas==2.0.3 Pillow==10.0.1 pkgutil_resolve_name==1.3.10 pluggy==1.3.0 -protobuf==4.24.3 -psutil==5.9.5 +protobuf==4.25.0 +psutil==5.9.6 py==1.11.0 py-cpuinfo==9.0.0 -pyarrow==13.0.0 +pyarrow==14.0.1 pyasn1==0.5.0 pyasn1-modules==0.3.0 pybullet==3.2.5 Pygments==2.16.1 -pytest==7.4.2 +pytest==7.4.3 pytest-benchmark==4.0.0 pytest-cov==4.1.0 pytest-forked==1.6.0 -pytest-xdist==3.3.1 +pytest-xdist==3.4.0 python-dateutil==2.8.2 pytz==2023.3.post1 PyWavelets==1.4.1 @@ -83,16 +84,16 @@ referencing==0.30.2 requests==2.31.0 requests-oauthlib==1.3.1 rich==13.6.0 -rpds-py==0.10.3 +rpds-py==0.12.0 rsa==4.9 scikit-image==0.21.0 scipy==1.10.1 -shapely==2.0.1 +shapely==2.0.2 six==1.16.0 sympy==1.12 tableprint==0.9.1 tensorboard==2.13.0 -tensorboard-data-server==0.7.1 +tensorboard-data-server==0.7.2 tensorboardX==2.6.2.2 tensorflow==2.13.1 tensorflow-estimator==2.13.0 @@ -101,17 +102,17 @@ tensorflow-probability==0.21.0 termcolor==2.3.0 tifffile==2023.7.10 tomli==2.0.1 -torch==2.0.1 -torchvision==0.15.2 -trimesh==3.23.5 -Twisted==23.8.0 +torch==2.1.0 +torchvision==0.16.0 +trimesh==4.0.4 +Twisted==23.10.0 typer==0.9.0 typing_extensions==4.5.0 tzdata==2023.3 -urllib3==2.0.6 -wcwidth==0.2.8 -Werkzeug==3.0.0 -wrapt==1.15.0 -yattag==1.15.1 +urllib3==2.1.0 +wcwidth==0.2.10 +Werkzeug==3.0.1 +wrapt==1.16.0 +yattag==1.15.2 zipp==3.17.0 -zope.interface==6.0 +zope.interface==6.1