Skip to content

Commit

Permalink
Removes dependency on singledispatchmethod package which is included …
Browse files Browse the repository at this point in the history
…in functools since Python 3.8 (#317)

PiperOrigin-RevId: 619494372

Co-authored-by: kubric-team <[email protected]>
  • Loading branch information
cdoersch and Qwlouse authored Mar 27, 2024
1 parent e842ea8 commit 466e3f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
20 changes: 9 additions & 11 deletions kubric/renderer/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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}")

Expand Down
6 changes: 2 additions & 4 deletions kubric/simulator/pybullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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}")

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pypng
pyquaternion
python-Levenshtein
scikit-learn
singledispatchmethod
tensorflow
tensorflow-datasets>=4.1.0
traitlets
Expand Down

0 comments on commit 466e3f1

Please sign in to comment.