ControlledExceptionRunnable Class — langchain Architecture
Architecture documentation for the ControlledExceptionRunnable class in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1["ControlledExceptionRunnable"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 45a0fa45_57fc_964f_1b7f_45355436ebdd["__init__()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| 45a0fa45_57fc_964f_1b7f_45355436ebdd a3895c50_dab4_0c36_2d24_f63121e198a0["invoke()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| a3895c50_dab4_0c36_2d24_f63121e198a0 a92288d5_3ea4_6080_81b2_e09426cb961e["_batch()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| a92288d5_3ea4_6080_81b2_e09426cb961e 593bb72a_4695_6c93_b95c_e277aca006ae["batch()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| 593bb72a_4695_6c93_b95c_e277aca006ae e24518e7_67af_1c57_2674_94d33184f37b["_abatch()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| e24518e7_67af_1c57_2674_94d33184f37b 8652094c_ec57_c551_fc44_9566d00cf872["abatch()"] 192ffa80_aa8c_9fdf_71de_8d2c6c5ac8d1 -->|method| 8652094c_ec57_c551_fc44_9566d00cf872
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 4178–4219
class ControlledExceptionRunnable(Runnable[str, str]):
def __init__(self, fail_starts_with: str) -> None:
self.fail_starts_with = fail_starts_with
@override
def invoke(
self, input: Any, config: RunnableConfig | None = None, **kwargs: Any
) -> Any:
raise NotImplementedError
def _batch(
self,
inputs: list[str],
) -> list[str | Exception]:
outputs: list[str | Exception] = []
for value in inputs:
if value.startswith(self.fail_starts_with):
outputs.append(
ValueError(
f"ControlledExceptionRunnable({self.fail_starts_with}) "
f"fail for {value}"
)
)
else:
outputs.append(value + "a")
return outputs
def batch(
self,
inputs: list[str],
config: RunnableConfig | list[RunnableConfig] | None = None,
*,
return_exceptions: bool = False,
**kwargs: Any,
) -> list[str]:
return self._batch_with_config(
self._batch,
inputs,
config,
return_exceptions=return_exceptions,
**kwargs,
)
Source
Frequently Asked Questions
What is the ControlledExceptionRunnable class?
ControlledExceptionRunnable is a class in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is ControlledExceptionRunnable defined?
ControlledExceptionRunnable is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 4178.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free