Skip to main content

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

syncwave-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syncwave-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file syncwave-0.1.2.tar.gz.

File metadata

  • Download URL: syncwave-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for syncwave-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2cf5e34c14c855bbded9124309e731657e349d68a669caec4f2ba9a09a94ede5
MD5 2349ff0b2ed20864453374b8fd36a38c
BLAKE2b-256 5981aff89436ffe5996bdd304b3dd88bd4276ca2b4f6f4f7df580009d8b38b80

See more details on using hashes here.

Provenance

The following attestation bundles were made for syncwave-0.1.2.tar.gz:

Publisher: release.yml on iannitello/syncwave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file syncwave-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: syncwave-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for syncwave-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94b9d654636e45be877c9207f494e2f92165fb2152226c50f57ccc13f3c6c9a7
MD5 96897ecd2a50f8b342de850ac08ca315
BLAKE2b-256 0fdf2cc4e6518f3c810c9a643485e60244a9169161e3ea8de4bb2905a0a534a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for syncwave-0.1.2-py3-none-any.whl:

Publisher: release.yml on iannitello/syncwave

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page