Transform any Python function into a scalable, resilient, cached service with one line of code.
import slay
# Store data
ref = slay.put("some data")
data = slay.get(ref)
# Store and execute a function
fn = slay.put(lambda x: x + 1)
result_ref = fn(5)
result = result_ref.get() # Returns 6
# Parallel execution
fn = slay.put(lambda x: x * 2)
result_refs = slay.apply(fn, [1, 2, 3, 4, 5])
results = slay.get_many(result_refs) # Returns [2, 4, 6, 8, 10]
# Add resilience
cached_fn = slay.add_caching(fn)
resilient_fn = slay.add_retry(cached_fn, attempts=5)
result_ref = resilient_fn(data)Put data/functions, call them, get results:
ref = slay.put(data) # Store data
data = slay.get(ref) # Retrieve it
fn = slay.put(lambda x: x + 1) # Store function
result_ref = fn(5) # Execute it
result = result_ref.get() # Get resultExecute functions on thousands of items instantly:
fn = slay.put(lambda x: x ** 2)
result_refs = slay.apply(fn, range(10000))
results = slay.get_many(result_refs)Add behaviors without changing your code:
fn = slay.put(expensive_function)
cached = slay.add_caching(fn)
resilient = slay.add_retry(cached, attempts=5)
result_ref = resilient(arg)
result = result_ref.get()Everything is a reference - data, functions, results:
ref1 = slay.put("data")
ref2 = slay.put("data")
assert ref1 == ref2 # Same content = equal references
# Automatic deduplication
# Same data = same hash = stored onceDeploy to AWS with no configuration:
cd infrastructure
cdk deploy- S3 bucket (auto-created)
- Lambda functions (auto-deployed)
- Step Functions state machines for retries and fan-out (auto-deployed)
- DynamoDB tables (auto-created)
pip install -e ".[dev]"
# Run tests
pytest tests/
# Run examples
python examples/01_hello_world.py
python examples/02_parallel_processing.py
python examples/03_retry_caching.py# Install with AWS CDK support
pip install -e ".[cdk]"
# Deploy infrastructure from the clients' Python: the Lambda runs its version
cd infrastructure
pip install -r requirements.txt
cdk deploy
# Now you can use Lambda backend
python my_script.py-
Reference System (
core/reference.py)- Content-addressed references (SHA256)
- Automatic tier selection
- Location-independent data access
-
Serialization (
core/serializer.py)- Dill-based function serialization
- Format detection (JSON, Parquet, NumPy, dill)
- Type preservation across boundaries
-
Storage (
core/storage.py)- Multi-tier storage (inline < 1KB, S3 >= 1KB)
- Automatic tier selection
- S3 integration for cloud deployment
-
Execution Backends (
backends/)- Local backend (development/testing)
- Lambda backend (AWS cloud)
- Fargate backend (coming soon)
-
Public API (
api.py)put()/get()/get_many()- store and fetch data and functionsrun()- execute a function reference;fn(x)is the same callapply()- run a function reference on many items in parallelstart_apply()/attach()- the same as a job that outlives the client
-
Function Composition (
wrappers.py)add_retry()- retry with backoff; on Lambda, a Step Functions loop that can also retry timeouts and crashesadd_caching()- a result cache in the storage bucket, shared by every client and Lambdaadd_cache_only()- read that cache; a miss raisesCacheMiss- More coming: rate limiting, concurrency control, etc.
import slay
# Store any data
ref = slay.put("hello world")
data = slay.get(ref)
print(data) # "hello world"
# Content-addressed - same data = same reference
ref1 = slay.put("data")
ref2 = slay.put("data")
assert ref1 == ref2 # True!import slay
fn = slay.put(lambda x: x ** 2)
result_ref = fn(5)
result = result_ref.get()
print(result) # 25import slay
fn = slay.put(lambda x: x * 2)
result_refs = slay.apply(fn, [1, 2, 3, 4, 5])
results = slay.get_many(result_refs)
print(results) # [2, 4, 6, 8, 10]import slay
def fetch_api_data(url):
return {"data": "from_api"}
fn = slay.put(fetch_api_data)
cached_fn = slay.add_caching(fn)
resilient_fn = slay.add_retry(cached_fn, attempts=5, backoff=2.0)
result_ref = resilient_fn("https://api.example.com/data")
result = result_ref.get()import slay
add_one = slay.put(lambda x: x + 1)
double = slay.put(lambda x: x * 2)
six = add_one(5) # Reference to 6; nothing is downloaded
twelve = double(six) # six goes to the backend as a reference
print(twelve.get()) # 12A Reference given as a top-level argument, positional or keyword, goes to
the backend as it is. The backend fetches its value and calls the function
with that value. apply() treats Reference items the same way. A Reference
inside a list or dict is not resolved: the function gets the Reference object.
A function that raises on the backend raises the same exception type in the
caller, so except ValueError works as it does for a local call:
import slay
fn = slay.put(lambda text: int(text))
try:
fn("not a number")
except ValueError as e:
remote = e.__cause__ # slay.RemoteExecutionError on Lambda
print(remote.remote_traceback) # the traceback text from the Lambda
print(remote.remote_logs) # stdout and stderr of the call- Lambda backend. The exception's
__cause__is aRemoteExecutionError. It holds the remote traceback (remote_traceback), the captured output (remote_logs) and the exception's type name (error_type). The exception travels as a dill value, which keeps its arguments and attributes. dill does not keep__traceback__,__cause__or__context__, so the remote traceback text is the only record of the remote chain. - Custom exceptions. dill rebuilds an exception as pickle does: it
calls the class with the exception's
args, then restores the attributes. If__init__takes parameters other than theargsit passes toException.__init__, give the class a__reduce__. Without one, the message can change, or the load fails and the caller getsRemoteExecutionError. - Local backend. The exception propagates unchanged, with its own traceback.
- slay errors. An error that slay raises on the backend keeps its type
as well. A function written by another Python minor version raises
slay.exceptions.SerializationError, on Lambda as locally. apply(). It raises the exception of the lowest failing item index. The Lambda backend waits for every item first. The local backend stops at the first failure, so later items do not run.- The exception cannot cross the wire. If the Lambda cannot serialize
the exception, or the client cannot load it, the caller gets
RemoteExecutionErroritself. Itserror_typenames the original type. - The Lambda fails outside the function. On a timeout, an
out-of-memory kill or a runtime crash, the caller gets
RemoteExecutionError. Itserror_typeis the LambdaerrorType(for exampleSandbox.Timedout), and itsmessageis the LambdaerrorMessage. - The invocation fails. Throttling, a missing function or missing
credentials raise
RemoteExecutionError, chained from the boto3 error. - Size. The handler keeps the last 64 KB of the captured output, of
the traceback text and of the message (
message). A Step Functions state holds at most 256 KB, and a retried call passes the handler's response through one. The exception itself travels by reference, so it keeps its full message.
add_caching(fn) returns a function Reference that stores each result in
the storage bucket, keyed by the call. Every client and every Lambda that
uses the same SLAY_STORAGE_BUCKET shares the entries.
import slay
square = slay.put(lambda x: x * x)
cached = slay.add_caching(square, version="1")
cached(12).get() # runs square on the backend, then writes the entry
cached(12).get() # reads the entry; no backend call
strict = slay.add_cache_only(square, version="1")
strict(12).get() # reads the same entry
strict(13) # raises slay.CacheMiss; nothing runs- Key. The key is a SHA-256 hash of the function's hash, the hashes
of the argument References (keyword arguments by name) and
version. The arguments are References already, so the key costs no serialization and no upload.f(5)andf(x=5)have different keys. - Entry. An entry is the result Reference as wire JSON, at
cache/<k[:2]>/<k>.jsoninSLAY_STORAGE_BUCKET(an S3 bucket or a directory). The cache needs the variable even for small results. - The wrapper.
add_cachingstores its wrapper like any other value. The wrapper is about 400 bytes larger than the function, so wrapping a function of about 600 bytes or more needsSLAY_STORAGE_BUCKETtoo. - Lookup.
run()reads the entry before it calls the backend, so a hit makes no Lambda call. On a miss,run()calls the function through the backend and then writes the entry. A call that raises writes no entry. apply(). It looks up every item first. Then it runs each distinct missing call once, in one fan-out, and returns the results in item order.- Cache-only.
add_cache_only(fn, version=None)reads the same entries. A miss raisesslay.CacheMissand runs nothing. Inapply(), the error names the lowest missing item index. - Expiry. The bucket's lifecycle rules delete values, cache entries and fan-out files after 90 days. On a hit whose result is stored in S3, slay checks that the result object still exists. A missing object counts as a miss.
- Permissions. Clients need
s3:ListBucketon the bucket. Without it, S3 reports a missing object as access denied, and slay raisesStorageErrorinstead of counting a miss. - Versions. dill stores a lambda, or a function defined in
__main__or inside another function, by value, so a change to its code changes its hash and its keys. dill stores a function defined at the top level of an importable module by reference to its name. Its hash stays the same when its code changes, so changeversionwhen you change it. Changeversiontoo when the function's result changes for another reason, for example new external data. - Unstable keys. dill's bytes for a set of strings depend on
PYTHONHASHSEED, so such an argument can hash differently in another process. The call then misses; it never returns a wrong result. ttl.add_cachingaccepts attlargument and ignores it.- Wrapped functions. For
add_caching(add_retry(fn)), the key uses the hash of the retry wrapper, so new retry settings start new entries.
add_retry(fn) returns a function Reference that calls fn again when an
attempt fails:
import slay
fetch = slay.put(fetch_page)
resilient = slay.add_retry(fetch, attempts=5, backoff=2.0,
retry_on_timeout=True, timeout=30)
page = resilient("https://example.com").get()- Attempts and waits.
attemptscounts every attempt, the first included. Before attempt n + 1, slay waitsbackoff * 2 ** (n - 1)seconds: 2, 4, 8 and 16 seconds in the example. - Error classes. An attempt fails in one of three ways:
- failure: the function raised.
retry_on_failure(defaultTrue) retries it. - timeout: the attempt ran longer than
timeoutseconds, or the Lambda reached its own timeout.retry_on_timeout(defaultFalse) retries it. - crash: the Lambda failed outside the function, for example out of
memory.
retry_on_crash(defaultFalse) retries it.
- failure: the function raised.
- When retries end. If the last attempt raised, the caller gets that
exception, as a call without retry does (see Errors). If the
last attempt timed out or crashed, the caller gets
RemoteExecutionError. Itserror_typeis the Step Functions error name, for exampleStates.Timeout, or the LambdaerrorType. - Lambda backend. A retried call runs as an execution of the
slay-retrystate machine (Step Functions, Standard). The client starts the execution and polls it until it ends. Step Functions waits in whole seconds, so slay rounds each wait up. Inapply(), every item of theslay-fanoutexecution runs the same loop (see Fan-out). timeout. A per-attempt limit in whole seconds. Without it, the Lambda's own 14-minute timeout applies. A Step Functions timeout stops the wait for the attempt, not the Lambda: the Lambda runs on until it returns or reaches its own timeout.- Local backend. The retry loop runs in the process. It cannot
interrupt an attempt, so it ignores
timeoutand retries only failures. - Composition.
add_caching(add_retry(fn))caches the result of the retried call.add_retry(add_caching(fn))retries a call that reads and writes the cache inside the executor. - Arguments.
attemptsmust be at least 1,backoffmust not be negative, andtimeoutmust be a positive whole number orNone.add_retryraisesValueErrorotherwise. - Plain calls.
run()withoutadd_retrycalls the Lambda directly, as before.
apply(fn, items, max_concurrent=None) calls fn once per item and
returns the result References in item order:
import slay
square = slay.put(lambda x: x * x)
refs = slay.apply(square, range(10_000), max_concurrent=100)
squares = slay.get_many(refs)- Lambda backend.
apply()runs one execution of theslay-fanoutstate machine (Step Functions, Standard). The client writes the calls tofanout/<execution name>/items.jsonin the storage bucket. A Distributed Map reads that file and starts one Standard child execution per item. Each child runs the loop of Retry, which makes one attempt unless the function comes fromadd_retry. - Client I/O. Your link to AWS carries the values you store (each
once), one items file of References, the start request, the status
polls and the result files, which also hold References. A value
crosses it again only when you call
.get(). - I/O inside AWS. Each item's invoke, argument fetch and result write runs between Step Functions, Lambda and S3. The executor fetches the arguments before your function starts, so your function does no I/O for its arguments, however many items there are.
- Results. A
ResultWriterwrites the child outputs underfanout/results/in the bucket, and the client reads them when the execution ends. Each output carries its item index, because the result files are in no particular order. max_concurrent. The most children that run at once.Nonelets Step Functions decide. The local backend runs the items one at a time and ignores it.- The bucket.
SLAY_STORAGE_BUCKETmust name the stack's S3 bucket: the state machine reads the calls from it and writes the results to it. A directory raisesStorageErrorbefore anything starts. The bucket's lifecycle rule deletes these files after 90 days. - Errors. Every item runs to completion.
apply()then raises the error of the lowest failing index (see Errors). - Plain calls.
run()withoutadd_retrystill invokes the Lambda directly.
apply() waits for its results. start_apply() starts the same work and
returns a Job at once:
job = slay.start_apply(square, range(10_000))
job_id = job.id # on Lambda: the execution ARN
# The client may exit now; the execution goes on.
job = slay.attach(job_id) # later, in any client of the same account
refs = job.results() # waits, then returns or raises as apply() does- Status.
job.status()returns"RUNNING","SUCCEEDED","FAILED","TIMED_OUT"or"ABORTED". A job whose items raised has the status"SUCCEEDED", because its execution finished;job.results()raises the error. - Wrappers.
start_apply()hands the whole call to the backend at once. For a function fromadd_retry, the retry settings go into the execution. Any other wrapper goes to each executor as the function: anadd_cachingfunction looks up each item inside its executor, and duplicate items are not merged.apply()looks up the cache in the client instead, and runs each distinct miss once. - Local backend.
start_apply()runs the items before it returns, sojob.status()is"SUCCEEDED". The job lives in the memory of the process, soattach()finds it only in that process. For an unknown ID,job.status()andjob.results()raiseValueError.
A function that runs on Lambda can call run() or apply() itself.
The executor sets SLAY_BACKEND=lambda, so nested calls go
to AWS: the executor may invoke itself and start executions of both state
machines. Nothing stops a function that calls itself without end, and
each level is a billed Lambda invocation.
dill stores a module that is outside the standard library and
site-packages by value. On Lambda, slay itself is such a module. slay
therefore makes dill store its own modules by name, so a function that
names the slay module serializes in the client and in the executor.
run_later() starts one call and returns a Job at once. run_at()
does the same for a call that starts at a given time:
import datetime as dt
import slay
report = slay.put(build_report)
job = slay.run_later(report, "2026-10")
job_id = job.id # on Lambda: the execution ARN
# The client may exit now; the execution goes on.
ref = slay.attach(job_id).result() # waits; returns or raises as run() does
slay.run_at(dt.timedelta(hours=8), report, "2026-11")
slay.run_at(dt.datetime(2026, 12, 1, tzinfo=dt.timezone.utc), report, "2026-12")- Lambda backend. Each call is one execution of the
slay-retrystate machine. The client starts it and does not wait for it. - The time.
whenis adatetime, or atimedeltafrom now. A naivedatetimeis local time, asdatetime.astimezone()reads it. The first attempt starts at that second; slay rounds a fraction of a second up. A time in the past starts the call at once. - One year. Step Functions stops an execution after one year. A time
365 days or more ahead raises
ValueError, and awhenof another type raisesTypeError. - Results.
job.result()waits for the call, then returns the result Reference or raises asrun()does (see Errors).job.status()is as for a job ofstart_apply(): a call that raised ends"SUCCEEDED".job.results()raisesValueErrorfor a job of one call, andjob.result()raisesValueErrorfor a job ofstart_apply(). - Wrappers. As for
start_apply(): the settings of anadd_retryfunction go into the execution, and any other wrapper runs inside the executor. - Arguments. Every argument after the function goes to the function,
so the function may take keyword arguments named
fnorwhen. - Local backend.
run_later()runs the call before it returns.run_at()sleeps until the time, then runs the call. The job lives in the memory of the process, as a job ofstart_apply()does. - Nested calls. A function on Lambda may call
run_later()andrun_at().
When the last attempt of a call from run_later(), run_at() or a
schedule fails, slay-retry sends a message to the SQS queue
slay-dead-letter. The queue keeps each message for 14 days. The body is
JSON:
{"execution": <the execution ARN>,
"call": {"func_ref": ..., "args_refs": [...], "kwargs_refs": {...}},
"response": <the last attempt's response, as in the execution's output>}
- The last attempt. The function raised, timed out or crashed, and
add_retryallows no more attempts (see Retry). Withoutadd_retry, the first attempt is the last.job.result()raises the same error. - Other calls.
run(),apply()andstart_apply()send no dead letter: their caller gets the error. - Reading. slay does not read the queue. Use the SQS console or
aws sqs receive-message, with rights of your own. The queue's name is theDeadLetterQueueoutput ofSlayComputeStack.
A schedule starts the same call again and again:
import slay
refresh = slay.put(refresh_prices)
slay.schedule("prices", "cron(0 2 * * ? *)", refresh, region="eu")
slay.reschedule("prices", "rate(6 hours)", refresh, region="eu")
slay.schedules() # ["prices"]
slay.unschedule("prices")- Lambda backend. A schedule is an EventBridge Scheduler schedule in
the group
slay. Each run starts aslay-retryexecution, asrun_later()does, soadd_retryand dead letters apply. Scheduler starts the execution through the roleslay-scheduler, which may startslay-retryexecutions and do nothing else. - Expressions.
rate(...),cron(...)orat(yyyy-mm-ddThh:mm:ss), as EventBridge Scheduler defines them. Every expression is in UTC. Scheduler checks the expression; a bad one raisesRemoteExecutionError. - Names. A name has 1 to 64 letters, digits,
-,_or..schedule()raisesValueErrorfor another name, or for a name that a schedule has already.reschedule()replaces the schedule of that name, or creates it. - Copies. The bucket deletes values after 90 days, and a schedule can
run for longer.
schedule()andreschedule()therefore copy each value that is stored in S3 (1 KB or more) toschedules/<name>/in the bucket. No lifecycle rule applies there.- The copied values are the function, each argument, and the inner function of a wrapper. The schedule's call names the copies.
- A Reference inside a container, or one that a closure holds, is not copied. It expires after 90 days.
reschedule()deletes the copies that the new call does not use.
- Removal.
unschedule(name)deletes the schedule, then its copies. If no schedule has that name, it deletes any copies under that name and raisesValueError. Anat()schedule stays after it runs, until you remove it. - Results. Each run stores its result as
run()does. Nothing reads it, and it expires after 90 days. A run whose last attempt fails sends a dead letter. - Python version. A function stored by dill loads only under the
Python minor version that wrote it. If you deploy the stack with
another version, each run fails with
SerializationError. Reschedule from a client with the new version. - The bucket.
SLAY_STORAGE_BUCKETmust name the stack's S3 bucket. A directory raisesStorageError, and nothing changes. - Local backend. No process outlives a schedule, so
schedule(),reschedule(),unschedule()andschedules()raiseSlayError. - Nested calls. The executor's role has no Scheduler rights, so a function on Lambda cannot call the schedule functions.
A client that uses the Lambda backend needs:
lambda:InvokeFunctiononslay-executor, andlambda:GetFunctionon it forSLAY_BACKEND=auto: without it, auto-detection picks the local backend;s3:GetObject,s3:PutObjectands3:ListBucketon the storage bucket (see Caching for whyListBucket);- for
add_retry,run_later()andrun_at():states:StartExecutionon theslay-retrystate machine andstates:DescribeExecutionon its executions; - for
apply(),start_apply()andattach(): the same on theslay-fanoutstate machine and its executions; - for the schedule functions:
scheduler:CreateSchedule,scheduler:UpdateSchedule,scheduler:GetScheduleandscheduler:DeleteScheduleon the schedules of the groupslay;scheduler:ListSchedules, which IAM grants on*only;iam:PassRoleon the roleslay-scheduler;s3:DeleteObjectonschedules/*in the storage bucket.
slay builds the state machine and role ARNs from the account that
sts:GetCallerIdentity returns. That call needs no permission.
IAM_POLICIES/SlayClient.json grants these rights, and IAM_POLICY.json
holds them together with the deployment rights. To give them to an IAM
group (see IAM_POLICIES/README.md):
cd IAM_POLICIES
./manage-policies.sh apply -t slayers # deploy and use slay
./manage-policies.sh apply -t slay-users --client # use slay only# No setup needed!
python examples/01_hello_world.pySee DEPLOYMENT.md for detailed setup instructions.
Quick start:
# 1. Configure AWS credentials
export CDK_DEFAULT_ACCOUNT="123456789012" # Replace with your account ID
export CDK_DEFAULT_REGION="us-east-1"
# 2. Deploy AWS resources
cd infrastructure
pip install -r requirements.txt
cdk deploy
# 3. Point clients at the bucket (the StorageBucket output of cdk deploy)
export SLAY_STORAGE_BUCKET="slay-storage-123456789012-us-east-1"
# 4. Set backend in your code
import slay
slay.set_backend('lambda')
# 5. Run your code - it now executes on Lambda
fn = slay.put(my_function)
result = fn(data).get()Getting your AWS Account ID:
aws sts get-caller-identityFor complete troubleshooting and security best practices, see DEPLOYMENT.md.
c/
├── src/slay/ # Main package
│ ├── core/ # Core abstractions
│ │ ├── reference.py # Content-addressed references
│ │ ├── serializer.py # Serialization system
│ │ ├── storage.py # Storage tiers
│ │ └── context.py # Execution context
│ ├── backends/ # Execution backends
│ │ ├── base.py # Abstract backend
│ │ ├── local.py # Local execution
│ │ ├── lambda_.py # AWS Lambda
│ │ └── schedules.py # EventBridge Scheduler and the copies
│ ├── api.py # Public API
│ ├── deferred.py # run_later, run_at and the schedules
│ ├── jobs.py # Job (start_apply, run_later, attach)
│ ├── wrappers.py # Function composition
│ └── exceptions.py # Exception types
├── infrastructure/ # AWS CDK infrastructure
│ ├── app.py # CDK app
│ ├── stacks/ # CDK stacks
│ │ ├── storage.py # S3 + DynamoDB
│ │ ├── compute.py # Lambda, state machines, dead letters, schedules
│ │ ├── retry_loop.py # The retry loop (slay-retry)
│ │ └── fanout.py # The Distributed Map (slay-fanout)
│ └── cdk.json # CDK config
├── runtime/ # Lambda runtime
│ ├── handler.py # Lambda entry point
│ └── requirements.txt
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ └── infrastructure/ # CDK stacks; state machines in moto
├── examples/ # Usage examples
└── README.md
SLAY_BACKEND- Backend to use:auto(default),local,lambdaSLAY_STORAGE_BUCKET- Where values of 1 KB or more go: the S3 bucket name (theStorageBucketoutput ofSlayStorageStack), or an existing local directory. Smaller values travel inside the reference and need no storage. CDK sets the variable inside the Lambda only; set it on clients yourself. Without it, storing a large value raisesStorageError.
import slay
# Set backend
slay.set_backend('lambda')
# Or configure globally
from slay.core.context import set_config
set_config('max_workers', 100)pytest tests/pytest tests/unit/test_reference.py -vpytest tests/ --cov=slay --cov-report=html- Execution time: Limited to 14 minutes (Lambda limit: 15 min)
- Use Fargate backend (Phase 2) for longer tasks
- Memory: Max 3GB (Lambda limit)
- Parallelism: Unlimited up to AWS account concurrency limits (~1000 Lambdas)
- Python version: Functions and other dill values load only under the
Python minor version that wrote them. The Lambda runtime matches the
Python that runs
cdk deploy, so deploy with the client's Python. - Kill switch and throttling (
slay.control): Not wired in. Nothing registers executions or checks for kills, sokill_all()and the other functions log a message and stop nothing. To stop runaway Lambda work, set the function's reserved concurrency to 0 in AWS. - Schedules: Every schedule expression is in UTC. A function on Lambda cannot create or remove schedules.
- Latency: < 1ms (in-process)
- Throughput: Sequential (for dev/testing)
- Max execution time: Unlimited
- Cold start: 100ms - 1s
- Warm invocation: 100-500ms
- Max execution time: 15 minutes
- Throughput: 1000+ concurrent (account dependent)
Example: Process 10,000 items
- Each task: 512MB, 5 seconds
- Compute: 10,000 × 0.5GB × 5s × $0.0000166667 = $0.42
- Orchestration: 10,000 × about 4 state transitions × $0.000025 = $1.00 (Step Functions, Standard)
- Storage: Variable (depends on data size)
- Total: ~$1.42 for 10,000 executions
put(data_or_func) -> Reference
Store data or function, get a reference.
get(ref) -> Any
Fetch data from a reference.
get_many(refs: list[Reference]) -> list[Any]
Fetch multiple references in parallel.
run(fn: Reference, *args, **kwargs) -> Reference
Execute a function reference, returns a reference to the result.
Reference arguments pass through without a download.
apply(fn: Reference, items: list[Any], max_concurrent=None) -> list[Reference]
Apply function to multiple items, returns references to results.
Reference items pass through without a download. See Fan-out.
start_apply(fn: Reference, items: list[Any], max_concurrent=None) -> Job
Start the work of apply() and return at once (see Jobs).
run_later(fn: Reference, /, *args, **kwargs) -> Job
Start one call and return at once (see
Later, at a time, and on a schedule).
run_at(when: datetime | timedelta, fn: Reference, /, *args, **kwargs) -> Job
Start one call at a time, to the second.
attach(job_id: str) -> Job
The job with this ID. Job.id and Job.status() report on it.
Job.results() waits for a job of start_apply(), and
Job.result() for a job of one call.
schedule(name: str, expression: str, fn: Reference, /, *args, **kwargs)
Run the call on an EventBridge Scheduler expression, in UTC (see
Schedules). Raises ValueError if the name is in use.
reschedule(name: str, expression: str, fn: Reference, /, *args, **kwargs)
Replace the schedule of that name, or create it.
unschedule(name: str)
Delete the schedule and its copies.
schedules() -> list[str]
The names of the schedules, sorted.
ref.get() -> Any
Fetch data from reference (with local caching).
fn(arg1, arg2, ...) -> Reference
Execute function reference remotely, returns reference to result.
Same as run(fn, arg1, arg2, ...).
ref1 == ref2
Compare by content hash (content-addressed equality).
add_retry(fn, attempts=3, backoff=1.0, retry_on_failure=True, retry_on_timeout=False, retry_on_crash=False, timeout=None) -> Reference
Call the function again when an attempt fails (see Retry).
add_caching(fn, ttl=None, version=None) -> Reference
Cache results in the storage bucket, shared by every client and Lambda
(see Caching). ttl is accepted and ignored.
add_cache_only(fn, version=None) -> Reference
Read the entries that add_caching writes; a miss raises slay.CacheMiss.
A failed call raises the function's own exception (see Errors).
slay.RemoteExecutionError
The backend's report of a failed call: the __cause__ of a re-raised
exception on Lambda, or the error itself when the exception cannot cross
the wire or the Lambda fails outside the function. Attributes: message,
remote_traceback, remote_logs, error_type.
slay.CacheMiss
Raised by a function from add_cache_only when no entry exists.
slay.SlayError
Base class of every slay error, including RemoteExecutionError,
CacheMiss, slay.exceptions.SerializationError and
slay.exceptions.StorageError.
slay.set_backend(name: str)
Set execution backend: 'local' (default) or 'lambda'.
slay.get_backend()
Get current backend.
This is an MVP implementation. Key areas for contribution:
- Additional Wrappers: Rate limiting, concurrency control
- Additional Backends: Fargate, EC2, Kubernetes, Ray
- Orchestration: Job tracking, durable execution, Step Functions
- Observability: CloudWatch dashboards, X-Ray tracing
- Performance: Parallel storage.load_many(), network optimizations
- Testing: Integration tests, e2e tests, chaos engineering
MIT