Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Brookins abrookins

View GitHub Profile
@abrookins
abrookins / embedded_json.py
Created Nov 20, 2021
Embedded JSON models with Redis OM for Python
View embedded_json.py
import datetime
from typing import Optional
from redis_om import (
EmbeddedJsonModel,
JsonModel,
Field,
Migrator,
)
from redis_om import get_redis_connection
@abrookins
abrookins / querying.py
Created Nov 20, 2021
Rich query expressions with Redis OM for Python
View querying.py
import datetime
from typing import Optional
from pydantic import EmailStr
from redis_om import (
Field,
HashModel,
Migrator
)
@abrookins
abrookins / validation.py
Created Nov 20, 2021
Data validation with Redis OM for Python
View validation.py
import datetime
from typing import Optional
from pydantic import EmailStr, ValidationError
from redis_om import HashModel
class Customer(HashModel):
first_name: str
@abrookins
abrookins / models.py
Created Nov 19, 2021
Declarative Models with Redis OM
View models.py
import datetime
from typing import Optional
from pydantic import EmailStr
from redis_om import HashModel
class Customer(HashModel):
first_name: str
@abrookins
abrookins / kant-light.icls
Last active Aug 12, 2020
Kant Light - A light monochrome color scheme for Intellij editors. Inspired by Verdandi.
View kant-light.icls
Moved to: https://github.com/abrookins/kant
@abrookins
abrookins / kant-light.icls
Created Aug 11, 2020
Kant Light - A light monochrome color scheme for Intellij editors.
View kant-light.icls
This file has been truncated, but you can view the full file.
<scheme name="Kant" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2020-08-11T14:43:37</property>
<property name="ide">Python</property>
<property name="ideVersion">2020.2.0.0</property>
<property name="modified">2020-08-11T14:43:46</property>
<property name="originalScheme">Kant</property>
</metaInfo>
@abrookins
abrookins / kant-dark.icls
Last active Aug 12, 2020
Kant Dark - A dark monochrome color scheme for Intellij editors. Inspired by Verdandi.
View kant-dark.icls
Moved to: https://github.com/abrookins/kant
View schema.py
SiteStatsSchema = marshmallow_dataclass.class_schema(SiteStats)
View ipython3.py
In [13]: SiteStatsSchema().load({"meter_reading_count": "hey"})
[…]
ValidationError: {'meter_reading_count': ['Not a valid integer.'], 'min_wh_generated': ['Missing data for required field.'], 'last_reporting_time': ['Missing data for required field.'], 'max_wh_generated': ['Missing data for required field.'], 'max_capacity': ['Missing data for required field.']}
View ipython3.py
In [10]: stats2 = SiteStatsSchema().load(data)
In [11]: stats == stats2
Out[11]: True