- Notifications
You must be signed in to change notification settings - Fork 20.9k
feat(graph-engine): make layer runtime state non-null and bound early #30552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits Select commit Hold shift + click to select a range
ca23cfa refactor(graph-engine): remove None guards and align layer docs with …
laipz8200 05ec375 feat(graph-engine): make GraphEngineLayer runtime state non-null via …
laipz8200 166488d test(graph-engine): cover non-null layer runtime state and uninitiali…
laipz8200 77b780e - chore(kanban): mark parent graph_runtime_state task done after merges
laipz8200 d0f6c2c [autofix.ci] apply automated fixes
autofix-ci[bot] 39f787f Update api/core/workflow/graph_engine/layers/base.py
laipz8200 a4e8d62 - refactor(graph-engine): replace uninitialized runtime-state sentine…
laipz8200 e7331f9 refactor(graph-engine): remove defensive try/except around layer init…
laipz8200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions 56 api/tests/unit_tests/core/workflow/graph_engine/layers/test_layer_initialization.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| from __future__ import annotations | ||
| | ||
| import pytest | ||
| | ||
| from core.workflow.graph_engine import GraphEngine | ||
| from core.workflow.graph_engine.command_channels import InMemoryChannel | ||
| from core.workflow.graph_engine.layers.base import ( | ||
| GraphEngineLayer, | ||
| GraphEngineLayerNotInitializedError, | ||
| ) | ||
| from core.workflow.graph_events import GraphEngineEvent | ||
| | ||
| from ..test_table_runner import WorkflowRunner | ||
| | ||
| | ||
| class LayerForTest(GraphEngineLayer): | ||
| def on_graph_start(self) -> None: | ||
| pass | ||
| | ||
| def on_event(self, event: GraphEngineEvent) -> None: | ||
| pass | ||
| | ||
| def on_graph_end(self, error: Exception | None) -> None: | ||
| pass | ||
| | ||
| | ||
| def test_layer_runtime_state_raises_when_uninitialized() -> None: | ||
| layer = LayerForTest() | ||
| | ||
| with pytest.raises(GraphEngineLayerNotInitializedError): | ||
| _ = layer.graph_runtime_state | ||
| | ||
| | ||
| def test_layer_runtime_state_available_after_engine_layer() -> None: | ||
| runner = WorkflowRunner() | ||
| fixture_data = runner.load_fixture("simple_passthrough_workflow") | ||
| graph, graph_runtime_state = runner.create_graph_from_fixture( | ||
| fixture_data, | ||
| inputs={"query": "test layer state"}, | ||
| ) | ||
| engine = GraphEngine( | ||
| workflow_id="test_workflow", | ||
| graph=graph, | ||
| graph_runtime_state=graph_runtime_state, | ||
| command_channel=InMemoryChannel(), | ||
| ) | ||
| | ||
| layer = LayerForTest() | ||
| engine.layer(layer) | ||
| | ||
| outputs = layer.graph_runtime_state.outputs | ||
| ready_queue_size = layer.graph_runtime_state.ready_queue_size | ||
| | ||
| assert outputs == {} | ||
| assert isinstance(ready_queue_size, int) | ||
| assert ready_queue_size >= 0 |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.