Make your code reactive; Turn plain JSONs into a live data store, two-way synced with Python objects.
Project description
Syncwave
Make your code reactive; Turn plain JSONs into a live data store, two-way synced with Python objects.
⚠️ Warning
Syncwave is under active development. Until version 1.0, any minor release (
0.x) may introduce breaking API changes. Pin the exact version to use in production.Version 1.0 will be released when the library is stable, feature-complete, and tested.
Getting Started
Install from PyPI:
# pip
pip install syncwave
# uv
uv add syncwave
Bind a Pydantic model to a JSON file with @syncwave.register. Syncwave automatically synchronizes the file with your in-memory objects.
from pydantic import BaseModel
from syncwave import Syncwave
# 1. Initialise Syncwave with a directory to hold the JSON files.
syncwave = Syncwave(data_dir="data")
# 2. Define and register a model
# This also creates a JSON file at `data/customers.json` if it doesn't exist.
# Otherwise, the data is loaded into the `syncwave` instance.
@syncwave.register(name="customers", key="id")
class Customer(BaseModel):
id: int
name: str
age: int
# syncwave acts as a read-only dict with:
# keys -> collection name (e.g. "customers")
# values -> corresponding SyncStore
# A SyncStore also acts as a read-only dict:
# keys -> model's key field (e.g. `id`)
# values -> live Pydantic model instances
# 3. Create and mutate instances like you would with normal Pydantic objects.
john = Customer(id=1, name="John Doe", age=30) # Automatically inserted in JSON
john.age = 31 # Automatically updated in JSON
# 4. Delete instances with `SyncStore.delete(key)`.
syncwave["customers"].delete(1) # Removed from syncwave and JSON
# 5. External edits propagate automatically.
# First, let's add a new customer to populate the JSON file.
Customer(id=2, name="Jane Doe", age=25)
input("Now edit 'data/customers.json' and press Enter…")
print(syncwave)
License
Syncwave is licensed under the MIT License.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syncwave-0.1.1.tar.gz.
File metadata
- Download URL: syncwave-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d47b856599ca349024db623ee7c318fcb9ae7a97793b231e229904b98c472cd
|
|
| MD5 |
60f106be2d881076bf869f3464bd2af7
|
|
| BLAKE2b-256 |
5f77b128bbc2449cff94136e60d74b7beb99a2af65a7410ea4eaaea5a38f0473
|
Provenance
The following attestation bundles were made for syncwave-0.1.1.tar.gz:
Publisher:
release.yml on iannitello/syncwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syncwave-0.1.1.tar.gz -
Subject digest:
9d47b856599ca349024db623ee7c318fcb9ae7a97793b231e229904b98c472cd - Sigstore transparency entry: 391543441
- Sigstore integration time:
-
Permalink:
iannitello/syncwave@71be0f343af24a68597bd7b25981175e9a4ef1cf -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/iannitello
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@71be0f343af24a68597bd7b25981175e9a4ef1cf -
Trigger Event:
release
-
Statement type:
File details
Details for the file syncwave-0.1.1-py3-none-any.whl.
File metadata
- Download URL: syncwave-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82a0ddf37081568fd1e801061f1e69d3b85111ca25f88bac6aeeae9565664204
|
|
| MD5 |
0061c02c40245aa712915a4eaeb55b2e
|
|
| BLAKE2b-256 |
2af89e67aa87cc63125ab8b4dcf8749126ccb7e2fe605ac43deaf3f54a702173
|
Provenance
The following attestation bundles were made for syncwave-0.1.1-py3-none-any.whl:
Publisher:
release.yml on iannitello/syncwave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
syncwave-0.1.1-py3-none-any.whl -
Subject digest:
82a0ddf37081568fd1e801061f1e69d3b85111ca25f88bac6aeeae9565664204 - Sigstore transparency entry: 391543472
- Sigstore integration time:
-
Permalink:
iannitello/syncwave@71be0f343af24a68597bd7b25981175e9a4ef1cf -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/iannitello
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@71be0f343af24a68597bd7b25981175e9a4ef1cf -
Trigger Event:
release
-
Statement type: