A library for managing function calls in specific order, to avoid code repeating. Similar to Apache Hamilton but simpler.
Project description
Weavelet
A library for managing function calls in specific order, to avoid code repeating. Similar to Apache Hamilton but simpler without 3rd party dependencies if not needed.
Features
- Simple DAG orchestration: Build execution graphs based on function signatures
- Decorator-based: Register functions as nodes using the
@node()decorator - Cross-module support: Nodes can be spread across multiple files
- Parameter injection: Automatic dependency resolution and parameter passing
- Result caching: Avoid recomputing expensive operations
- Pure Python: No external dependencies for core functionality
Quick Start
Installation
pip install weavelet
Basic Usage
Create nodes in any Python file:
# a_nodes.py
from weavelet import node
@node()
def auth_token(api_key: str) -> str:
return f"Bearer {api_key}"
@node()
def user_profile(auth_token: str, user_id: int) -> dict:
return {"id": user_id, "name": "Ala"}
@node()
def make_greeting(user_profile: dict) -> str:
return f"Hello, {user_profile['name']}!"
Execute the DAG:
# main.py
from weavelet import Weave
import a_nodes
weave = Weave()
weave.include(a_nodes)
weave.params.add("api_key", "xyz")
weave.params.add("user_id", 128)
result = weave.run("make_greeting") # -> "Hello, Ala!"
print(result)
How it Works
Weavelet automatically builds a DAG based on function signatures:
- Function parameters that match other node names become dependencies
- Parameters not matching node names are injected from
weave.params - Execution order is determined through topological sorting
- Results are cached to avoid redundant computation
Requirements
- Python >=3.12
- No external dependencies for core functionality
Development
Uses uv as package manager with TDD approach.
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
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 weavelet-0.0.1.tar.gz.
File metadata
- Download URL: weavelet-0.0.1.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f7c8a939332a8bc50c637047e82f7a14b1ec3fd949ab437ca2332cbed029f3
|
|
| MD5 |
5905be4dc98cabe53342bc237b581c93
|
|
| BLAKE2b-256 |
63d0fc46139e034822f856a8fe45f9226f69dee2eed185185693cdd227a1ada1
|
File details
Details for the file weavelet-0.0.1-py3-none-any.whl.
File metadata
- Download URL: weavelet-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0d59e5d50d33d102d415d0b5d4da950eac23f71aec5c428d088acd54723df6
|
|
| MD5 |
7c0ac87fa9df2a4a67d567c0ecc35c7c
|
|
| BLAKE2b-256 |
ca89ad023b06c74d00342edafda4bb4f2e69b9c34193762f508925e70a0ebca5
|