diff --git a/kubric/renderer/blender.py b/kubric/renderer/blender.py index 2ba10093..c9a952b2 100644 --- a/kubric/renderer/blender.py +++ b/kubric/renderer/blender.py @@ -15,27 +15,25 @@ # pylint: disable=function-redefined (removes singledispatchmethod pylint errors) import collections +from contextlib import redirect_stdout +import functools import io import logging import os import sys -from contextlib import redirect_stdout -from typing import Any, Dict, Optional, Sequence, Union import tempfile - -from kubric.safeimport.bpy import bpy - -import numpy as np -import tensorflow as tf -from singledispatchmethod import singledispatchmethod +from typing import Any, Dict, Optional, Sequence, Union import kubric as kb from kubric import core +from kubric import file_io from kubric.core.assets import UndefinedAsset +from kubric.file_io import PathLike from kubric.redirect_io import RedirectStream from kubric.renderer import blender_utils -from kubric import file_io -from kubric.file_io import PathLike +from kubric.safeimport.bpy import bpy +import numpy as np +import tensorflow as tf logger = logging.getLogger(__name__) @@ -358,7 +356,7 @@ def clear_and_reset_blender_scene(verbose: bool = False, custom_scene: str = Non logger.info("Loading scene from '%s'", custom_scene) bpy.ops.wm.open_mainfile(filepath=custom_scene) - @singledispatchmethod + @functools.singledispatchmethod def add_asset(self, asset: core.Asset) -> Any: raise NotImplementedError(f"Cannot add {asset!r}") diff --git a/kubric/simulator/pybullet.py b/kubric/simulator/pybullet.py index e8dbfd8e..0dc58628 100644 --- a/kubric/simulator/pybullet.py +++ b/kubric/simulator/pybullet.py @@ -22,11 +22,9 @@ import tempfile from typing import Dict, List, Optional, Tuple, Union -import tensorflow as tf -from singledispatchmethod import singledispatchmethod - from kubric import core from kubric.redirect_io import RedirectStream +import tensorflow as tf # --- hides the "pybullet build time: May 26 2021 18:52:36" message on import with RedirectStream(stream=sys.stderr): @@ -86,7 +84,7 @@ def __init__(self, scene: core.Scene, scratch_dir=tempfile.mkdtemp()): def physics_client(self): return self._physics_client.client - @singledispatchmethod + @functools.singledispatchmethod def add_asset(self, asset: core.Asset) -> Optional[int]: raise NotImplementedError(f"Cannot add {asset!r}") diff --git a/requirements.txt b/requirements.txt index 4c729dad..dbad9871 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,6 @@ pypng pyquaternion python-Levenshtein scikit-learn -singledispatchmethod tensorflow tensorflow-datasets>=4.1.0 traitlets