A simple key-value store for use with Prefect.
Project description
prefect-kv
Welcome!
A simple key-value store for use with Prefect.
Getting Started
Python setup
Requires an installation of Python 3.7+.
We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.
Installation
Install prefect-kv
with pip
:
pip install prefect-kv
Using a key-value store
The entire store is saved to Prefect's API each time a key is updated. Each time a key is read, the entire store is loaded from Prefect's API. This exposes a simple way to persist and retrieve values across flow runs and tasks, independently of your dataflow.
from prefect_kv import KVStore
# Create a new KV store named 'demo-store'
store = KVStore(name="demo-store")
# Set a value in the store
store.set("foo", "test")
# Get a value from the store
print(store.get("foo"))
# Get a value from the store with a default
print(store.get("does-not-exist, "that's okay!"))
# Set a value in the store using item syntax
store["bar"] = "another test"
# Get a value from the store using item syntax
print(store["bar"])
# View the whole store
print(f"Here's the whole thing: {store.dict()}")
If you exit the process and create a new store object with same name, you will still be able to access your values:
from prefect_kv import KVStore
# Get the existing KV store named 'demo-store'
store = KVStore(name="demo-store")
print(store["foo"])
print(store["bar"])
Resources
If you encounter any bugs while using prefect-kv
, feel free to open an issue in the prefect-kv repository.
If you have any questions or issues while using prefect-kv
, you can find help in either the Prefect Discourse forum or the Prefect Slack community.
Feel free to ⭐️ or watch prefect-kv
for updates too!
Development
If you'd like to install a version of prefect-kv
for development, clone the repository and perform an editable install with pip
:
git clone https://github.com/madkinsz/prefect-kv.git
cd prefect-kv/
pip install -e ".[dev]"
# Install linting pre-commit hooks
pre-commit install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file prefect-kv-0.1.0.tar.gz
.
File metadata
- Download URL: prefect-kv-0.1.0.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bbb35c817cd79d0a9b4b423a0548aad9440ca41fe3aeb36dea5acaf713fc83b |
|
MD5 | e0e54304a50334087d46563b8e1b68d1 |
|
BLAKE2b-256 | 3918eb2a0ffb24935778a331e6ae6bfdf667d29abd874b01ce9059f4155876b7 |
File details
Details for the file prefect_kv-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: prefect_kv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9461ac38a3cc7fba4803e186a3aee4f9dc4ebbb58a88bf4b2e22e048e7e8496a |
|
MD5 | 0f716dc7516e1879bc8dc0c318bb70f4 |
|
BLAKE2b-256 | 432ac11fa87f0eda6229b23a8b49cb74f000a6e9446f39be555cfb87fd5bfac5 |