feat: Add async output resolution with caching and ordered processing (#7487)
* feat: enhance output processing to maintain order * feat: add async output resolution method with caching support * test: Update component outputs in test_component_events.py Enhance the test for component build results by adding output definitions for 'text_output' and 'tool_output' to ensure comprehensive coverage of output handling during the build process. * 📝 Add docstrings to `order-outputs` (#8280) Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * [autofix.ci] apply automated fixes * fix: Update output retrieval in Component class to handle missing outputs gracefully Modified the output retrieval logic in the Component class to use `get` method for accessing `_outputs_map`, providing a default value of a deepcopy of the output. This change enhances robustness by preventing KeyError exceptions when an output is not found in the map. * refactor: Enhance output processing logic in Component class Updated the _get_outputs_to_process method to first process outputs in the order defined by self.outputs, followed by any remaining outputs from _outputs_map. This change improves the output handling logic and ensures that all relevant outputs are considered for processing. * refactor: Improve docstring clarity in test_component_events.py Updated the docstring for the test_component_build_results function to enhance clarity and readability. The changes ensure that the purpose and expectations of the test are clearly communicated, improving documentation quality. --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
9b345cc01d
commit
aaf36c4316
2 changed files with 72 additions and 2 deletions
|
|
@ -134,7 +134,11 @@ async def test_component_error_handling():
|
|||
|
||||
@pytest.mark.usefixtures("client")
|
||||
async def test_component_build_results():
|
||||
"""Test component's build_results functionality."""
|
||||
"""Test that build_results correctly generates output results and artifacts for defined outputs.
|
||||
|
||||
Test that the results dictionary contains the correct output keys and values,
|
||||
and that the artifacts dictionary includes the correct types for each output.
|
||||
"""
|
||||
# Create event queue and manager
|
||||
queue = asyncio.Queue()
|
||||
event_manager = EventManager(queue)
|
||||
|
|
@ -149,6 +153,11 @@ async def test_component_build_results():
|
|||
"tool_output": Output(name="tool_output", method="get_tool"),
|
||||
}
|
||||
|
||||
component.outputs = [
|
||||
Output(name="text_output", method="get_text"),
|
||||
Output(name="tool_output", method="get_tool"),
|
||||
]
|
||||
|
||||
# Build results
|
||||
results, artifacts = await component._build_results()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue