Skip to content

Commit 33f3149

Browse files
committed
fixing documentation deployment
1 parent 2382ad6 commit 33f3149

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
set -e
3838
cd docs
3939
make html
40+
env:
41+
SPHINX_BUILD: "1"
4042

4143
- name: Deploy to GitHub Pages
4244
run: |

gbrl/__init__.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,19 @@ def load_cpp_module():
9696

9797

9898
# Load the C++ module dynamically
99-
_gbrl_cpp_module = load_cpp_module()
100-
101-
# Create a global alias for the GBRL class
102-
GBRL_CPP = _gbrl_cpp_module.GBRL
103-
104-
cuda_available = GBRL_CPP.cuda_available
99+
try:
100+
_gbrl_cpp_module = load_cpp_module()
101+
# Create a global alias for the GBRL class
102+
GBRL_CPP = _gbrl_cpp_module.GBRL
103+
cuda_available = GBRL_CPP.cuda_available
104+
except ImportError:
105+
# If we're building documentation or the C++ module isn't available,
106+
# use a mock instead
107+
if os.environ.get('SPHINX_BUILD') or 'sphinx' in sys.modules:
108+
from unittest.mock import MagicMock
109+
_gbrl_cpp_module = MagicMock()
110+
GBRL_CPP = MagicMock()
111+
cuda_available = lambda: False # noqa: E731
112+
else:
113+
# Re-raise the error if we're not building docs
114+
raise

0 commit comments

Comments
 (0)