Skip to content

Commit a86b3c2

Browse files
authored
Merge branch 'main' into dependabot/github_actions/codecov/codecov-action-5
2 parents 4d0b915 + cd117b2 commit a86b3c2

18 files changed

+673
-408
lines changed

.github/wordlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ validator
5656
validators
5757
virtualenv
5858
http
59+
AMR
60+
EntraID
61+
entraid
62+
metamodel

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
strategy:
7777
matrix:
7878
os: [ ubuntu-latest ]
79-
pyver: [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.9", "pypy-3.10" ]
79+
pyver: [ "3.9", "3.10", "3.11", "3.12", "pypy-3.9", "pypy-3.10" ]
8080
redisstack: [ "latest" ]
8181
fail-fast: false
8282
services:

.github/workflows/pypi-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
- name: Set Poetry config
4444
run: |
45-
pip install --upgrade pip poetry
45+
pip install --upgrade pip poetry==1.8.4
4646
poetry config virtualenvs.in-project false
4747
poetry config virtualenvs.path ~/.virtualenvs
4848
poetry export --dev --without-hashes -o requirements.txt

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div align="center">
22
<br/>
33
<br/>
4-
<img width="360" src="https://raw.githubusercontent.com/redis-developer/redis-om-python/main/images/logo.svg?token=AAAXXHUYL6RHPESRRAMBJOLBSVQXE" alt="Redis OM" />
4+
<img width="360" src="docs/images/logo.svg" alt="Redis OM" />
55
<br/>
66
<br/>
77
</div>
@@ -370,6 +370,36 @@ You can run these modules in your self-hosted Redis deployment, or you can use [
370370

371371
To learn more, read [our documentation](docs/redis_modules.md).
372372

373+
## Connecting to Azure Managed Redis with EntraID
374+
375+
Once you have EntraID setup for your Azure Managed Redis (AMR) deployment, you can use Redis OM Python with it by leveraging the [redis-py-entraid](https://github.com/redis/redis-py-entraid) library.
376+
Simply install the library with:
377+
378+
```
379+
pip install redis-entraid
380+
```
381+
382+
Then you'll initialize your credentials provider, connect to redis, and pass the database object into your metamodel:
383+
384+
```python
385+
386+
from redis import Redis
387+
from redis_entraid.cred_provider import create_from_default_azure_credential
388+
from redis_om import HashModel, Field
389+
credential_provider = create_from_default_azure_credential(
390+
("https://redis.azure.com/.default",),
391+
)
392+
393+
db = Redis(host="cluster-name.region.redis.azure.net", port=10000, ssl=True, ssl_cert_reqs=None, credential_provider=credential_provider)
394+
db.flushdb()
395+
class User(HashModel):
396+
first_name: str
397+
last_name: str = Field(index=True)
398+
399+
class Meta:
400+
database = db
401+
```
402+
373403
## ❤️ Contributing
374404

375405
We'd love your contributions!

aredis_om/_compat.py

Lines changed: 0 additions & 99 deletions
This file was deleted.

aredis_om/checks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from functools import lru_cache
2-
from typing import List
32

43
from aredis_om.connections import get_redis_connection
54

aredis_om/model/encoders.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
from types import GeneratorType
3232
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
3333

34-
from .._compat import ENCODERS_BY_TYPE, BaseModel
34+
from pydantic import BaseModel
35+
from pydantic.deprecated.json import ENCODERS_BY_TYPE
36+
from pydantic_core import PydanticUndefined
3537

3638

3739
SetIntStr = Set[Union[int, str]]
@@ -72,7 +74,7 @@ def jsonable_encoder(
7274
encoder = getattr(obj.__config__, "json_encoders", {})
7375
if custom_encoder:
7476
encoder.update(custom_encoder)
75-
obj_dict = obj.dict(
77+
obj_dict = obj.model_dump(
7678
include=include, # type: ignore # in Pydantic
7779
exclude=exclude, # type: ignore # in Pydantic
7880
by_alias=by_alias,
@@ -106,6 +108,7 @@ def jsonable_encoder(
106108
or (not isinstance(key, str))
107109
or (not key.startswith("_sa"))
108110
)
111+
and value is not PydanticUndefined
109112
and (value is not None or not exclude_none)
110113
and ((include and key in include) or not exclude or key not in exclude)
111114
):

aredis_om/model/migrations/migrator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ async def detect_migrations(self):
130130
continue
131131

132132
stored_hash = await conn.get(hash_key)
133+
if isinstance(stored_hash, bytes):
134+
stored_hash = stored_hash.decode("utf-8")
135+
133136
schema_out_of_date = current_hash != stored_hash
134137

135138
if schema_out_of_date:

0 commit comments

Comments
 (0)