-
Notifications
You must be signed in to change notification settings - Fork 2
Reviews notes
Thor Whalen edited this page Jan 28, 2020
·
3 revisions
- Django's Model and Form definitions: https://docs.djangoproject.com/en/3.0/topics/db/models/ and https://docs.djangoproject.com/en/3.0/topics/forms/
- WTForm: https://wtforms.readthedocs.io/en/stable/, https://flask-wtf.readthedocs.io/en/stable/
- Marshmallow: https://marshmallow.readthedocs.io/en/stable/
- Audience: Data scientist / data engineer
Mappings consist
class FilenameMapper(Translator):
def private(self, public, context):
# filename -> full path
return os.path.join(context.base, public)
def public(self, private, context):
return os.path.relative(...)
class MyKVStore(KVStore):
class Meta:
store = FilesystemStore("/path/to/something")
keys = FilenameMapper()
values = TextMapper(encoding="utf8")
print(MyKVStore)
# MyKVStore(store=<default>
class MoreComplex(KVStore):
class Meta:
store = ....
keys = SpecialisedKeyValueTransformer(store)
values = keys.valuetranformer()
def wrap_kvs(
store, name, *,
key_of_id=None, id_of_key=None, obj_of_data=None, data_of_obj=None, postget=None)
class MyStore(Store):
def _id_of_key(self, k):
return _id
Projects:
- https://github.com/i2mint/py2store (https://pybay.com/speaker/thor-whalen/)
- https://github.com/thorwhalen/py2api
- https://github.com/thorwhalen/py2dash
- Sense of a feature not fitting with the architecture
- Pythonic API design?
-
Example: https://github.com/psf/black/blob/master/.pre-commit-config.yaml
-
black: https://github.com/psf/black
-
example project using the above: https://github.com/mjpieters/collegial
def __contains__(self, k) -> bool:
return self.store.__contains__(self._id_of_key(k))