stepfunction 0.0.4__tar.gz → 0.0.5__tar.gz

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.
Files changed (35) hide show
  1. {stepfunction-0.0.4/src/StepFunction.egg-info → stepfunction-0.0.5}/PKG-INFO +1 -1
  2. {stepfunction-0.0.4 → stepfunction-0.0.5}/pyproject.toml +1 -1
  3. {stepfunction-0.0.4 → stepfunction-0.0.5/src/StepFunction.egg-info}/PKG-INFO +1 -1
  4. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/StepFunction.egg-info/SOURCES.txt +4 -0
  5. stepfunction-0.0.5/src/stepfunction/steps/__init__.py +7 -0
  6. stepfunction-0.0.5/src/stepfunction/steps/exceptions/__init__.py +3 -0
  7. stepfunction-0.0.5/src/stepfunction/steps/exceptions/step_exceptions.py +11 -0
  8. stepfunction-0.0.5/src/stepfunction/steps/retry_step.py +68 -0
  9. stepfunction-0.0.5/src/stepfunction/steps/timeout_step.py +61 -0
  10. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/steps/wait_step.py +2 -2
  11. stepfunction-0.0.4/src/stepfunction/steps/__init__.py +0 -4
  12. {stepfunction-0.0.4 → stepfunction-0.0.5}/LICENSE +0 -0
  13. {stepfunction-0.0.4 → stepfunction-0.0.5}/README.md +0 -0
  14. {stepfunction-0.0.4 → stepfunction-0.0.5}/setup.cfg +0 -0
  15. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/StepFunction.egg-info/dependency_links.txt +0 -0
  16. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/StepFunction.egg-info/requires.txt +0 -0
  17. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/StepFunction.egg-info/top_level.txt +0 -0
  18. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/constants/__init__.py +0 -0
  19. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/constants/enums.py +0 -0
  20. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/constants/visualizer.py +0 -0
  21. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/core/step_function/__init__.py +0 -0
  22. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/core/step_function/step_function.py +0 -0
  23. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/core/visualizer/__init__.py +0 -0
  24. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/core/visualizer/visualizer.py +0 -0
  25. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/exceptions/__init__.py +0 -0
  26. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/exceptions/step_errors.py +0 -0
  27. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/steps/base/__init__.py +0 -0
  28. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/steps/base/base_step.py +0 -0
  29. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/types/__init__.py +0 -0
  30. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/types/step_types.py +0 -0
  31. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/types/visualizer_types.py +0 -0
  32. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/utils/__init__.py +0 -0
  33. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/utils/constants.py +0 -0
  34. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/utils/logger.py +0 -0
  35. {stepfunction-0.0.4 → stepfunction-0.0.5}/src/stepfunction/utils/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stepfunction
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Step Function Workflow Orchestration Library
5
5
  Author: Vineeth Penugonda
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "stepfunction"
3
- version = "0.0.4"
3
+ version = "0.0.5"
4
4
  authors = [{ name = "Vineeth Penugonda" }]
5
5
  description = "Step Function Workflow Orchestration Library"
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stepfunction
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Step Function Workflow Orchestration Library
5
5
  Author: Vineeth Penugonda
6
6
  License-Expression: MIT
@@ -21,9 +21,13 @@ src/stepfunction/core/visualizer/visualizer.py
21
21
  src/stepfunction/exceptions/__init__.py
22
22
  src/stepfunction/exceptions/step_errors.py
23
23
  src/stepfunction/steps/__init__.py
24
+ src/stepfunction/steps/retry_step.py
25
+ src/stepfunction/steps/timeout_step.py
24
26
  src/stepfunction/steps/wait_step.py
25
27
  src/stepfunction/steps/base/__init__.py
26
28
  src/stepfunction/steps/base/base_step.py
29
+ src/stepfunction/steps/exceptions/__init__.py
30
+ src/stepfunction/steps/exceptions/step_exceptions.py
27
31
  src/stepfunction/types/__init__.py
28
32
  src/stepfunction/types/step_types.py
29
33
  src/stepfunction/types/visualizer_types.py
@@ -0,0 +1,7 @@
1
+ from .base import BaseStep
2
+ from .exceptions import StepTimeoutError
3
+ from .retry_step import RetryStep
4
+ from .timeout_step import TimeoutStep
5
+ from .wait_step import WaitStep
6
+
7
+ __all__ = ["BaseStep", "RetryStep", "StepTimeoutError", "TimeoutStep", "WaitStep"]
@@ -0,0 +1,3 @@
1
+ from .step_exceptions import StepTimeoutError
2
+
3
+ __all__ = ["StepTimeoutError"]
@@ -0,0 +1,11 @@
1
+ """Exceptions for built-in step types.
2
+
3
+ Author: Vineeth Penugonda
4
+ """
5
+
6
+
7
+ class StepTimeoutError(Exception):
8
+ """Raised when a step exceeds its allowed execution time."""
9
+
10
+ def __init__(self, timeout: float):
11
+ super().__init__(f"Step exceeded the timeout of {timeout}s")
@@ -0,0 +1,68 @@
1
+ """RetryStep — a built-in step that retries a callable on failure.
2
+
3
+ Author: Vineeth Penugonda
4
+ """
5
+
6
+ from asyncio import sleep
7
+ from inspect import iscoroutinefunction
8
+ from typing import Any, Callable
9
+
10
+ from stepfunction.constants.enums import StepType
11
+ from stepfunction.steps.base import BaseStep
12
+
13
+
14
+ class RetryStep(BaseStep):
15
+ """A step that retries a callable on failure with a fixed delay between attempts.
16
+
17
+ Executes the wrapped function and retries up to ``max_retries`` times if it
18
+ raises an exception. Raises the last exception if all attempts fail.
19
+
20
+ Args:
21
+ func (Callable): The function to execute. May be sync or async.
22
+ max_retries (int): Maximum number of retry attempts after the first failure.
23
+ A value of 3 means the function is called at most 4 times. Defaults to 3.
24
+ delay (float): Seconds to wait between retry attempts. Defaults to 1.0.
25
+
26
+ Raises:
27
+ ValueError: If max_retries is negative or delay is negative.
28
+
29
+ Example:
30
+ sf.add_step("fetch", RetryStep(func=call_api, max_retries=3, delay=2.0), next_step="next")
31
+ """
32
+
33
+ step_type: StepType = StepType.INBUILT
34
+
35
+ def __init__(
36
+ self, func: Callable[[Any], Any], max_retries: int = 3, delay: float = 1.0
37
+ ):
38
+ if max_retries < 0:
39
+ raise ValueError("max_retries must be a non-negative integer")
40
+ if delay < 0:
41
+ raise ValueError("delay must be a non-negative number")
42
+
43
+ self.func = func
44
+ self.max_retries = max_retries
45
+ self.delay = delay
46
+
47
+ def build(self) -> Callable[[Any], Any]:
48
+ """Return an async function that retries ``func`` on failure."""
49
+ func = self.func
50
+ max_retries = self.max_retries
51
+ delay = self.delay
52
+
53
+ async def run(input_value: Any) -> Any:
54
+ last_exc: Exception = None
55
+
56
+ for attempt in range(max_retries + 1):
57
+ try:
58
+ if iscoroutinefunction(func):
59
+ return await func(input_value)
60
+ return func(input_value)
61
+ except Exception as exc:
62
+ last_exc = exc
63
+ if attempt < max_retries:
64
+ await sleep(delay)
65
+
66
+ raise last_exc
67
+
68
+ return run
@@ -0,0 +1,61 @@
1
+ """TimeoutStep — a built-in step that enforces a maximum execution duration.
2
+
3
+ Author: Vineeth Penugonda
4
+ """
5
+
6
+ from asyncio import TimeoutError as AsyncTimeoutError
7
+ from asyncio import get_running_loop, wait_for
8
+ from inspect import iscoroutinefunction
9
+ from typing import Any, Callable
10
+
11
+ from stepfunction.constants.enums import StepType
12
+ from stepfunction.steps.base import BaseStep
13
+ from stepfunction.steps.exceptions import StepTimeoutError
14
+
15
+
16
+ class TimeoutStep(BaseStep):
17
+ """A step that raises an error if the wrapped callable exceeds a time limit.
18
+
19
+ Works with both sync and async functions. Sync functions are executed in a
20
+ thread pool so the timeout can be enforced without blocking the event loop.
21
+
22
+ Args:
23
+ func (Callable): The function to execute. May be sync or async.
24
+ timeout (float): Maximum allowed duration in seconds.
25
+
26
+ Raises:
27
+ ValueError: If timeout is not a positive number.
28
+ StepTimeoutError: If the function does not complete within ``timeout`` seconds.
29
+
30
+ Example:
31
+ sf.add_step("process", TimeoutStep(func=heavy_job, timeout=30.0), next_step="next")
32
+ """
33
+
34
+ step_type: StepType = StepType.INBUILT
35
+
36
+ def __init__(self, func: Callable[[Any], Any], timeout: float):
37
+ if timeout <= 0:
38
+ raise ValueError("timeout must be a positive number")
39
+
40
+ self.func = func
41
+ self.timeout = timeout
42
+
43
+ def build(self) -> Callable[[Any], Any]:
44
+ """Return an async function that enforces a timeout on ``func``."""
45
+ func = self.func
46
+ timeout = self.timeout
47
+
48
+ async def run(input_value: Any) -> Any:
49
+ try:
50
+ if iscoroutinefunction(func):
51
+ return await wait_for(func(input_value), timeout=timeout)
52
+ else:
53
+ loop = get_running_loop()
54
+ return await wait_for(
55
+ loop.run_in_executor(None, func, input_value),
56
+ timeout=timeout,
57
+ )
58
+ except AsyncTimeoutError:
59
+ raise StepTimeoutError(timeout)
60
+
61
+ return run
@@ -3,7 +3,7 @@
3
3
  Author: Vineeth Penugonda
4
4
  """
5
5
 
6
- import asyncio
6
+ from asyncio import sleep
7
7
  from typing import Any, Callable
8
8
 
9
9
  from stepfunction.constants.enums import StepType
@@ -35,7 +35,7 @@ class WaitStep(BaseStep):
35
35
  duration = self.duration
36
36
 
37
37
  async def wait(input_value: Any) -> Any:
38
- await asyncio.sleep(duration)
38
+ await sleep(duration)
39
39
  return input_value
40
40
 
41
41
  return wait
@@ -1,4 +0,0 @@
1
- from .base import BaseStep
2
- from .wait_step import WaitStep
3
-
4
- __all__ = ["BaseStep", "WaitStep"]
File without changes
File without changes
File without changes