mongodb-labs / mongo-arrow

MongoDB integrations for Apache Arrow. Export MongoDB documents to numpy array, parquet files, and pandas dataframes in one line of code.
https://mongo-arrow.readthedocs.io
Apache License 2.0
92 stars 14 forks source link

pymongoarrow does not work with pymongo >= 4.9 #233

Open rraymondgh opened 2 months ago

rraymondgh commented 2 months ago
import pymongo
import pymongoarrow

print(pymongo.__version__, pymongoarrow.__version__)

from pymongoarrow.monkey import patch_all
patch_all()

works with:

4.8.0 1.5.1

fails with:

4.9.1 1.5.1

Exception

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 7
      4 print(pymongo.__version__, pymongoarrow.__version__)
      6 from pymongoarrow.monkey import patch_all
----> 7 patch_all()

File [/opt/conda/lib/python3.11/site-packages/pymongoarrow/monkey.py:35](http://localhost:8888/opt/conda/lib/python3.11/site-packages/pymongoarrow/monkey.py#line=34), in patch_all()
     20 """Patch all PyMongoArrow methods into PyMongo.
     21 
     22 Calling this method equips the :class:`pymongo.collection.Collection`
   (...)
     31    df = coll.db.test.find_pandas_all({'amount': {'$gte': 20}}, schema=schema)
     32 """
     33 from pymongo.collection import Collection
---> 35 import pymongoarrow.api as api_module
     37 api_methods = api_module._PATCH_METHODS
     38 for method_name in api_methods:

File [/opt/conda/lib/python3.11/site-packages/pymongoarrow/api.py:33](http://localhost:8888/opt/conda/lib/python3.11/site-packages/pymongoarrow/api.py#line=32)
     31 from pyarrow import Table, timestamp
     32 from pyarrow.types import is_date32, is_date64
---> 33 from pymongo.bulk import BulkWriteError
     34 from pymongo.common import MAX_WRITE_BATCH_SIZE
     36 from pymongoarrow.context import PyMongoArrowContext

ModuleNotFoundError: No module named 'pymongo.bulk'
aclark4life commented 2 months ago

Thank you for the bug report, @rraymondgh! I've created a JIRA ticket for this issue here: https://jira.mongodb.org/browse/ARROW-247