Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.9.1 #82

Merged
merged 12 commits into from
Oct 5, 2023
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
21 changes: 12 additions & 9 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8, 3.9]
solr: [8.6]
django: [0, 3.0, 3.1, 3.2]
python: ["3.9", "3.10", "3.11"]
solr: ["8.6"]
django: [0, "3.2", "4.0"]
include: # run one build on solr 9.2; no need to run all combinations
- python: 3.9
solr: 9.2
django: 3.2
# We use service containers to avoid needing to set up a local copy of
# mysql or postgres on the test runner instance. This syntax is similar to
# the spec of a docker-compose file. For more, see:
Expand All @@ -25,22 +29,21 @@ jobs:
ports:
- 8983:8983
steps:
- name: Copy solr configsets to solr home directory (Solr 8 only)
- name: Copy solr configsets to solr home directory
run: "docker exec -d ${{ job.services.solr.id }} cp -r /opt/solr/server/solr/configsets /var/solr/data"
if: ${{ matrix.solr == 8.6 }}

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

# We base the python cache on the hash of all requirements files, so that
# if any change, the cache is invalidated.
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('setup.py') }}
Expand All @@ -66,4 +69,4 @@ jobs:
run: py.test --cov=parasolr --cov-report=xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
11 changes: 9 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
CHANGELOG
=========

0.8.2
-----
0.9.1
----

* Solr 9 compatible; now tested against Solr 9.2 and 8.6
* Dropped support for python 3.7; now tested against python 3.9-3.11
* Now tested against Django 4.0 and 3.2

0.9
---

* ``SolrQuerySet`` now supports Solr grouping via new `group`
method and `GroupedResponse`
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ configuration and indexing content.
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
:target: https://pycqa.github.io/isort/

Currently tested against Python 3.8 and 3.9, Solr 8.6.2, and Django 3.0-3.2 and without Django.
Tested against Python 3.9-3.11, Solr 8.6 and 9.2, and Django 3.2-4.0 and without Django.


Installation
Expand Down
4 changes: 1 addition & 3 deletions parasolr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
default_app_config = "parasolr.apps.ParasolConfig"

__version_info__ = (0, 9, 0, None)
__version_info__ = (0, 9, 1, None)

# Dot-connect all but the last. Last is dash-connected if not None.
__version__ = ".".join([str(i) for i in __version_info__[:-1]])
Expand Down
18 changes: 9 additions & 9 deletions parasolr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ class MySolrSchema(schema.SolrSchema):
"""

import logging
from collections import defaultdict
from typing import Any, Optional

from attrdict import AttrDefault
from addict import Dict as AttrDict

from parasolr.solr.client import SolrClient

Expand Down Expand Up @@ -247,7 +248,7 @@ def get_field_types(cls) -> list:
]

@classmethod
def configure_fields(cls, solr: SolrClient) -> AttrDefault:
def configure_fields(cls, solr: SolrClient) -> AttrDict:
"""Update the configured Solr instance schema to match
the configured fields.

Expand All @@ -266,8 +267,7 @@ def configure_fields(cls, solr: SolrClient) -> AttrDefault:
current_fields = [field.name for field in solr.schema.list_fields()]
configured_field_names = cls.get_field_names()

# use attrdict instead of defaultdict since we have attrmap
stats = AttrDefault(int, {})
stats = AttrDict(added=0, replaced=0, deleted=0)

for field_name in configured_field_names:
field_opts = getattr(cls, field_name)
Expand Down Expand Up @@ -310,7 +310,7 @@ def configure_copy_fields(cls, solr: SolrClient) -> None:
solr_copy_fields = solr.schema.list_copy_fields()
# create a dictionary lookup of existing copy fields from Solr
# source field -> list of destination fields
cp_fields = AttrDefault(list, {})
cp_fields = defaultdict(list)
for copyfield in solr_copy_fields:
cp_fields[copyfield.source].append(copyfield.dest)

Expand Down Expand Up @@ -341,25 +341,25 @@ def configure_copy_fields(cls, solr: SolrClient) -> None:
solr.schema.delete_copy_field(cp_field.source, cp_field.dest)

@classmethod
def configure_fieldtypes(cls, solr: SolrClient) -> AttrDefault:
def configure_fieldtypes(cls, solr: SolrClient) -> AttrDict:
"""Update the configured Solr instance so the schema includes
the configured field types, if any.

Args:
solr: A configured Solr instance.

Returns:
:class:`attrdict.AttrDefault` with counts for updated
:class:`addict.Dict` with counts for updated
and added field types.
"""

configured_field_types = cls.get_field_types()

stats = AttrDefault(int, {})
stats = AttrDict(updated=0, added=0)

# if none are configured, nothing to do
if not configured_field_types:
return stats
return AttrDict({})

# convert list return into dictionary keyed on field type name
current_field_types = {
Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from urllib.parse import urljoin

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr.solr.base import ClientBase, SolrConnectionNotFound

Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.parse import urljoin

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions parasolr/solr/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, List, Optional

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr import __version__ as parasol_version
from parasolr.solr.admin import CoreAdmin
Expand All @@ -20,7 +20,7 @@


class ParasolrDict(AttrDict):
"""A subclass of :class:`attrdict.AttrDict` that can convert itself to a
"""A subclass of :class:`addict.Dict` that can convert itself to a
regular dictionary."""

def as_dict(self):
Expand All @@ -35,7 +35,7 @@ def as_dict(self):
return copy

def __repr__(self):
"""Print a dict-like :meth:`repr`, without including 'AttrDict'."""
"""Print a dict-like :meth:`repr`, without including 'addict.Dict'."""
return "ParasolrDict(%s)" % super(AttrDict, self).__repr__()


Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.parse import urljoin

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr.solr.client import ClientBase

Expand Down
2 changes: 1 addition & 1 deletion parasolr/solr/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import Mock, patch

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr.solr.base import ClientBase

Expand Down
4 changes: 1 addition & 3 deletions parasolr/solr/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import OrderedDict

import requests
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr import __version__ as parasolr_ver
from parasolr.solr.admin import CoreAdmin
Expand Down Expand Up @@ -49,7 +49,6 @@ def test_repr(self):

class TestQueryResponse:
def test_init(self):

response = AttrDict(
{
"responseHeader": {"params": {"foo": "bar"}},
Expand Down Expand Up @@ -182,7 +181,6 @@ def test_query(self, test_client):

class TestGroupedResponse:
def test_init(self):

response = AttrDict(
{
"responseHeader": {"params": {"group": "true", "group.field": "A"}},
Expand Down
3 changes: 1 addition & 2 deletions parasolr/tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import Mock, patch

import pytest
from attrdict import AttrDict
from addict import Dict as AttrDict

from parasolr import schema
from parasolr.solr import SolrClient
Expand Down Expand Up @@ -164,7 +164,6 @@ class LocalTestSchema(schema.SolrSchema):
with patch.object(
LocalTestSchema, "configure_copy_fields"
) as mock_config_cp_fields:

# simulate only standard fields defined
mocksolr.schema.list_fields.return_value = [
AttrDict({"name": "id"}),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

REQUIREMENTS = ["requests", "attrdict", "progressbar2"]
REQUIREMENTS = ["requests", "addict", "progressbar2"]
# NOTE: progressbar only needed for django index script; make optional?
TEST_REQUIREMENTS = ["pytest>5.2", "pytest-cov"]
DEV_REQUIREMENTS = [
Expand Down
Loading