ivan.lee commited on
Commit ·
f219fd1
1
Parent(s): bfc4cb9
Fix import issues on Hugging Face space mock fallback
Browse files- .gitignore +4 -1
- reachy_mini/__init__.py +6 -1
- reachy_mini/media/media_manager.py +11 -1
- reachy_mini/utils.py +8 -1
.gitignore
CHANGED
|
@@ -34,4 +34,7 @@ record/
|
|
| 34 |
|
| 35 |
# Key / certificate files
|
| 36 |
*.pem
|
| 37 |
-
*.key
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Key / certificate files
|
| 36 |
*.pem
|
| 37 |
+
*.key
|
| 38 |
+
|
| 39 |
+
# Project retrospective tutorial
|
| 40 |
+
learn.md
|
reachy_mini/__init__.py
CHANGED
|
@@ -6,14 +6,19 @@ parent_dir = os.path.dirname(current_dir)
|
|
| 6 |
|
| 7 |
real_reachy_mini_pkg = None
|
| 8 |
original_path = list(sys.path)
|
|
|
|
| 9 |
try:
|
| 10 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 11 |
import reachy_mini as rmp
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
except ImportError:
|
| 14 |
pass
|
| 15 |
finally:
|
| 16 |
sys.path = original_path
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if real_reachy_mini_pkg is not None:
|
| 19 |
globals().update({k: v for k, v in real_reachy_mini_pkg.__dict__.items() if not k.startswith('__')})
|
|
|
|
| 6 |
|
| 7 |
real_reachy_mini_pkg = None
|
| 8 |
original_path = list(sys.path)
|
| 9 |
+
original_module = sys.modules.pop('reachy_mini', None)
|
| 10 |
try:
|
| 11 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 12 |
import reachy_mini as rmp
|
| 13 |
+
# Verify it is the real reachy_mini package with the required class
|
| 14 |
+
if hasattr(rmp, 'ReachyMini'):
|
| 15 |
+
real_reachy_mini_pkg = rmp
|
| 16 |
except ImportError:
|
| 17 |
pass
|
| 18 |
finally:
|
| 19 |
sys.path = original_path
|
| 20 |
+
if original_module is not None:
|
| 21 |
+
sys.modules['reachy_mini'] = original_module
|
| 22 |
|
| 23 |
if real_reachy_mini_pkg is not None:
|
| 24 |
globals().update({k: v for k, v in real_reachy_mini_pkg.__dict__.items() if not k.startswith('__')})
|
reachy_mini/media/media_manager.py
CHANGED
|
@@ -6,14 +6,24 @@ parent_dir = os.path.dirname(current_dir) # dev/camping_ai/
|
|
| 6 |
|
| 7 |
real_media_manager = None
|
| 8 |
original_path = list(sys.path)
|
|
|
|
|
|
|
|
|
|
| 9 |
try:
|
| 10 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 11 |
from reachy_mini.media import media_manager as rmm
|
| 12 |
-
|
|
|
|
| 13 |
except ImportError:
|
| 14 |
pass
|
| 15 |
finally:
|
| 16 |
sys.path = original_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if real_media_manager is not None:
|
| 19 |
globals().update({k: v for k, v in real_media_manager.__dict__.items() if not k.startswith('__')})
|
|
|
|
| 6 |
|
| 7 |
real_media_manager = None
|
| 8 |
original_path = list(sys.path)
|
| 9 |
+
original_module = sys.modules.pop('reachy_mini.media.media_manager', None)
|
| 10 |
+
original_parent_media = sys.modules.pop('reachy_mini.media', None)
|
| 11 |
+
original_parent = sys.modules.pop('reachy_mini', None)
|
| 12 |
try:
|
| 13 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 14 |
from reachy_mini.media import media_manager as rmm
|
| 15 |
+
if hasattr(rmm, 'MediaManager'):
|
| 16 |
+
real_media_manager = rmm
|
| 17 |
except ImportError:
|
| 18 |
pass
|
| 19 |
finally:
|
| 20 |
sys.path = original_path
|
| 21 |
+
if original_parent is not None:
|
| 22 |
+
sys.modules['reachy_mini'] = original_parent
|
| 23 |
+
if original_parent_media is not None:
|
| 24 |
+
sys.modules['reachy_mini.media'] = original_parent_media
|
| 25 |
+
if original_module is not None:
|
| 26 |
+
sys.modules['reachy_mini.media.media_manager'] = original_module
|
| 27 |
|
| 28 |
if real_media_manager is not None:
|
| 29 |
globals().update({k: v for k, v in real_media_manager.__dict__.items() if not k.startswith('__')})
|
reachy_mini/utils.py
CHANGED
|
@@ -6,14 +6,21 @@ parent_dir = os.path.dirname(current_dir) # dev/camping_ai/
|
|
| 6 |
|
| 7 |
real_utils = None
|
| 8 |
original_path = list(sys.path)
|
|
|
|
|
|
|
| 9 |
try:
|
| 10 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 11 |
from reachy_mini import utils as ru
|
| 12 |
-
|
|
|
|
| 13 |
except ImportError:
|
| 14 |
pass
|
| 15 |
finally:
|
| 16 |
sys.path = original_path
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if real_utils is not None:
|
| 19 |
globals().update({k: v for k, v in real_utils.__dict__.items() if not k.startswith('__')})
|
|
|
|
| 6 |
|
| 7 |
real_utils = None
|
| 8 |
original_path = list(sys.path)
|
| 9 |
+
original_module = sys.modules.pop('reachy_mini.utils', None)
|
| 10 |
+
original_parent = sys.modules.pop('reachy_mini', None)
|
| 11 |
try:
|
| 12 |
sys.path = [p for p in sys.path if os.path.abspath(p) not in (parent_dir, current_dir)]
|
| 13 |
from reachy_mini import utils as ru
|
| 14 |
+
if hasattr(ru, 'create_head_pose'):
|
| 15 |
+
real_utils = ru
|
| 16 |
except ImportError:
|
| 17 |
pass
|
| 18 |
finally:
|
| 19 |
sys.path = original_path
|
| 20 |
+
if original_parent is not None:
|
| 21 |
+
sys.modules['reachy_mini'] = original_parent
|
| 22 |
+
if original_module is not None:
|
| 23 |
+
sys.modules['reachy_mini.utils'] = original_module
|
| 24 |
|
| 25 |
if real_utils is not None:
|
| 26 |
globals().update({k: v for k, v in real_utils.__dict__.items() if not k.startswith('__')})
|