Skip to content

Commit

Permalink
chore: Upgrade dependencies (#39)
Browse files Browse the repository at this point in the history
* chore: Upgrade dependencies

* fix

* fix

* more fixes

* more fixes

* more fixes
  • Loading branch information
tibordp committed Oct 17, 2021
1 parent c3a336e commit 1fcaa7d
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 42 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:
strategy:
matrix:
environment:
- python-version: 3.8
- python-version: "3.9"
toxenv: check
- python-version: 3.8
- python-version: "3.9"
toxenv: docs
- python-version: 3.8
toxenv: py38
- python-version: 3.7
- python-version: "3.7"
toxenv: py37
- python-version: 3.9
- python-version: "3.8"
toxenv: py38
- python-version: "3.9"
toxenv: py39
- python-version: "3.10"
toxenv: py310
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.environment['python-version'] }}
Expand All @@ -40,7 +42,7 @@ jobs:
strategy:
matrix:
environment:
- python-version: 3.8
- python-version: "3.9"
toxenv: integration
services:
postgres:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sphinx:
formats: all

python:
version: 3.8
version: "3.9"
install:
- requirements: docs/requirements.txt
- method: pip
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ RUN apt-get update -y \
python3.7 \
python3.8 \
python3.9 \
python3.10 \
python3-pip \
python3.10-distutils \
python3-apt \
redis-tools \
postgresql-client \
mysql-client \
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Pyncette comes with an implementation for the following backends (used for persi
- SQLite (included)
- Redis (``pip install pyncette[redis]``)
- PostgreSQL (``pip install pyncette[postgres]``)
- MySQL 8.0+ (``pip install pyncette[mysql]``)
- MySQL 8.0+ (``pip install pyncette[mysql]`` - [does not work on Python 3.10](https://github.com/aio-libs/aiomysql/issues/624))
- Amazon DynamoDB (``pip install pyncette[dynamodb]``)

Pyncette imposes few requirements on the underlying datastores, so it can be extended to support other databases or
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ services:
context: .
dockerfile: Dockerfile.dev
command: bash
user: ${UID_GID-}
working_dir: /src
environment:
POSTGRES_URL: "postgres://postgres:password@postgres/pyncette"
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9

RUN apt-get update && apt-get install -y \
dumb-init \
Expand All @@ -14,4 +14,4 @@ EXPOSE 9699/tcp
ENV USE_UVLOOP=1

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["python", "entrypoint.py"]
CMD ["python", "entrypoint.py"]
2 changes: 2 additions & 0 deletions docs/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ The MySQL backend requires MySQL version 8.0+.
The table will be automatically initialized on startup if it does not exists unless ``mysql_skip_table_create`` is set to ``True``.

.. caution:: MySQL backend currently does not work with Python 3.10 due to an issue with an upstream library.


Amazon DynamoDB
---------------
Expand Down
8 changes: 4 additions & 4 deletions examples/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ async def populate(n: int, parallel: int) -> None:


async def run(
hit_count: RawValue,
staleness: RawValue,
hit_count: Any,
staleness: Any,
enabled_partitions: Optional[List[int]],
) -> None:

Expand Down Expand Up @@ -119,8 +119,8 @@ def setup(log_level: str) -> None:


async def report(
hit_counts: List[RawValue],
stalenesses: List[RawValue],
hit_counts: List[Any],
stalenesses: List[Any],
) -> None:
previous_hit_count = 0
previous_sample = time.perf_counter()
Expand Down
19 changes: 10 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def read(*names, **kwargs):


extras = {
"redis": ["aioredis>=1.3.1"],
"prometheus": ["prometheus_client>=0.8.0"],
"postgres": ["asyncpg>=0.20.1"],
"dynamodb": ["aioboto3>=8.3.0"],
"redis": ["aioredis>=2.0.0"],
"prometheus": ["prometheus_client>=0.11.0"],
"postgres": ["asyncpg>=0.24.0"],
"dynamodb": ["aioboto3>=9.2.2"],
"mysql": ["aiomysql>=0.0.21", "cryptography>=3.4.7"],
"uvloop": ["uvloop>=0.15.2"],
"uvloop": ["uvloop>=0.16.0"],
}

setup(
Expand Down Expand Up @@ -65,6 +65,7 @@ def read(*names, **kwargs):
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Utilities",
],
Expand All @@ -79,10 +80,10 @@ def read(*names, **kwargs):
python_requires=">=3.7",
install_requires=[
"typing-extensions>=3.7.4.2",
"croniter>=0.3.34",
"aiosqlite>=0.13.0",
"aiohttp>=3.6.2",
"python-dateutil>=2.8.1",
"croniter>=1.0.15",
"aiosqlite>=0.17.0",
"aiohttp>=3.7.4",
"python-dateutil>=2.8.2",
"coloredlogs",
],
extras_require={
Expand Down
3 changes: 2 additions & 1 deletion src/pyncette/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ async def dynamodb_repository(
**kwargs: Any,
) -> AsyncIterator[DynamoDBRepository]:
"""Factory context manager for Redis repository that initializes the connection to Redis"""
async with aioboto3.resource(
session = aioboto3.Session()
async with session.resource(
"dynamodb",
region_name=dynamodb_region_name,
endpoint_url=dynamodb_endpoint,
Expand Down
17 changes: 5 additions & 12 deletions src/pyncette/redis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ async def execute(

for _ in range(3):
try:
return await client.evalsha(self._sha, keys=keys, args=args)
except aioredis.ReplyError as err:
if str(err).startswith("NOSCRIPT"):
logger.warning("We seem to have lost the LUA script, reloading...")
await self.register(client)
else:
raise
return await client.evalsha(self._sha, len(keys), *keys, *args)
except aioredis.exceptions.NoScriptError:
logger.warning("We seem to have lost the LUA script, reloading...")
await self.register(client)

raise PyncetteException("Could not reload the Lua script.")

Expand Down Expand Up @@ -294,11 +291,7 @@ def _get_task_index_key(self, task: Optional[Task]) -> str:
@contextlib.asynccontextmanager
async def redis_repository(**kwargs: Any) -> AsyncIterator[RedisRepository]:
"""Factory context manager for Redis repository that initializes the connection to Redis"""
redis_pool = await aioredis.create_redis_pool(kwargs["redis_url"])
try:
async with aioredis.from_url(kwargs["redis_url"]) as redis_pool:
repository = RedisRepository(redis_pool, **kwargs)
await repository.register_scripts()
yield repository
finally:
redis_pool.close()
await redis_pool.wait_closed()
6 changes: 3 additions & 3 deletions tests/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ async def test_script_reload(monkeypatch):
monkeypatch.setattr(redis, "read_text", lambda *args: 'return { "SUCCESS" }')

redis_url = os.environ.get("REDIS_URL", "redis://localhost")
redis_pool = await aioredis.create_redis_pool(redis_url)
redis_pool = aioredis.from_url(redis_url)

lua_script = redis._LuaScript("dummy")
result = await lua_script.register(redis_pool)
await redis_pool.execute("SCRIPT", "FLUSH", "SYNC")
await redis_pool.execute_command("SCRIPT", "FLUSH", "SYNC")

result = await lua_script.execute(redis_pool, [], [])

Expand All @@ -29,7 +29,7 @@ async def test_script_register(monkeypatch):
monkeypatch.setattr(redis, "read_text", lambda *args: 'return { "SUCCESS" }')

redis_url = os.environ.get("REDIS_URL", "redis://localhost")
redis_pool = await aioredis.create_redis_pool(redis_url)
redis_pool = aioredis.from_url(redis_url)

lua_script = redis._LuaScript("dummy")
result = await lua_script.execute(redis_pool, [], [])
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ envlist =
clean,
check,
docs,
{py37,py38,py39},
{py37,py38,py39,py310},
integration,
report
ignore_basepython_conflict = true
Expand All @@ -24,6 +24,7 @@ basepython =
py37: {env:TOXPYTHON:python3.7}
py38: {env:TOXPYTHON:python3.8}
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
{integration,docs}: {env:TOXPYTHON:python3}
{bootstrap,clean,check,report,fmt}: {env:TOXPYTHON:python3}
setenv =
Expand Down Expand Up @@ -59,6 +60,9 @@ deps =
pygments
mypy
isort
types-python-dateutil
types-croniter
types-PyMySQL
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
Expand Down

0 comments on commit 1fcaa7d

Please sign in to comment.