Latest Results
docs: migrate tutorials and examples to @daft.func / @daft.cls (#6729)
## Changes Made
Migrates every user-facing tutorial and example that still taught the
deprecated `@daft.udf` decorator onto the new `@daft.func` / `@daft.cls`
API, per
[docs/custom-code/migration.md](https://docs.daft.ai/en/stable/custom-code/migration/).
Without this, anyone (including LLM agents) reading the repo for
reference code would learn the legacy API.
### Files migrated (15)
**Docs examples + modality guide (6):**
- `docs/examples/text-embeddings.md`
- `docs/examples/image-generation.md`
- `docs/examples/document-processing.md`
- `docs/examples/llms-red-pajamas.md`
- `docs/examples/mnist.md`
- `docs/modalities/images.md`
**Tutorial notebooks (7):**
- `tutorials/text_to_image/text_to_image_generation.ipynb`
- `tutorials/mnist.ipynb`
- `tutorials/embeddings/daft_tutorial_embeddings_stackexchange.ipynb`
- `tutorials/document_processing/document_processing_tutorial.ipynb`
-
`tutorials/delta_lake/{1-local-image-batch-inference,2-distributed-batch-inference}.ipynb`
- `tutorials/talks_and_demos/data-ai-summit-2024.ipynb`
**Other (2):**
- `benchmarking/common_crawl/extract.py` (function UDF →
`@daft.func.batch`)
- `daft/dataframe/dataframe.py` (`map_groups` docstring example)
### Translations applied
- Function `@daft.udf(...)` → `@daft.func` / `@daft.func.batch`
(row-wise where the body iterates per row, batch where it uses
`daft.Series`).
- Class `@daft.udf(...)` → `@daft.cls(...)` with
`@daft.method.batch(return_dtype=...)` on `__call__`.
- `concurrency=N` → `max_concurrency=N` (with a prose note in
`text-embeddings.md` where the semantic drift from "exactly N instances"
to "cap at N" is material to the tuning advice).
- `num_gpus=N` → `gpus=N` on `@daft.cls`.
- `ClassUDF.with_init_args(...)` → constructor args on instantiation
(`inst = ClassUDF(...); inst(col)`).
- `ClassUDF.override_options(num_gpus=1)` → `@daft.cls(gpus=1 if USE_GPU
else 0)` on the decorator (e.g. `image-generation.md`).
- `talks_and_demos`: `run_gpt4o_on_urls` is now `async def` +
`@daft.func(max_concurrency=16)` using `aiohttp` — the textbook per-row
async pattern the v2 API enables. `generate_presigned_url` is plain
row-wise `@daft.func` with inferred return dtype from type hints.
- `delta_lake/1`: removed a broken "subclass with `@daft.cls(gpus=1)`"
recipe (subclassing a decorated class bypasses the wrapper at runtime —
confirmed). Replaced with the direct recipe.
### Verification
- Smoke-tested each migration pattern end-to-end (class UDF, constructor
args, `gpus=0/1`, `max_concurrency`, async + `max_concurrency`, sync
rejection of `max_concurrency`, multi-arg batch method).
- `dataframe.map_groups` doctest still passes after the `@daft.udf` →
`@daft.func.batch` swap in the docstring.
- All touched `.py` files parse; md / notebook code blocks parse.
- `daft.cls` / `daft.method.batch` / `daft.func` / `daft.func.batch`
resolve at runtime.
### Left untouched (intentional)
- `daft/udf/legacy.py`, `tests/expressions/test_legacy_udf.py`,
`tests/test_resource_requests.py`, `tests/ray/test_udf_ray_options.py`,
`tests/sql/test_coalesce.py`, `tests/integration/*` — they test the
legacy behavior.
- `docs/custom-code/udfs.md`, `docs/api/udf.md`,
`docs/custom-code/migration.md` — legacy reference page and migration
guide (the before/after examples must stay).
## Related Issues
Not tied to an open issue.
---------
Co-authored-by: Srinivas Lade <srinulade1@gmail.com> Latest Branches
0%
0%
0%
desmond/bump-deltalake-floor-1.6.0 © 2026 CodSpeed Technology