Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,33 @@ jobs:
run: just docs
- name: Run linkcheck
run: just docs-linkcheck
test_minimum:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an unrelated change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to make sure the logic still worked with older versions of PyMongo that don't have the codecs property.

runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
- name: Install Deps
run: |
python -m pip install uv rust-just
- name: Set up env
run: |
echo "LIBBSON_INSTALL_DIR=$PWD/libbson" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$PWD/libbson/lib" >> $GITHUB_ENV
- name: Install libbson
run: just build-libbson
- name: Run tests
shell: bash
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[test]" --resolution=lowest-direct
pytest
12 changes: 9 additions & 3 deletions bindings/python/pymongoarrow/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
is_uint32,
is_uint64,
)
from pymongo.collection import Collection
from pymongo.common import MAX_WRITE_BATCH_SIZE

from pymongoarrow.context import PyMongoArrowContext
Expand Down Expand Up @@ -488,7 +489,9 @@ def transform_python(self, value):
return Decimal128(value)


def write(collection, tabular, *, exclude_none: bool = False, auto_convert: bool = True):
def write(
collection: Collection, tabular, *, exclude_none: bool = False, auto_convert: bool = True
):
"""Write data from `tabular` into the given MongoDB `collection`.

:Parameters:
Expand Down Expand Up @@ -559,10 +562,13 @@ def write(collection, tabular, *, exclude_none: bool = False, auto_convert: bool

# Add handling for special case types.
codec_options = collection.codec_options
base_codecs = []
if hasattr(codec_options.type_registry, "codecs"):
base_codecs = codec_options.type_registry.codecs
if pd is not None:
type_registry = TypeRegistry([_PandasNACodec(), _DecimalCodec()])
type_registry = TypeRegistry([*base_codecs, _PandasNACodec(), _DecimalCodec()])
else:
type_registry = TypeRegistry([_DecimalCodec()])
type_registry = TypeRegistry([*base_codecs, _DecimalCodec()])
codec_options = codec_options.with_options(type_registry=type_registry)

while cur_offset < tab_size:
Expand Down
5 changes: 3 additions & 2 deletions bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Source = "https://github.com/mongodb-labs/mongo-arrow/tree/main/bindings/python"
Tracker = "https://jira.mongodb.org/projects/INTPYTHON/issues"

[project.optional-dependencies]
test = ["pytz", "pytest"]
test-polars = ["polars"]
test = ["pytz>=2025.2", "pytest>=8.0"]
test-polars = ["polars>=1.10"]
test-pandas = ["pandas>=1.3.5,<3"]

[tool.setuptools]
Expand Down Expand Up @@ -106,6 +106,7 @@ xfail_strict = true
filterwarnings = [
"error",
"module:The global interpreter lock:RuntimeWarning", # from pandas
"module:matching against an empty string will:pytest.PytestWarning", # from pandas
]

[tool.ruff]
Expand Down
4 changes: 4 additions & 0 deletions bindings/python/test/pandas_types/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def test_contains(self):
# We cannot compare a Binary object to an array.
pass

def test_array_interface_copy(self):
# We cannot avoid copying with our extension arrays.
pass


class TestConstructors(base.BaseConstructorsTests):
def test_array_from_scalars(self):
Expand Down
4 changes: 4 additions & 0 deletions bindings/python/test/pandas_types/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def test_contains(self):
# We cannot compare a Code object to an array.
pass

def test_array_interface_copy(self):
# We cannot avoid copying with our extension arrays.
pass


class TestConstructors(base.BaseConstructorsTests):
pass
Expand Down
4 changes: 3 additions & 1 deletion bindings/python/test/pandas_types/test_decimal128.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def test_is_not_object_type(self, data):


class TestInterface(base.BaseInterfaceTests):
pass
def test_array_interface_copy(self):
# We cannot avoid copying with our extension arrays.
pass


class TestConstructors(base.BaseConstructorsTests):
Expand Down
4 changes: 3 additions & 1 deletion bindings/python/test/pandas_types/test_objectid.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def test_is_not_object_type(self, data):


class TestInterface(base.BaseInterfaceTests):
pass
def test_array_interface_copy(self):
# We cannot avoid copying with our extension arrays.
pass


class TestConstructors(base.BaseConstructorsTests):
Expand Down
1,098 changes: 625 additions & 473 deletions bindings/python/uv.lock

Large diffs are not rendered by default.

Loading