No project description provided
Project description
dml-util
Overview
dml-util provides utilities and adapters for DaggerML, enabling seamless function wrapping, artifact storage, and execution in local and cloud environments. It is designed to work with the daggerml ecosystem.
Front-End vs Back-End
- Front-End (User Interface):
- The main entrypoints for most users are the
funkifydecorator,S3Store, and the included adapters/runners (e.g. conda, hatch, ssh, batch -- all viafunkify). - These let you wrap Python functions as DAG nodes, store artifacts, and run code in a variety of environments with minimal setup.
- Beginners should start by using these included adapters and runners, as shown in the examples.
- The main entrypoints for most users are the
- Back-End (Advanced/Extensible):
- The back-end consists of the adapters and runners themselves, which handle execution, state, and integration with cloud/local resources.
- Advanced users can write their own adapters or runners by following the patterns in
src/dml_util/adapters/andsrc/dml_util/runners/. - See the source and docstrings for guidance.
Installation
pip install dml-util
Usage
Wrapping Functions as DAG Nodes
from daggerml import Dml
from dml_util import funkify
@funkify
def add_numbers(dag):
"""Add numbers together.
Parameters
----------
dag : DmlDag
The DAG context provided by DaggerML.
Returns
-------
int
The sum of the input numbers.
"""
dag.result = sum(dag.argv[1:].value())
return dag.result
dml = Dml()
with dml.new("simple_addition") as dag:
dag.add_fn = add_numbers
dag.sum = dag.add_fn(1, 2, 3)
print(dag.sum.value()) # Output: 6
S3 Storage
from dml_util import S3Store
s3 = S3Store()
uri = s3.put(b"my data", name="foo.txt").uri
print(uri) # s3://<bucket>/<prefix>/data/foo.txt
Advanced: Docker, Batch, and ECR
from dml_util import dkr_build, funkify, S3Store
@funkify
def fn(dag):
*args, denom = dag.argv[1:].value()
dag.result = sum(args) / denom
s3 = S3Store()
tar = s3.tar(dml, ".")
img = dkr_build(tar, ["--platform", "linux/amd64", "-f", "Dockerfile"])
batch_fn = funkify(fn, data={"image": img.value()}, adapter=dag.batch.value())
result = batch_fn(1, 2, 3, 4)
Documentation
- All public functions and classes use numpy style docstrings.
- See the python-lib GitHub repo for core DaggerML usage.
- See the daggerml-cli GitHub repo for CLI usage.
License
dml-util is distributed under the terms of the MIT license.
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 dml_util-0.0.19.tar.gz.
File metadata
- Download URL: dml_util-0.0.19.tar.gz
- Upload date:
- Size: 72.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3f8bc8714a80b160ec8183e7838c404414b2ad4e9dd176d1788fd15a4811ec
|
|
| MD5 |
5703212074c373c00bd662c0c43cee9b
|
|
| BLAKE2b-256 |
ba4e6d2ebdce514f5e09469791309233ea6d421d393be8319fe81da9ef6a8ef0
|
File details
Details for the file dml_util-0.0.19-py3-none-any.whl.
File metadata
- Download URL: dml_util-0.0.19-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc97b5741734eee59dbc7664a6fbf4e32f7791c1ef7257065f2032e7508f1758
|
|
| MD5 |
f1b67aef1e71c9e18a2a7ac291dc5918
|
|
| BLAKE2b-256 |
06fdd2ab95858a851e2cd7ef4926b866422d8b809139ffd9d0afbcdb3ec00946
|