dmesh-sdk
A native asynchronous SDK, provided as a part of dmesh-core for managing open data product and open data contract standards. dmesh-sdk provides the core abstractions and persistence layers needed to implement the Open Data Mesh standard.
🚀 Key Features
- Async First: Built from the ground up for high-performance asynchronous operations using
asyncioandpsycopg3. - Idempotent Operations: Safely publish and update data products and contracts.
- Validation: Built-in JSON Schema validation for Data Product and Data Contract specifications.
- Pluggable Architecture: Easily switch between storage backends (In-memory for testing, PostgreSQL for production).
- Factory-based Initialization: Simplified setup for complex repository configurations.
📦 Installation
pip install dmesh-sdk
🛠️ Quick Start
In-Memory persistency
import asyncio
from dmesh.sdk import AsyncSDK, RepositoryFactory
async def main():
# Initialize an In-Memory repository for testing
factory = RepositoryFactory().create(db_type="memory")
# Use the SDK as an asynchronous context manager
async with AsyncSDK(factory) as sdk:
# Register a data product (idempotent)
dp_spec = {
"domain": "finance",
"name": "ledger"
}
dp = await sdk.put_data_product(dp_spec)
stored_dp = await sdk.get_data_product(dp['id'])
print(f"Registered Data Product ID: {stored_dp['id']}")
print(f"Data Product: {stored_dp}")
dc_spec = {}
dc = await sdk.put_data_contract(dc_spec, stored_dp['id'])
stored_dc = await sdk.get_data_contract(dc['id'])
print(f"Registered Data Contract ID: {stored_dc['id']}")
print(f"Data Contract: {stored_dc}")
if __name__ == "__main__":
asyncio.run(main())
Registered Data Product ID: ba781283-1f14-5db2-a3f3-ce330da2c6dd
Data Product: {'domain': 'finance', 'name': 'ledger', 'apiVersion': 'v1.0.0', 'kind': 'DataProduct', 'version': 'v1.0.0', 'status': 'draft', 'id': 'ba781283-1f14-5db2-a3f3-ce330da2c6dd'}
Registered Data Contract ID: b9ee4bd2-205d-5eb8-8e13-1f9ee1f6ea26
Data Contract: {'id': 'b9ee4bd2-205d-5eb8-8e13-1f9ee1f6ea26', 'apiVersion': 'v3.1.0', 'kind': 'DataContract', 'version': 'v1.0.0', 'status': 'draft', 'dataProduct': 'ledger', 'domain': 'finance'}
Postgres persistency
To use the PostgreSQL backend, you need a running database.
Option 1: Fast Docker Run (Simplest)
Run a standalone Postgres instance:
docker run --name dmesh-postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres -e POSTGRES_DB=postgres -p 5432:5432 -d postgres:16
Option 2: Docker Compose (Monorepo)
If you have the full dmesh-core repository, you can use the included docker-compose.yml:
docker-compose up -d db
Configuration
Before running the code below, ensure your environment variables are set (either in a .env file or exported in your shell):
DMESH_DB__HOST=localhost
DMESH_DB__PORT=5432
DMESH_DB__USER=postgres
DMESH_DB__PASSWORD=postgres
DMESH_DB__NAME=postgres
import asyncio
import selectors
from dmesh.sdk import AsyncSDK, RepositoryFactory, get_settings
async def main():
# Load settings from config service
settings = get_settings()
# Initialize an In-Memory repository for testing
factory = RepositoryFactory().create_from_settings(db_type="postgres", settings=settings)
# Use the SDK as an asynchronous context manager
async with AsyncSDK(factory) as sdk:
# Register a data product (idempotent)
dp_spec = {
"domain": "finance",
"name": "ledger"
}
dp = await sdk.put_data_product(dp_spec)
stored_dp = await sdk.get_data_product(dp['id'])
print(f"Registered Data Product ID: {stored_dp['id']}")
print(f"Data Product: {stored_dp}")
dc_spec = {}
dc = await sdk.put_data_contract(dc_spec, stored_dp['id'])
stored_dc = await sdk.get_data_contract(dc['id'])
print(f"Registered Data Contract ID: {stored_dc['id']}")
print(f"Data Contract: {stored_dc}")
if __name__ == "__main__":
# Ensure correct loop factory for Windows if needed, though run() usually handles it
asyncio.run(main(), loop_factory=lambda: asyncio.SelectorEventLoop(selectors.SelectSelector()))
📖 Related Projects
- dmesh-cli: Command-line interface for managing your data mesh.
- dmesh-api: REST API (FastAPI based) server for data mesh orchestration.
- dmesh-viewer: Web-based interface for data mesh visualization.
📄 License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Metadata
Release files for dmesh-sdk 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dmesh_sdk-0.10.0.tar.gz | 40.3 kB | Without provenance | Details for dmesh_sdk-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dmesh_sdk-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for dmesh_sdk-0.10.0-py3-none-any.whl |
Total release size: 88.4 kB
Release files / dmesh_sdk-0.10.0.tar.gz
| Download URL | dmesh_sdk-0.10.0.tar.gz |
|---|---|
| Size | 40.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1898cd9d01013586e48ca59069280fd1b0354fd547d70fbfeb0b29d5e08c5fe
|
|
BLAKE2b-256 checksum How to use checksums |
2482f0862a5d77f9b2969178ec4f2fe17ed30213c950f0209f40cc35a9d22c3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / dmesh_sdk-0.10.0-py3-none-any.whl
| Download URL | dmesh_sdk-0.10.0-py3-none-any.whl |
|---|---|
| Size | 48.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac1f5d9216931f26517f54f41cee9c0465a078eb93c902509a728824dfb2c77a
|
|
BLAKE2b-256 checksum How to use checksums |
c7f7c66ee241e9103288a76fa4f0fd5999eee2199c906fae0f7a2caf0d3879a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for dmesh-sdk 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.