Skip to content

Commit ae03c45

Browse files
committed
more updates to docs
Signed-off-by: Filinto Duran <[email protected]>
1 parent 3ec779d commit ae03c45

File tree

6 files changed

+54
-29
lines changed

6 files changed

+54
-29
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ See the [examples](./examples) directory for a list of sample orchestrations and
186186
- `async_fanout_fanin.py` - Updated to use new `durabletask.aio` package
187187
- `async_enhanced_features.py` - Comprehensive demo of all enhanced features
188188
- `async_non_determinism_demo.py` - Non-determinism detection demonstration
189-
- See [ASYNC_ENHANCEMENTS.md](./ASYNC_ENHANCEMENTS.md) for detailed examples and usage patterns
189+
- See [ASYNC_ENHANCEMENTS.md](./durabletask/aio/ASYNCIO_ENHANCEMENTS.md) for detailed examples and usage patterns
190190

191191
## Development
192192

@@ -264,7 +264,7 @@ Optional sandbox mode (`best_effort` or `strict`) patches `asyncio.sleep`, `rand
264264

265265
In `strict` mode, `asyncio.create_task` is blocked inside workflows to preserve determinism and will raise a `SandboxViolationError` if used.
266266

267-
> **Enhanced Sandbox Features**: The enhanced version includes comprehensive non-determinism detection, timeout support, enhanced concurrency primitives, and debugging tools. See [ASYNC_ENHANCEMENTS.md](./ASYNC_ENHANCEMENTS.md) for complete documentation.
267+
> **Enhanced Sandbox Features**: The enhanced version includes comprehensive non-determinism detection, timeout support, enhanced concurrency primitives, and debugging tools. See [ASYNC_ENHANCEMENTS.md](./durabletask/aio/ASYNCIO_ENHANCEMENTS.md) for complete documentation.
268268
269269
#### Async patterns
270270

codegen-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
grpcio-tools==1.62.3 # codegen only; conflicts with protobuf>=6 at runtime
2+

ASYNC_ENHANCEMENTS.md renamed to durabletask/aio/ASYNCIO_ENHANCEMENTS.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -257,29 +257,3 @@ async def workflow_with_cleanup(ctx, input_data):
257257
```bash
258258
export DAPR_WF_DEBUG=true
259259
```
260-
261-
## Compatibility
262-
263-
- **Backward Compatible**: All existing async workflows continue to work
264-
- **Upstream Compatible**: Async enhancements live under `durabletask.aio`
265-
- **Zero Overhead**: Default behavior has no performance impact
266-
- **Opt-in Features**: Enhanced features are opt-in via `sandbox_mode`
267-
268-
## Files Added/Modified
269-
270-
### New Files
271-
- `tests/durabletask/test_asyncio_compat_enhanced.py` - Comprehensive tests
272-
- `tests/durabletask/test_non_determinism_detection.py` - Detection tests
273-
- `examples/async_enhanced_features.py` - Full feature demo
274-
- `examples/async_non_determinism_demo.py` - Detection demo
275-
- `examples/README_ENHANCED.md` - Detailed documentation
276-
- `ASYNC_ENHANCEMENTS.md` - This file
277-
278-
### Modified Files
279-
- `durabletask/aio/*` - Async package with enhanced features
280-
- `README.md` - Updates to reference enhancements
281-
282-
### Unchanged Files
283-
- `durabletask/task.py` - No changes to core task system
284-
- `durabletask/worker.py` - Minimal changes for async orchestrator registration
285-
- `durabletask/client.py` - No changes to client API
File renamed without changes.

durabletask/aio/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from .compatibility import OrchestrationContextProtocol, ensure_compatibility
3434

3535
# Core context and driver
36-
from .context import AsyncWorkflowContext
36+
from .context import AsyncWorkflowContext, WorkflowInfo
3737
from .driver import CoroutineOrchestratorRunner, WorkflowFunction
3838

3939
# Sandbox and error handling
@@ -56,6 +56,7 @@
5656
__all__ = [
5757
# Core classes
5858
"AsyncWorkflowContext",
59+
"WorkflowInfo",
5960
"CoroutineOrchestratorRunner",
6061
"WorkflowFunction",
6162

durabletask/aio/context.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from __future__ import annotations
1313

1414
import os
15+
from dataclasses import dataclass
1516
from datetime import datetime, timedelta
1617
from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast
1718

@@ -36,6 +37,27 @@
3637
T = TypeVar("T")
3738

3839

40+
@dataclass(frozen=True)
41+
class WorkflowInfo:
42+
"""
43+
Read-only metadata snapshot about the running workflow execution.
44+
45+
Similar to Temporal's workflow.info, this provides convenient access to
46+
workflow execution metadata in a single immutable object.
47+
"""
48+
instance_id: str
49+
workflow_name: Optional[str]
50+
is_replaying: bool
51+
is_suspended: bool
52+
parent_instance_id: Optional[str]
53+
current_time: datetime
54+
history_event_sequence: int
55+
trace_parent: Optional[str]
56+
trace_state: Optional[str]
57+
orchestration_span_id: Optional[str]
58+
workflow_attempt: Optional[int]
59+
60+
3961
@ensure_compatibility
4062
class AsyncWorkflowContext(DeterministicContextMixin):
4163
"""
@@ -143,6 +165,32 @@ def workflow_attempt(self) -> Optional[int]:
143165
"""Temporary: retry attempt for this workflow if available (propagated by worker)."""
144166
return getattr(self._base_ctx, 'workflow_attempt', None)
145167

168+
@property
169+
def info(self) -> WorkflowInfo:
170+
"""
171+
Get a read-only snapshot of workflow execution metadata.
172+
173+
This provides a Temporal-style info object bundling instance_id, workflow_name,
174+
is_replaying, timestamps, tracing info, and other metadata in a single immutable object.
175+
Useful for deterministic logging, idempotency keys, and conditional logic based on replay state.
176+
177+
Returns:
178+
WorkflowInfo: Immutable dataclass with workflow execution metadata
179+
"""
180+
return WorkflowInfo(
181+
instance_id=self.instance_id,
182+
workflow_name=self.workflow_name,
183+
is_replaying=self.is_replaying,
184+
is_suspended=self.is_suspended,
185+
parent_instance_id=self.parent_instance_id,
186+
current_time=self.current_utc_datetime,
187+
history_event_sequence=self.history_event_sequence,
188+
trace_parent=self.trace_parent,
189+
trace_state=self.trace_state,
190+
orchestration_span_id=self.orchestration_span_id,
191+
workflow_attempt=self.workflow_attempt,
192+
)
193+
146194
# Activity operations
147195
def activity(
148196
self,

0 commit comments

Comments
 (0)