docs: Error executing `realtime.md`'s code during building of local documentation
achieveordie opened this issue · comments
Describe the bug
When I'm trying to build documentation, I'm met with a CellExecutionError:
Notebook error:
CellExecutionError in user_guide/plugins/realtime.md:
------------------
from folium import JsCode
m = folium.Map(location=[40.73, -73.94], zoom_start=12)
rt = folium.plugins.Realtime(
"https://raw.githubusercontent.com/python-visualization/folium-example-data/main/subway_stations.geojson",
get_feature_id=JsCode("(f) => { return f.properties.objectid; }"),
interval=10000,
)
rt.add_to(m)
m
------------------
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[2], line 1
----> 1 from folium import JsCode
2 m = folium.Map(location=[40.73, -73.94], zoom_start=12)
3 rt = folium.plugins.Realtime(
4 "https://raw.githubusercontent.com/python-visualization/folium-example-data/main/subway_stations.geojson",
5 get_feature_id=JsCode("(f) => { return f.properties.objectid; }"),
6 interval=10000,
7 )
ImportError: cannot import name 'JsCode' from 'folium' (C:\Users\sagar\miniconda3\envs\folium-dev\Lib\site-packages\folium\__init__.py)
You can ignore this error by setting the following in conf.py:
nbsphinx_allow_errors = True
make: *** [Makefile:45: html] Error 2
To Reproduce
Run make html
on the current head inside the /docs
directory.
Expected behavior
Documentation build should be successful.
Environment (please complete the following information):
- Browser - irrelevant
- Jupyter Notebook or html files -
realtime.md
file which contains ipython code to create an HTML file. - Python version -
3.12.2
- folium version -
0.15.1
- branca version -
0.7.1
Additional context
The code works. I'm not sure what context is missing for this failure.
Possible solutions
Since a user can run the failing code, we could ignore the errors by including the nbsphinx_allow_errors=True
flag. Perhaps an easier win but doesn't address the problem.
folium is maintained by volunteers. Can you help making a fix for this issue?
I wasn't able to figure out the source of error during my initial inspection (I could be missing something very obvious), will take a look at it again if there's interest.
I was unable to reproduce this locally. Could it be a conflict between the version from the repository and the version of your pip installed folium? What is the output of python -c "from folium import JsCode"
?
That seems right @hansthen . JsCode
was added in v0.16.0, so since you are on v0.15.1 you cannot import it. Can you try upgrading your version of Folium?