• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / a39cb164-6c44-4f53-92bc-6ed8705a075c

05 May 2025 12:45PM UTC coverage: 86.555% (+0.02%) from 86.54%
a39cb164-6c44-4f53-92bc-6ed8705a075c

push

circleci

web-flow
Switch to using `kclpy-ext` (#12567)

64183 of 74153 relevant lines covered (86.55%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.31
/localstack-core/localstack/services/stepfunctions/asl/component/eval_component.py
1
import abc
1✔
2
import logging
1✔
3
from typing import Optional
1✔
4

5
from localstack.services.stepfunctions.asl.component.common.error_name.failure_event import (
1✔
6
    FailureEventException,
7
)
8
from localstack.services.stepfunctions.asl.component.component import Component
1✔
9
from localstack.services.stepfunctions.asl.eval.environment import Environment
1✔
10
from localstack.services.stepfunctions.asl.utils.encoding import to_json_str
1✔
11
from localstack.utils.strings import long_uid
1✔
12

13
LOG = logging.getLogger(__name__)
1✔
14

15

16
class EvalComponent(Component, abc.ABC):
1✔
17
    __heap_key: Optional[str] = None
1✔
18

19
    @property
1✔
20
    def heap_key(self) -> str:
1✔
21
        if self.__heap_key is None:
1✔
22
            self.__heap_key = long_uid()
1✔
23
        return self.__heap_key
1✔
24

25
    def _log_evaluation_step(self, subject: str = "Generic") -> None:
1✔
26
        if LOG.isEnabledFor(logging.DEBUG):
1✔
27
            LOG.debug(
1✔
28
                "[ASL] [%s] [%s]: '%s'",
29
                subject.lower()[:4],
30
                self.__class__.__name__,
31
                repr(self),
32
            )
33

34
    def _log_failure_event_exception(self, failure_event_exception: FailureEventException) -> None:
1✔
35
        error_log_parts = ["Exception=FailureEventException"]
1✔
36

37
        error_name = failure_event_exception.failure_event.error_name
1✔
38
        if error_name:
1✔
39
            error_log_parts.append(f"Error={error_name.error_name}")
1✔
40

41
        event_details = failure_event_exception.failure_event.event_details
1✔
42
        if event_details:
1✔
43
            error_log_parts.append(f"Details={to_json_str(event_details)}")
1✔
44

45
        error_log = ", ".join(error_log_parts)
1✔
46
        component_repr = repr(self)
1✔
47
        LOG.error("%s at '%s'", error_log, component_repr)
1✔
48

49
    def _log_exception(self, exception: Exception) -> None:
1✔
50
        exception_name = exception.__class__.__name__
1✔
51

52
        error_log_parts = [f"Exception={exception_name}"]
1✔
53

54
        exception_body = list(exception.args)
1✔
55
        if exception_body:
1✔
56
            error_log_parts.append(f"Details={exception_body}")
×
57
        else:
58
            error_log_parts.append("Details=None-Available")
1✔
59

60
        error_log = ", ".join(error_log_parts)
1✔
61
        component_repr = repr(self)
1✔
62
        LOG.error("%s at '%s'", error_log, component_repr)
1✔
63

64
    def eval(self, env: Environment) -> None:
1✔
65
        if env.is_running():
1✔
66
            self._log_evaluation_step("Computing")
1✔
67
            try:
1✔
68
                field_name = self._field_name()
1✔
69
                if field_name is not None:
1✔
70
                    env.next_field_name = field_name
1✔
71
                self._eval_body(env)
1✔
72
            except FailureEventException as failure_event_exception:
1✔
73
                self._log_failure_event_exception(failure_event_exception=failure_event_exception)
1✔
74
                raise failure_event_exception
1✔
75
            except Exception as exception:
1✔
76
                self._log_exception(exception=exception)
1✔
77
                raise exception
1✔
78
        else:
79
            self._log_evaluation_step("Pruning")
1✔
80

81
    @abc.abstractmethod
1✔
82
    def _eval_body(self, env: Environment) -> None:
1✔
83
        raise NotImplementedError()
84

85
    def _field_name(self) -> Optional[str]:
1✔
86
        return self.__class__.__name__
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc