Skip to main content

No project description provided

Project description

dml-util

PyPI - Version PyPI - Python Version


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 funkify decorator, S3Store, and the included adapters/runners (e.g. conda, hatch, ssh, batch -- all via funkify).
    • 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.
  • 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/ and src/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

License

dml-util is distributed under the terms of 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

dml_util-0.0.21.post1.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

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

dml_util-0.0.21.post1-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file dml_util-0.0.21.post1.tar.gz.

File metadata

  • Download URL: dml_util-0.0.21.post1.tar.gz
  • Upload date:
  • Size: 73.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for dml_util-0.0.21.post1.tar.gz
Algorithm Hash digest
SHA256 433fc3786cdb89007a2e7f9a6734e5bd5da5c5af93f48047fd1a3bbe7b56761c
MD5 fc112820352ea1597bc468f66716cc58
BLAKE2b-256 3c93bb31d9b88aeb5190a5bc2cc31ab7c703704ee51d707948533eb12dc38e72

See more details on using hashes here.

File details

Details for the file dml_util-0.0.21.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for dml_util-0.0.21.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 262ee3a80ab146e0862e7dd7887885cd8bc797ca96908da6ef4b167ba9cab683
MD5 0e08ee6c663fe578b63d2add53b92244
BLAKE2b-256 d1056b13d3a4f4d2044bff182eb02a9eca1473f57764f15b9623cd0cf44d0e78

See more details on using hashes here.

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