Skip to content

Commit b2c2dd9

Browse files
author
Andrew Brookins
committed
WIP on async - test failure due to closed event loop
1 parent 0f9f7aa commit b2c2dd9

22 files changed

+348
-190
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NAME := redis_developer
1+
NAME := redis_om
22
INSTALL_STAMP := .install.stamp
33
POETRY := $(shell command -v poetry 2> /dev/null)
44

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Check out this example:
5252
import datetime
5353
from typing import Optional
5454

55-
from redis_developer.model import (
55+
from redis_om.model import (
5656
EmbeddedJsonModel,
5757
JsonModel,
5858
Field,
@@ -172,9 +172,9 @@ Don't want to run Redis yourself? RediSearch and RedisJSON are also available on
172172

173173
We'd love your contributions!
174174

175-
**Bug reports** are especially helpful at this stage of the project. [You can open a bug report on GitHub](https://github.com/redis-developer/redis-developer-python/issues/new).
175+
**Bug reports** are especially helpful at this stage of the project. [You can open a bug report on GitHub](https://github.com/redis-om/redis-om-python/issues/new).
176176

177-
You can also **contribute documentation** -- or just let us know if something needs more detail. [Open an issue on GitHub](https://github.com/redis-developer/redis-developer-python/issues/new) to get started.
177+
You can also **contribute documentation** -- or just let us know if something needs more detail. [Open an issue on GitHub](https://github.com/redis-om/redis-om-python/issues/new) to get started.
178178

179179
## License
180180

@@ -184,17 +184,17 @@ Redis OM is [MIT licensed][license-url].
184184

185185
[version-svg]: https://img.shields.io/pypi/v/redis-om?style=flat-square
186186
[package-url]: https://pypi.org/project/redis-om/
187-
[ci-svg]: https://img.shields.io/github/workflow/status/redis-developer/redis-developer-python/python?style=flat-square
188-
[ci-url]: https://github.com/redis-developer/redis-developer-python/actions/workflows/build.yml
187+
[ci-svg]: https://img.shields.io/github/workflow/status/redis-om/redis-om-python/python?style=flat-square
188+
[ci-url]: https://github.com/redis-om/redis-om-python/actions/workflows/build.yml
189189
[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
190190
[license-url]: LICENSE
191191

192192
<!-- Links -->
193193

194-
[redis-developer-website]: https://developer.redis.com
195-
[redis-om-js]: https://github.com/redis-developer/redis-om-js
196-
[redis-om-dotnet]: https://github.com/redis-developer/redis-om-dotnet
197-
[redis-om-spring]: https://github.com/redis-developer/redis-om-spring
194+
[redis-om-website]: https://developer.redis.com
195+
[redis-om-js]: https://github.com/redis-om/redis-om-js
196+
[redis-om-dotnet]: https://github.com/redis-om/redis-om-dotnet
197+
[redis-om-spring]: https://github.com/redis-om/redis-om-spring
198198
[redisearch-url]: https://oss.redis.com/redisearch/
199199
[redis-json-url]: https://oss.redis.com/redisjson/
200200
[pydantic-url]: https://github.com/samuelcolvin/pydantic

build.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import unasync
2+
3+
4+
def build(setup_kwargs):
5+
setup_kwargs.update(
6+
{"cmdclass": {'build_py': unasync.cmdclass_build_py(rules=[
7+
unasync.Rule("/aredis_om/", "/redis_om/"),
8+
unasync.Rule("/aredis_om/tests/", "/redis_om/tests/", additional_replacements={"aredis_om": "redis_om"}),
9+
])}}
10+
)

poetry.lock

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[tool.poetry]
2-
name = "redis-developer"
2+
name = "redis-om"
33
version = "0.1.0"
44
description = "A high-level library containing useful Redis abstractions and tools, like an ORM and leaderboard."
55
authors = ["Andrew Brookins <[email protected]>"]
66
license = "MIT"
7+
build = "build.py"
78

89
[tool.poetry.dependencies]
910
python = "^3.8"
@@ -30,10 +31,11 @@ bandit = "^1.7.0"
3031
coverage = "^6.0.2"
3132
pytest-cov = "^3.0.0"
3233
pytest-xdist = "^2.4.0"
33-
34+
unasync = "^0.5.0"
35+
pytest-asyncio = "^0.16.0"
3436

3537
[tool.poetry.scripts]
36-
migrate = "redis_developer.orm.cli.migrate:migrate"
38+
migrate = "redis_om.orm.cli.migrate:migrate"
3739

3840
[build-system]
3941
requires = ["poetry-core>=1.0.0"]
File renamed without changes.
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import os
2+
from typing import Union
23

34
import dotenv
5+
import aioredis
46
import redis
5-
7+
from redis_om.unasync_util import ASYNC_MODE
68

79
dotenv.load_dotenv()
810

911
URL = os.environ.get("REDIS_OM_URL", None)
12+
if ASYNC_MODE:
13+
client = aioredis.Redis
14+
else:
15+
client = redis.Redis
1016

1117

12-
def get_redis_connection(**kwargs) -> redis.Redis:
18+
def get_redis_connection(**kwargs) -> Union[aioredis.Redis, redis.Redis]:
1319
# If someone passed in a 'url' parameter, or specified a REDIS_OM_URL
1420
# environment variable, we'll create the Redis client from the URL.
1521
url = kwargs.pop("url", URL)
1622
if url:
17-
return redis.from_url(url, **kwargs)
23+
return client.from_url(url, **kwargs)
1824

1925
# Decode from UTF-8 by default
2026
if "decode_responses" not in kwargs:
2127
kwargs["decode_responses"] = True
22-
return redis.Redis(**kwargs)
28+
return client(**kwargs)
File renamed without changes.

redis_developer/model/cli/migrate.py renamed to redis_om/model/cli/migrate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import click
22

3-
from redis_developer.model.migrations.migrator import Migrator
3+
from redis_om.model.migrations.migrator import Migrator
44

55

66
@click.command()
7-
@click.option("--module", default="redis_developer")
7+
@click.option("--module", default="redis_om")
88
def migrate(module):
99
migrator = Migrator(module)
1010

0 commit comments

Comments
 (0)