auto-workflow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- assets/logo.svg +6524 -0
- auto_workflow/__init__.py +40 -0
- auto_workflow/__main__.py +9 -0
- auto_workflow/artifacts.py +119 -0
- auto_workflow/build.py +158 -0
- auto_workflow/cache.py +111 -0
- auto_workflow/cli.py +78 -0
- auto_workflow/config.py +76 -0
- auto_workflow/context.py +32 -0
- auto_workflow/dag.py +80 -0
- auto_workflow/events.py +22 -0
- auto_workflow/exceptions.py +42 -0
- auto_workflow/execution.py +45 -0
- auto_workflow/fanout.py +59 -0
- auto_workflow/flow.py +165 -0
- auto_workflow/lifecycle.py +16 -0
- auto_workflow/logging_middleware.py +191 -0
- auto_workflow/metrics_provider.py +35 -0
- auto_workflow/middleware.py +59 -0
- auto_workflow/py.typed +0 -0
- auto_workflow/scheduler.py +362 -0
- auto_workflow/secrets.py +45 -0
- auto_workflow/task.py +158 -0
- auto_workflow/tracing.py +29 -0
- auto_workflow/types.py +27 -0
- auto_workflow/utils.py +39 -0
- auto_workflow-0.1.0.dist-info/LICENSE +674 -0
- auto_workflow-0.1.0.dist-info/METADATA +423 -0
- auto_workflow-0.1.0.dist-info/RECORD +31 -0
- auto_workflow-0.1.0.dist-info/WHEEL +4 -0
- auto_workflow-0.1.0.dist-info/entry_points.txt +3 -0
auto_workflow/utils.py
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
"""Utility helpers."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
import asyncio
|
6
|
+
import functools
|
7
|
+
import hashlib
|
8
|
+
import inspect
|
9
|
+
from collections.abc import Callable
|
10
|
+
from typing import Any
|
11
|
+
|
12
|
+
_DEF_HASH_SALT = b"auto_workflow:v1"
|
13
|
+
|
14
|
+
|
15
|
+
def default_cache_key(fn: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any]) -> str:
|
16
|
+
try:
|
17
|
+
sig = inspect.signature(fn)
|
18
|
+
bound = sig.bind_partial(*args, **kwargs)
|
19
|
+
bound.apply_defaults()
|
20
|
+
key_source = repr((fn.__module__, fn.__qualname__, sorted(bound.arguments.items())))
|
21
|
+
except Exception: # pragma: no cover - fallback
|
22
|
+
key_source = repr((fn.__module__, fn.__qualname__, args, kwargs))
|
23
|
+
digest = hashlib.sha256(_DEF_HASH_SALT + key_source.encode()).hexdigest()
|
24
|
+
return digest
|
25
|
+
|
26
|
+
|
27
|
+
def is_coroutine_fn(fn: Callable[..., Any]) -> bool:
|
28
|
+
while isinstance(fn, functools.partial): # type: ignore
|
29
|
+
fn = fn.func # type: ignore
|
30
|
+
return asyncio.iscoroutinefunction(fn) or inspect.isasyncgenfunction(fn)
|
31
|
+
|
32
|
+
|
33
|
+
async def maybe_await(value: Any) -> Any:
|
34
|
+
if inspect.isawaitable(value):
|
35
|
+
return await value
|
36
|
+
return value
|
37
|
+
|
38
|
+
|
39
|
+
__all__ = ["default_cache_key", "is_coroutine_fn", "maybe_await"]
|