Skip to content

Commit 504c38e

Browse files
authored
improve setup docs to make it cleat that callable is expected (#1116)
1 parent 52c56c4 commit 504c38e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/datachain/lib/dc/datachain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,11 @@ def setup(self, **kwargs) -> "Self":
20822082
Use before running map/gen/agg/batch_map to save an object and pass it as an
20832083
argument to the UDF.
20842084
2085+
The value must be a callable (a `lambda: <value>` syntax can be used to quickly
2086+
create one) that returns the object to be passed to the UDF. It is evaluated
2087+
lazily when UDF is running, in case of multiple machines the callable is run on
2088+
a worker machine.
2089+
20852090
Example:
20862091
```py
20872092
import anthropic
@@ -2091,7 +2096,11 @@ def setup(self, **kwargs) -> "Self":
20912096
(
20922097
dc.read_storage(DATA, type="text")
20932098
.settings(parallel=4, cache=True)
2099+
2100+
# Setup Anthropic client and pass it to the UDF below automatically
2101+
# The value is callable (see the note above)
20942102
.setup(client=lambda: anthropic.Anthropic(api_key=API_KEY))
2103+
20952104
.map(
20962105
claude=lambda client, file: client.messages.create(
20972106
model=MODEL,

0 commit comments

Comments
 (0)