Sessions¶
session
¶
Managed execution contexts for eager tasks.
The session context manager sets up backend, cache, plugin, and event
infrastructure so that eager tasks automatically participate in caching,
hook dispatch, and event reporting. Workflows use session
internally; notebooks and scripts can use it directly.
Three tiers of usage::
# 1. Bare call — no context, inline defaults, no reporters
result = add(x=1, y=2)
# 2. session — managed context for notebooks / scripts
with session(backend="thread", cache_store=".cache"):
a = add(x=1, y=2)
# 3. @workflow — named, CLI-discoverable entry point
@workflow
def my_pipeline(x: int):
return add(x=x, y=1)
my_pipeline.run(x=5)
session
¶
session(
*,
backend: str | None = None,
cache_store: str | CacheStore | None = None,
dataset_store: str | DatasetStore | None = None,
plugins: SerializablePlugin | list[SerializablePlugin] | None = None,
settings: DagliteSettings | None = None,
) -> Iterator[SessionContext]
Synchronous context manager that sets up an execution context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str | None
|
Name of the backend to default. If |
None
|
cache_store
|
str | CacheStore | None
|
Cache store configuration. Can be a |
None
|
dataset_store
|
str | DatasetStore | None
|
Dataset store configuration. Can be a |
None
|
plugins
|
SerializablePlugin | list[SerializablePlugin] | None
|
Extra plugin instances for this session only. |
None
|
settings
|
DagliteSettings | None
|
A |
None
|
Yields:
| Type | Description |
|---|---|
SessionContext
|
The active |
Source code in src/daglite/session.py
async_session
async
¶
async_session(
*,
backend: str | None = None,
cache_store: str | CacheStore | None = None,
dataset_store: str | DatasetStore | None = None,
plugins: SerializablePlugin | list[SerializablePlugin] | None = None,
settings: DagliteSettings | None = None,
) -> AsyncIterator[SessionContext]
Async context manager that sets up an eager execution context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
str | None
|
Name of the backend to default. If |
None
|
cache_store
|
str | CacheStore | None
|
Cache store configuration. Can be a |
None
|
dataset_store
|
str | DatasetStore | None
|
Dataset store configuration. Can be a |
None
|
plugins
|
SerializablePlugin | list[SerializablePlugin] | None
|
Extra plugin instances for this session only. |
None
|
settings
|
DagliteSettings | None
|
A |
None
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[SessionContext]
|
The active |