-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Feat: Runflow optimization and improved dropdown behavior #10720
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
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR adds flow retrieval and caching capabilities across backend and frontend. It introduces new helpers for listing flows by folder context, flow-based retrieval, and implements comprehensive caching and dynamic output resolution in RunFlowBaseComponent. Frontend updates propagate metadata and refresh signals through the UI. Integration and unit tests validate the new functionality. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as Frontend UI
participant Template as mutateTemplate
participant API as API Call
participant Backend as Backend Services
participant DB as Database
User->>UI: Select flow / trigger refresh
UI->>Template: mutateTemplate(..., isRefresh=true)
Template->>API: POST with is_refresh=true in payload
alt is_refresh = true
API->>Backend: list_flows_by_flow_folder()
Backend->>DB: Query flows in same folder
DB-->>Backend: Flow list with updated_at
Backend->>Backend: Sort by order_params
Backend-->>API: Return flows + metadata
API-->>UI: Update dropdown options
else is_refresh = false
API->>Backend: get_flow_by_id_or_name()
Backend->>Backend: Load graph + derive outputs
Backend-->>API: Flow data + graph structure
API-->>UI: Update build config
end
UI->>User: Reflect changes (options/config)
sequenceDiagram
participant RunFlow as RunFlowComponent
participant Cache as Flow Cache
participant DB as Database
participant Graph as Graph Builder
RunFlow->>RunFlow: update_build_config()
alt Flow selection changes
RunFlow->>RunFlow: get_selected_flow_meta()
RunFlow->>DB: Fetch flow by derived flow_id
RunFlow->>RunFlow: load_graph_and_update_cfg()
RunFlow->>Graph: Reconstruct graph from payload
Graph-->>RunFlow: Graph object
RunFlow->>RunFlow: update_build_config_from_graph()
RunFlow->>RunFlow: Delete old output fields
else Refresh triggered (is_refresh=true)
RunFlow->>DB: list_flows_by_flow_folder()
DB-->>RunFlow: Available flows list
RunFlow->>RunFlow: Populate flow_name_selected.options
RunFlow->>RunFlow: check_and_update_stale_flow()
alt Flow is stale
RunFlow->>RunFlow: load_graph_and_update_cfg()
RunFlow->>Graph: Reload graph
Graph-->>RunFlow: Updated graph
end
end
RunFlow->>RunFlow: Sync to frontend
sequenceDiagram
participant Runner as Flow Runner
participant RFComp as RunFlowBaseComponent
participant Cache as Cache Service
participant GraphMgr as Graph Manager
Runner->>RFComp: _run_flow_with_cached_graph()
RFComp->>RFComp: _build_flow_cache_key()
RFComp->>Cache: _get_cached_flow()
alt Cache Hit & Up-to-date
Cache-->>RFComp: Cached Graph
RFComp->>RFComp: _is_cached_flow_up_to_date()
rect rgb(144, 238, 144)
Note over RFComp,Cache: Use cached graph
RFComp->>RFComp: _pre_run_setup()
end
else Cache Miss or Stale
RFComp->>GraphMgr: get_graph()
GraphMgr-->>RFComp: Fresh Graph
RFComp->>Cache: _set_cached_flow()
Cache-->>RFComp: Cached
end
RFComp->>RFComp: _build_inputs_from_tweaks()
RFComp->>RFComp: run_flow(graph, inputs)
RFComp->>RFComp: _get_cached_run_outputs()
RFComp-->>Runner: Results
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (24.17%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10720 +/- ##
==========================================
+ Coverage 32.40% 32.48% +0.08%
==========================================
Files 1366 1366
Lines 62953 63294 +341
Branches 9305 9356 +51
==========================================
+ Hits 20401 20564 +163
- Misses 41524 41698 +174
- Partials 1028 1032 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/lfx/src/lfx/components/input_output/chat_output.py (1)
130-139: Critical: Inconsistent session_id usage breaks message storage.Line 130 derives a session_id by falling back to
self.graph.session_id, but line 136 still checksself.session_idfor the storage condition. This creates a bug where:
- If
self.session_idis empty butself.graph.session_idhas a value, the message will be assigned a session_id but won't be stored.This is inconsistent with the correct implementation in
chat.py(lines 92-101), which derives the session_id into a variable and uses it consistently.Apply this diff to fix the inconsistency:
+ session_id = self.session_id or self.graph.session_id or "" message.sender = self.sender message.sender_name = self.sender_name - message.session_id = self.session_id or self.graph.session_id or "" + message.session_id = session_id message.context_id = self.context_id message.flow_id = self.graph.flow_id if hasattr(self, "graph") else None message.properties.source = self._build_source(source_id, display_name, source) # Store message if needed - if self.session_id and self.should_store_message: + if session_id and self.should_store_message: stored_message = await self.send_message(message) self.message.value = stored_message message = stored_messagesrc/lfx/src/lfx/base/tools/run_flow.py (1)
282-297: Unpacking failure whenget_required_datareturnsNone.If
get_required_datareturnsNone(as its type hint indicates it can), the tuple unpacking on line 285 will raiseTypeError: cannot unpack non-iterable NoneType object.Apply this diff to handle the
Nonecase:async def _get_tools(self) -> list[Tool]: """Expose flow as a tool.""" component_toolkit: type[ComponentToolkit] = get_component_toolkit() - flow_description, tool_mode_inputs = await self.get_required_data() + result = await self.get_required_data() + if result is None: + return [] + flow_description, tool_mode_inputs = result if not tool_mode_inputs: return []
🧹 Nitpick comments (13)
src/backend/tests/unit/base/tools/test_run_flow.py (2)
1-11: Remove unused import.
Messageis imported but never used in the test file.from unittest.mock import AsyncMock, MagicMock, Mock, PropertyMock, patch from uuid import uuid4 import pytest from lfx.base.tools.run_flow import RunFlowBaseComponent from lfx.graph.graph.base import Graph from lfx.schema.data import Data from lfx.schema.dotdict import dotdict from lfx.services.cache.utils import CacheMiss from lfx.template.field.base import Output -
463-481: Test relies on hardcoded separator value.The test uses
~as the separator directly. Consider usingcomponent.IOPUT_SEPto ensure the test stays in sync if the separator constant changes.def test_extract_tweaks_from_keyed_values(self): """Test extracting tweaks from keyed values.""" component = RunFlowBaseComponent() + sep = component.IOPUT_SEP values = { - "vertex1~param1": "value1", - "vertex1~param2": "value2", - "vertex2~param1": "value3", + f"vertex1{sep}param1": "value1", + f"vertex1{sep}param2": "value2", + f"vertex2{sep}param1": "value3", "invalid_key": "should_be_ignored", }src/lfx/src/lfx/helpers/flow.py (1)
88-93: Mutable default argument pattern.The
order_paramsparameter uses a mutable dict as default. While the# noqa: B006suppresses the lint warning, this is still a potential gotcha if the function ever modifies the dict. Since this is a stub that doesn't useorder_params, it's low risk, but consider usingNonewith a fallback for consistency with defensive coding practices.async def list_flows_by_flow_folder( *, user_id: str | None = None, flow_id: str | None = None, - order_params: dict | None = {"column": "updated_at", "direction": "desc"} # noqa: B006, ARG001 + order_params: dict | None = None, # noqa: ARG001 ) -> list[Data]:src/backend/base/langflow/helpers/flow.py (2)
51-56: Mutable default argument fororder_params.Same pattern as the lfx stub - using a mutable dict as default. While the current implementation doesn't mutate the dict, consider using
Nonewith a fallback for defensive coding.async def list_flows_by_flow_folder( *, user_id: str | None = None, flow_id: str | None = None, - order_params: dict | None = {"column": "updated_at", "direction": "desc"} # noqa: B006 + order_params: dict | None = None, ) -> list[Data]: + if order_params is None: + order_params = {"column": "updated_at", "direction": "desc"}
136-147: Redundant validation after already checking flow_id or flow_name.Lines 145-147 check
if not (attr and val)and raise an error, but this condition is unreachable. The earlier check on line 132-134 ensures eitherflow_idorflow_nameis provided, and lines 139-144 guaranteeattrandvalare set from one of them.# set user provided flow id or flow name. # if both are provided, flow_id is used. attr, val = None, None if flow_name: attr = "name" val = flow_name if flow_id: attr = "id" val = flow_id - if not (attr and val): - msg = "Flow id or Name is required" - raise ValueError(msg)src/backend/tests/unit/helpers/test_flow_helpers.py (1)
214-240: Consider strengthening the "prefers id over name" assertion.The test verifies that
execwas called once but doesn't verify that the query used theidattribute instead ofname. To fully validate this behavior, you could capture and inspect the SQL statement or verify the mock was called with specific arguments.Example enhancement:
# Capture the select statement from the exec call call_args = mock_session.exec.call_args select_stmt = call_args[0][0] # Verify the where clause uses Flow.id, not Flow.name # (This would require more sophisticated inspection of the SQLAlchemy statement)src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.py (1)
303-305: Minor inconsistency:model_dump()vsmodel_dump(mode="json").Line 304 uses
flow.model_dump()while other similar calls in this file (e.g., lines 40, 56, 168, 184, 246) usemodel_dump(mode="json"). This inconsistency could lead to different serialization behavior if the flow contains non-JSON-serializable types like datetime objects.- response = await client.post("api/v1/flows/", json=flow.model_dump(), headers=logged_in_headers) + response = await client.post("api/v1/flows/", json=flow.model_dump(mode="json"), headers=logged_in_headers)src/lfx/src/lfx/components/flow_controls/run_flow.py (2)
47-48: Prefer parentheses over backslash for line continuation.Line continuation using backslash is less preferred in Python. Using parentheses is cleaner and more robust.
- build_config["flow_name_selected"]["options_metadata"] \ - .append({"id": flow.data["id"], "updated_at": flow.data["updated_at"]}) + build_config["flow_name_selected"]["options_metadata"].append( + {"id": flow.data["id"], "updated_at": flow.data["updated_at"]} + )
73-75: Return type annotation mismatch.The method returns
build_config.get(...).get(...).get(field)which can returnNoneat any step, but the return type is annotated asdict. Should be-> Anyor-> dict | None.- def get_selected_flow_meta(self, build_config: dotdict, field: str) -> dict: + def get_selected_flow_meta(self, build_config: dotdict, field: str) -> Any:src/lfx/src/lfx/base/tools/run_flow.py (1)
612-616: Dead code:or 'missing_id'is unreachable.Line 614 raises a
ValueErrorwhenflow_idis falsy, so theor 'missing_id'fallback on line 616 can never execute. Consider removing it for clarity.def _build_flow_cache_key(self, *, flow_id: str | None = None) -> str | None: if not (self.user_id and flow_id): msg = "Failed to build cache key: Flow ID and user ID are required" raise ValueError(msg) - return f"run_flow:{self.user_id}:{flow_id or 'missing_id'}" + return f"run_flow:{self.user_id}:{flow_id}"src/frontend/src/components/core/dropdownComponent/index.tsx (2)
115-122: Centralize metadata key filtering to avoid future driftYou now exclude
id/updated_atin bothfilterMetadataKeysandformatTooltipContent. To keep behavior in sync long‑term, consider reusingfilterMetadataKeysinsideformatTooltipContent(and adjusting itsexcludeKeyslist if needed) instead of duplicating the exclusion logic in two places.Also applies to: 285-302, 540-568
263-283: Refresh handling and metadata passing are wired correctly
handleRefreshButtonPresscorrectly callsmutateTemplatewithisRefresh = true, matching the updated helper and API payload shape.- In the options list,
onSelect(currentValue, undefined, undefined, filteredMetadata?.[index])cleanly passes the selected option’s metadata downstream while preserving existing argument order.One behavioral note:
refreshOptionsis reset via a fixed timeout rather than awaiting the debounced mutation’s completion, so the loading state is time‑based rather than tied to request success. If you want the spinner to reflect actual completion, you’d need to hook into the mutation state instead of using a hardcoded delay.Also applies to: 487-504
src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts (1)
11-23: Confirm backend contract foris_refreshand template augmentation
- Injecting
_frontend_node_flow_id/_frontend_node_folder_idas{ value: id }fields on the template looks consistent with existing field shapes.is_refreshis added as a plain boolean on the template (is_refresh: payload.is_refresh), unlike the other injected fields. Please confirm the backend either explicitly expects this raw boolean or safely ignores non‑field entries on the template object so this doesn’t break template processing.- Minor nit: you call
useFlowsManagerStoretwice; you could destructurecurrentFlowIdandcurrentFlowin a single selector and derivefolderIdfrom that to avoid duplicate subscriptions.Also applies to: 39-53, 55-63
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
src/backend/base/langflow/helpers/flow.py(3 hunks)src/backend/base/langflow/services/database/models/flow/model.py(1 hunks)src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.py(1 hunks)src/backend/tests/unit/base/tools/test_run_flow.py(1 hunks)src/backend/tests/unit/components/logic/test_run_flow_component.py(1 hunks)src/backend/tests/unit/helpers/test_flow_helpers.py(1 hunks)src/frontend/src/CustomNodes/helpers/mutate-template.ts(3 hunks)src/frontend/src/components/core/dropdownComponent/index.tsx(4 hunks)src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsx(1 hunks)src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts(2 hunks)src/frontend/src/types/components/index.ts(1 hunks)src/lfx/src/lfx/base/tools/run_flow.py(3 hunks)src/lfx/src/lfx/components/flow_controls/run_flow.py(2 hunks)src/lfx/src/lfx/components/input_output/chat.py(1 hunks)src/lfx/src/lfx/components/input_output/chat_output.py(1 hunks)src/lfx/src/lfx/custom/custom_component/component.py(1 hunks)src/lfx/src/lfx/custom/custom_component/custom_component.py(3 hunks)src/lfx/src/lfx/graph/vertex/param_handler.py(1 hunks)src/lfx/src/lfx/helpers/__init__.py(4 hunks)src/lfx/src/lfx/helpers/flow.py(1 hunks)src/lfx/src/lfx/inputs/input_mixin.py(1 hunks)src/lfx/tests/unit/helpers/test_flow_helpers.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
src/frontend/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
src/frontend/src/**/*.{ts,tsx}: Use React 18 with TypeScript for frontend development
Use Zustand for state management
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsxsrc/frontend/src/types/components/index.tssrc/frontend/src/CustomNodes/helpers/mutate-template.tssrc/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts
src/frontend/src/**/*.{tsx,jsx,css,scss}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
Use Tailwind CSS for styling
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsx
src/frontend/src/components/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
src/frontend/src/components/**/*.{tsx,jsx}: Use React Flow for flow graph visualization with Node, Edge, Controls, and Background components
Use the cn() utility function for combining Tailwind CSS classes in components
Use TypeScript interfaces for defining component props in React components
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsx
src/frontend/src/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
src/frontend/src/**/*.{tsx,jsx}: Implement dark mode support using the useDarkMode hook and dark store
Use Lucide React for icon components in the application
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsx
src/backend/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/**/*.py: Use FastAPI async patterns withawaitfor async operations in component execution methods
Useasyncio.create_task()for background tasks and implement proper cleanup with try/except forasyncio.CancelledError
Usequeue.put_nowait()for non-blocking queue operations andasyncio.wait_for()with timeouts for controlled get operations
Files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/base/langflow/services/database/models/flow/model.pysrc/backend/base/langflow/helpers/flow.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Place backend unit tests insrc/backend/tests/directory, component tests insrc/backend/tests/unit/components/organized by component subdirectory, and integration tests accessible viamake integration_tests
Use same filename as component with appropriate test prefix/suffix (e.g.,my_component.py→test_my_component.py)
Use theclientfixture (FastAPI Test Client) defined insrc/backend/tests/conftest.pyfor API tests; it provides an asynchttpx.AsyncClientwith automatic in-memory SQLite database and mocked environment variables. Skip client creation by marking test with@pytest.mark.noclient
Inherit from the correctComponentTestBasefamily class located insrc/backend/tests/base.pybased on API access needs:ComponentTestBase(no API),ComponentTestBaseWithClient(needs API), orComponentTestBaseWithoutClient(pure logic). Provide three required fixtures:component_class,default_kwargs, andfile_names_mapping
Create comprehensive unit tests for all new backend components. If unit tests are incomplete, create a corresponding Markdown file documenting manual testing steps and expected outcomes
Test both sync and async code paths, mock external dependencies appropriately, test error handling and edge cases, validate input/output behavior, and test component initialization and configuration
Use@pytest.mark.asynciodecorator for async component tests and ensure async methods are properly awaited
Test background tasks usingasyncio.create_task()and verify completion withasyncio.wait_for()with appropriate timeout constraints
Test queue operations using non-blockingqueue.put_nowait()andasyncio.wait_for(queue.get(), timeout=...)to verify queue processing without blocking
Use@pytest.mark.no_blockbustermarker to skip the blockbuster plugin in specific tests
For database tests that may fail in batch runs, run them sequentially usinguv run pytest src/backend/tests/unit/test_database.pyr...
Files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
**/{test_*.py,*.test.ts,*.test.tsx}
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
Check that test files follow the project's naming conventions (test_*.py for backend, *.test.ts for frontend)
Files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
**/test_*.py
📄 CodeRabbit inference engine (coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt)
**/test_*.py: Backend tests should follow pytest structure with proper test_*.py naming
For async functions, ensure proper async testing patterns are used with pytest for backend
Files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
src/backend/base/langflow/services/database/models/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Database models should be organized by domain (api_key/, flow/, folder/, user/, etc.) under
src/backend/base/langflow/services/database/models/
Files:
src/backend/base/langflow/services/database/models/flow/model.py
src/backend/**/*component*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In Python component classes, set the
iconattribute to a string matching the desired icon name (e.g.,icon = "AstraDB"). The string must match the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
🧠 Learnings (22)
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Use predefined JSON flows and utility functions from `tests.unit.build_utils` (create_flow, build_flow, get_build_events, consume_and_assert_stream) for flow execution testing
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/src/lfx/components/flow_controls/run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/lfx/src/lfx/helpers/__init__.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/src/lfx/helpers/flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to tests/unit/**/*.py : Database and flow integration tests should use helper functions from `tests.unit.build_utils` such as `create_flow`, `build_flow`, and `get_build_events`
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/src/lfx/components/flow_controls/run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/src/lfx/helpers/flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths, mock external dependencies appropriately, test error handling and edge cases, validate input/output behavior, and test component initialization and configuration
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Create comprehensive unit tests for all new backend components. If unit tests are incomplete, create a corresponding Markdown file documenting manual testing steps and expected outcomes
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Use `monkeypatch` fixture to mock internal functions for testing error handling scenarios; validate error status codes and error message content in responses
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow REST API endpoints using the `client` fixture with appropriate HTTP methods (GET, POST, etc.), headers (logged_in_headers), and payload validation
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Place backend unit tests in `src/backend/tests/` directory, component tests in `src/backend/tests/unit/components/` organized by component subdirectory, and integration tests accessible via `make integration_tests`
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Use `aiofiles` and `anyio.Path` for async file operations in tests; create temporary test files using `tmp_path` fixture and verify file existence and content
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Test component versioning and backward compatibility using `file_names_mapping` fixture with `VersionComponentMapping` objects mapping component files across Langflow versions
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's `Message` objects using `langflow.schema.message.Message` and validate text, sender, sender_name, session_id, files, and properties attributes
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-11-24T19:47:40.371Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2025-11-24T19:47:40.371Z
Learning: Applies to **/test_*.py : For async functions, ensure proper async testing patterns are used with pytest for backend
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update `__init__.py` with alphabetically sorted imports when adding new components
Applied to files:
src/lfx/src/lfx/components/flow_controls/run_flow.pysrc/backend/base/langflow/helpers/flow.pysrc/lfx/src/lfx/helpers/__init__.pysrc/lfx/src/lfx/custom/custom_component/custom_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Test component build config updates by calling `to_frontend_node()` to get the node template, then calling `update_build_config()` to apply configuration changes
Applied to files:
src/lfx/src/lfx/components/flow_controls/run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Database models should be organized by domain (api_key/, flow/, folder/, user/, etc.) under `src/backend/base/langflow/services/database/models/`
Applied to files:
src/backend/base/langflow/services/database/models/flow/model.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/api/**/*.py : Backend API endpoints should be organized by version (v1/, v2/) under `src/backend/base/langflow/api/` with specific modules for features (chat.py, flows.py, users.py, etc.)
Applied to files:
src/backend/base/langflow/helpers/flow.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : For component `run()` methods, use async/await pattern and return appropriate message types
Applied to files:
src/lfx/src/lfx/custom/custom_component/component.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/**/*.py : Use FastAPI async patterns with `await` for async operations in component execution methods
Applied to files:
src/lfx/src/lfx/custom/custom_component/component.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new components to the appropriate subdirectory under `src/backend/base/langflow/components/` (agents/, data/, embeddings/, input_output/, models/, processing/, prompts/, tools/, or vectorstores/)
Applied to files:
src/lfx/src/lfx/custom/custom_component/custom_component.py
📚 Learning: 2025-08-05T22:51:27.961Z
Learnt from: edwinjosechittilappilly
Repo: langflow-ai/langflow PR: 0
File: :0-0
Timestamp: 2025-08-05T22:51:27.961Z
Learning: The TestComposioComponentAuth test in src/backend/tests/unit/components/bundles/composio/test_base_composio.py demonstrates proper integration testing patterns for external API components, including real API calls with mocking for OAuth completion, comprehensive resource cleanup, and proper environment variable handling with pytest.skip() fallbacks.
Applied to files:
src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Inherit from the correct `ComponentTestBase` family class located in `src/backend/tests/base.py` based on API access needs: `ComponentTestBase` (no API), `ComponentTestBaseWithClient` (needs API), or `ComponentTestBaseWithoutClient` (pure logic). Provide three required fixtures: `component_class`, `default_kwargs`, and `file_names_mapping`
Applied to files:
src/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:47:28.965Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-11-24T19:47:28.965Z
Learning: Applies to src/backend/tests/**/*.py : Use same filename as component with appropriate test prefix/suffix (e.g., `my_component.py` → `test_my_component.py`)
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to tests/unit/components/**/*.py : Create unit tests in `src/backend/tests/unit/components/` mirroring the component directory structure, using `ComponentTestBaseWithClient` or `ComponentTestBaseWithoutClient` base classes
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
🧬 Code graph analysis (12)
src/backend/tests/unit/helpers/test_flow_helpers.py (3)
src/backend/base/langflow/helpers/flow.py (4)
get_flow_by_id_or_name(123-164)list_flows(35-48)list_flows_by_flow_folder(51-87)list_flows_by_folder_id(90-120)src/lfx/src/lfx/helpers/flow.py (4)
get_flow_by_id_or_name(172-202)list_flows(66-85)list_flows_by_flow_folder(88-131)list_flows_by_folder_id(134-169)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/lfx/src/lfx/components/flow_controls/run_flow.py (2)
src/lfx/src/lfx/base/tools/run_flow.py (1)
RunFlowBaseComponent(29-728)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/backend/base/langflow/helpers/flow.py (3)
src/lfx/src/lfx/schema/data.py (1)
Data(26-288)src/backend/base/langflow/services/database/models/flow/model.py (2)
Flow(186-213)to_data(198-208)src/backend/tests/conftest.py (1)
flow(549-569)
src/lfx/tests/unit/helpers/test_flow_helpers.py (1)
src/backend/base/langflow/helpers/flow.py (8)
build_schema_from_inputs(364-381)get_arg_names(384-397)get_flow_by_id_or_name(123-164)list_flows(35-48)list_flows_by_flow_folder(51-87)list_flows_by_folder_id(90-120)load_flow(167-190)run_flow(201-253)
src/lfx/src/lfx/custom/custom_component/component.py (2)
src/lfx/src/lfx/base/tools/run_flow.py (1)
update_outputs(432-463)src/lfx/tests/unit/custom/custom_component/test_update_outputs.py (2)
update_outputs(95-111)update_outputs(187-205)
src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts (2)
src/frontend/src/types/api/index.ts (1)
APIClassType(31-68)src/frontend/src/controllers/API/helpers/constants.ts (1)
getURL(40-50)
src/lfx/src/lfx/helpers/__init__.py (1)
src/lfx/src/lfx/helpers/flow.py (5)
get_flow_by_id_or_name(172-202)get_flow_inputs(20-29)list_flows(66-85)list_flows_by_flow_folder(88-131)list_flows_by_folder_id(134-169)
src/lfx/src/lfx/custom/custom_component/custom_component.py (2)
src/backend/base/langflow/helpers/flow.py (4)
get_flow_by_id_or_name(123-164)list_flows(35-48)list_flows_by_flow_folder(51-87)list_flows_by_folder_id(90-120)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/lfx/src/lfx/components/input_output/chat_output.py (1)
src/lfx/src/lfx/custom/custom_component/custom_component.py (1)
graph(191-192)
src/lfx/src/lfx/helpers/flow.py (2)
src/backend/base/langflow/helpers/flow.py (3)
list_flows_by_flow_folder(51-87)list_flows_by_folder_id(90-120)get_flow_by_id_or_name(123-164)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/lfx/src/lfx/components/input_output/chat.py (2)
src/lfx/src/lfx/custom/custom_component/custom_component.py (1)
graph(191-192)src/lfx/src/lfx/schema/message.py (2)
Message(34-299)create(287-291)
src/backend/tests/unit/components/logic/test_run_flow_component.py (1)
src/lfx/src/lfx/components/flow_controls/run_flow.py (5)
get_selected_flow_meta(73-75)load_graph_and_update_cfg(77-88)should_update_stale_flow(90-96)check_and_update_stale_flow(98-106)update_build_config(24-71)
🪛 GitHub Actions: autofix.ci
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsx
[warning] 1-1: Unstaged changes detected after reset during autofix workflow. The file was modified and staged automatically.
src/frontend/src/components/core/dropdownComponent/index.tsx
[warning] 1-1: Unstaged changes detected after reset during autofix workflow. The file was modified and staged automatically.
src/frontend/src/types/components/index.ts
[warning] 1-1: Unstaged changes detected after reset during autofix workflow. The file was modified and staged automatically.
src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts
[warning] 1-1: Unstaged changes detected after reset during autofix workflow. The file was modified and staged automatically.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
- GitHub Check: Lint Backend / Run Mypy (3.10)
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Lint Backend / Run Mypy (3.12)
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Run Frontend Unit Tests / Frontend Jest Unit Tests
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Update Component Index
- GitHub Check: Update Starter Projects
🔇 Additional comments (62)
src/lfx/src/lfx/custom/custom_component/component.py (1)
580-583: LGTM! Clean async/sync compatibility pattern.The conditional handling for both synchronous and asynchronous
update_outputsimplementations is well-implemented and follows the established pattern used elsewhere in this file (e.g., lines 1359-1362 for_get_tools). This provides excellent backward compatibility while supporting async operations.src/lfx/src/lfx/components/input_output/chat.py (1)
92-101: LGTM! Correct session_id derivation and usage.The implementation correctly derives the session_id with fallback to
self.graph.session_id(line 92) and uses it consistently for both message creation (line 97) and the storage condition (line 101). This is the proper pattern.Note: The session_id derivation logic is duplicated in
chat_output.py(line 130) and could be extracted into a shared helper method on the baseChatComponentclass, as suggested in the review of that file.src/backend/base/langflow/services/database/models/flow/model.py (1)
198-208: LGTM!The addition of
folder_idto theto_data()serialization is consistent with the existing pattern and necessary for the new flow retrieval helpers that filter by folder.src/lfx/src/lfx/inputs/input_mixin.py (1)
64-66: LGTM!The
override_skipfield follows the existing pattern of boolean configuration options in the mixin. The integration withshould_skip_fieldinparam_handler.pycorrectly ensures fields with this flag are always processed.src/lfx/src/lfx/graph/vertex/param_handler.py (1)
129-138: LGTM!The
override_skipguard is correctly placed as an early return before other skip conditions, ensuring fields with this flag are always processed regardless of other criteria.src/backend/tests/unit/base/tools/test_run_flow.py (1)
24-687: Comprehensive test coverage.The test suite thoroughly covers initialization, flow retrieval, caching, timestamp parsing, I/O handling, pre-run setup, and output resolution. Good use of mocking patterns and async test decorators.
src/lfx/src/lfx/helpers/flow.py (1)
172-202: Stub implementation is well-structured.The
get_flow_by_id_or_namestub correctly validates required parameters, logs a warning about the missing database backend, and returnsNoneas expected. The docstring clearly explains this is a stub.src/backend/base/langflow/helpers/flow.py (2)
70-84: Self-join query is well-constructed.The aliased join pattern correctly finds flows in the same folder as the specified flow while excluding the source flow itself. The query filters properly by user ownership on both sides of the join.
30-33: SORT_DISPATCHER is a clean approach for dynamic ordering.Mapping direction strings to SQLAlchemy ordering functions is a maintainable pattern that avoids repetitive conditional logic.
src/backend/tests/unit/components/logic/test_run_flow_component.py (3)
1-23: Test class organization follows project conventions.The test file is well-organized with separate classes for initialization, helper methods, and build config testing. Metadata assertions in
test_component_has_correct_metadataensure component attributes remain stable.
504-555: Runtime integration test verifies critical flow execution path.This test ensures the runtime correctly passes the cached
updated_attimestamp toget_graph, which is essential for the cache freshness checking mechanism.
677-716: Good coverage of stale flow detection during refresh.The test verifies that
check_and_update_stale_flowis called when refreshing the flow list, ensuring stale flows are automatically updated.src/lfx/src/lfx/helpers/__init__.py (1)
39-46: LGTM!The new helper exports (
get_flow_by_id_or_name,list_flows_by_flow_folder,list_flows_by_folder_id) are consistently added across all import branches (langflow, fallback, lfx) and properly exported in__all__. The alphabetical ordering is maintained as per the learnings.Also applies to: 75-82, 111-118, 133-137
src/backend/tests/unit/helpers/test_flow_helpers.py (4)
1-12: LGTM!Imports are well-organized and test file naming follows the
test_*.pyconvention. Thepatchimport from unittest.mock is correctly included for mocking database sessions.
15-48: LGTM!The
TestListFlowsclass correctly tests both the error case (missing user_id) and the database query path with proper async mocking ofsession_scope. The mock setup for the async context manager follows best practices.
50-114: LGTM!Good test coverage for error cases and the basic query path. The
test_list_flows_by_flow_folder_respects_order_paramstest validates that the function accepts order parameters without error; verifying actual ordering behavior would require more complex assertions on the SQL statement, which is acceptable to defer.
117-152: LGTM!The
TestListFlowsByFolderIdclass appropriately tests validation errors and the database query path, following the same consistent mocking pattern.src/lfx/tests/unit/helpers/test_flow_helpers.py (7)
1-17: LGTM!Imports are well-organized. The
UUIDimport on line 2 is used on line 227 for theset_run_idassertion, so it's not unused.
20-42: LGTM!Clear test that validates the filtering logic for input vertices.
45-63: LGTM!Good validation of the schema building logic, including the field naming transformation from display names.
66-81: LGTM!Clear test that validates the argument name extraction logic.
84-176: LGTM!Comprehensive tests for the lfx stub implementations, correctly validating error handling and the expected empty/None return values.
179-189: LGTM!Correctly validates that
load_flowraisesNotImplementedErrorin the lfx stub implementation.
192-283: LGTM!Thorough test coverage for
run_flowincluding error handling, graph property setting, input normalization (dict to list), and correct invocation ofgraph.arun. The tests properly validate the expected call arguments structure.src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.py (6)
1-10: LGTM!Imports are well-organized with proper separation between langflow and lfx dependencies. The integration test file follows the correct location pattern under
src/backend/tests/integration/.
12-101: LGTM!Excellent end-to-end integration test that validates the complete workflow including flow creation,
update_build_configbehavior, and proper exclusion of the current flow from options. Good use of try/finally for cleanup.
103-138: LGTM!Good integration test for
run_flowexecution with real components, validating that graph properties are set correctly and the result structure is as expected.
141-226: LGTM!Comprehensive integration test for tool generation from flows. Good validation of flow ownership and the ability to retrieve graphs and generate tools from real database flows.
229-284: LGTM!Good test for output resolution with real flow structure. The use of
SimpleNamespaceto mock the_vertexattribute is a pragmatic approach for integration testing.
334-337: Verify assertion intent:==vsis.The comment states "Expected same graph instance from cache" but the assertion uses
==(equality) rather thanis(identity). If the intent is to verify that caching returns the exact same object instance, useassert graph1 is graph2.- assert graph1 == graph2, "Expected same graph instance from cache" + assert graph1 is graph2, "Expected same graph instance from cache"src/lfx/src/lfx/components/flow_controls/run_flow.py (5)
1-6: LGTM!Imports are appropriate for the new functionality.
datetimeis needed for timestamp handling andDatafor type annotations.
90-96: LGTM, though consider readability.The logic using chained walrus operators is correct but dense. The current implementation works, but consider extracting the timestamp comparisons for clarity if maintenance becomes an issue.
98-106: LGTM!The method correctly combines the stale check and update logic. The TODO comment on line 100 indicates awareness of potential future improvements.
108-110: LGTM!Simple utility for ISO timestamp string conversion. The method name
get_str_isotsis a bit cryptic;get_iso_timestampmight be clearer, but this is a minor naming preference.
77-88: No issues found - review comment is incorrect.The
get_graphmethod signature shows thatflow_name_selectedandflow_id_selectedare both optional parameters with defaultNone. The method requires at least one of them (line 144-146 validates this), and the reviewed code providesflow_id_selected, satisfying the requirement. Passing onlyflow_id_selectedandupdated_atis valid and correct.Likely an incorrect or invalid review comment.
src/lfx/src/lfx/custom/custom_component/custom_component.py (5)
15-22: LGTM - imports aligned with new flow helper utilities.The imports properly bring in the new flow-discovery helpers that are used by the new methods in this file.
556-562: LGTM - consistent error handling pattern.The refactored method properly delegates validation to the underlying
list_flowshelper and wraps exceptions consistently.
564-576: LGTM - handles missing flow_id gracefully.Returning an empty list when
flow_idis unavailable is appropriate for scenarios where the flow context isn't yet established (e.g., during component initialization).
578-590: LGTM - consistent implementation with sibling method.The method follows the same pattern as
alist_flows_by_flow_folder, ensuring API consistency.
637-655: LGTM - clean utility for attribute resolution.The helper provides a clear fallback mechanism from runtime to frontend node attributes with good documentation.
src/lfx/src/lfx/base/tools/run_flow.py (19)
29-55: LGTM - well-structured initialization with cache dispatcher.The dispatcher pattern cleanly organizes cache operations, and the instance variables for tracking run outputs and freshness are appropriately initialized.
56-96: LGTM - well-defined base inputs with appropriate configuration.The inputs are properly configured with
real_time_refreshfor dynamic updates andoverride_skip=Trueto persist the flow ID to runtime.
101-119: LGTM - proper lifecycle management for dynamic output methods.The method correctly clears old dynamic methods before registering new ones, preventing stale method references.
177-186: LGTM - correct field management logic.The method properly preserves new fields and default keys while removing stale fields from the build config.
188-216: LGTM - good handling of display name collisions.The use of
Counterto detect duplicate vertex display names and the disambiguation logic with vertex ID suffixes is well implemented.
302-325: LGTM - efficient caching of run outputs.The method correctly caches flow execution results to avoid redundant runs when resolving multiple outputs from the same flow execution.
327-361: LGTM - comprehensive output resolution with reasonable fallbacks.The resolution logic correctly prioritizes exact matches in
resultsandartifactsdictionaries before falling back to the complete output data.
383-402: LGTM - clean dynamic method registration pattern.The use of
MethodTypeto bind dynamic resolver functions is appropriate, and the sanitization of vertex/output names prevents invalid method names.
407-430: LGTM - proper preservation of tool output during sync.The method correctly handles the tool output, ensuring it's preserved from the existing outputs map or found in the new outputs list.
432-463: LGTM - well-structured output update flow.The method properly guards against invalid inputs and uses metadata for cache optimization when updating frontend node outputs.
468-507: LGTM - thorough output formatting with collision handling.The display name logic correctly handles various scenarios: single output vertices, multiple outputs, and duplicate vertex display names.
509-526: LGTM - simple and well-validated utility.
531-556: LGTM - clean integration of cached graph with flow execution.The method properly retrieves the cached graph, applies tweaks, and executes the flow.
561-587: LGTM - robust cache dispatcher with graceful error handling.The method properly guards against disabled caching and missing services, with appropriate exception handling for non-critical cache operations.
618-629: LGTM - proper graph reconstruction from cache.The method correctly handles missing data with appropriate fallbacks for description and updated_at fields.
631-646: LGTM - conservative cache freshness validation.The timestamp comparison correctly requires both values to be present and uses a >= comparison, treating any cache with matching or newer timestamp as valid.
648-671: LGTM - thorough validation before cache deletion.The method properly validates all required parameters including the edge case of whitespace-only flow IDs.
676-705: LGTM - clean data transformation for tweaks and inputs.The methods correctly parse keyed field names into structured tweaks and build appropriate input payloads for flow execution.
720-728: LGTM - proper state reset for new flow execution.The method correctly resets cached outputs and extracts fresh tweak data before each run.
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsx (1)
27-36: Selected metadata propagation looks correct
onChangenow cleanly threadsselectedMetadatathrough asselected_metadataonly when provided, without altering existingvalue/load_from_dbbehavior. No issues from a type or flow perspective.src/frontend/src/types/components/index.ts (1)
56-74: DropdownonSelectAPI extension is backward‑compatibleAdding
selectedMetadata?: anyas a 4th argument aligns with the new dropdown usage and remains optional, so existing call sites stay valid.src/frontend/src/CustomNodes/helpers/mutate-template.ts (1)
14-29:isRefreshflag is consistently threaded through the mutation pathThe new
isRefresh?: booleanparameter is correctly propagated into the debounced function and onto the mutation payload asis_refresh: isRefresh ?? false, so existing callers getfalseby default while refresh callers can opt intotrue. This keeps prior behavior intact and provides a clear switch for the backend.Also applies to: 35-57, 90-101
2eabe13 to
e6da1c2
Compare
ff481bf to
41b4bd1
Compare
misc: remove commented out code feat: add refresh button and sort flows by updated_at date from most to least recent ruff (flow.py imports) improve fn contracts in runflow and improve flow id retrieval logic based on graph exec context add dynamic outputs and optimize db lookups add flow cache and db query for getting a single flow by id or name cache run outputs and add refresh context to build config misc misc use ids for flow retrieval misc fix missing flow_id bug add unit and integration tests add input field flag to persist hidden fields at runtime move unit tests and change input and output display names chore: update component index fix: fix tool mode when flow has multiple inputs by dynamically creating resolvers chore: update component index ruff (run_flow and tests) add resolvers to outputs map for non tool mode runtime fix tests (current flow excluded in db fetch) mypy (helpers/flow.py) chore: update component index remove unused code and clean up comments fix: persist user messages in chat-based flows via session injection chore: update component index empty string fallback for sessionid in chat.py chore: update component index chore: update component index cache invalidation with timestamps misc add cache invalidation chore: update component index chore: update comp idx ruff (run_flow.py) change session_id input type to MessageTextInput chore: update component index chore: update component index chore: update component index chore: update component index sync starter projects with main chore: update component index chore: update component index chore: update component index remove dead code + impl coderabbit suggestions chore: update component index chore: update component index clear options metadata before updating chore: update component index sync starter projects with main sync starter projects with main default param val (list flows)
Cristhianzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
e303c96 to
9631265
Compare
* feat: optimize dropdown filtering and output resolution misc: remove commented out code feat: add refresh button and sort flows by updated_at date from most to least recent ruff (flow.py imports) improve fn contracts in runflow and improve flow id retrieval logic based on graph exec context add dynamic outputs and optimize db lookups add flow cache and db query for getting a single flow by id or name cache run outputs and add refresh context to build config misc misc use ids for flow retrieval misc fix missing flow_id bug add unit and integration tests add input field flag to persist hidden fields at runtime move unit tests and change input and output display names chore: update component index fix: fix tool mode when flow has multiple inputs by dynamically creating resolvers chore: update component index ruff (run_flow and tests) add resolvers to outputs map for non tool mode runtime fix tests (current flow excluded in db fetch) mypy (helpers/flow.py) chore: update component index remove unused code and clean up comments fix: persist user messages in chat-based flows via session injection chore: update component index empty string fallback for sessionid in chat.py chore: update component index chore: update component index cache invalidation with timestamps misc add cache invalidation chore: update component index chore: update comp idx ruff (run_flow.py) change session_id input type to MessageTextInput chore: update component index chore: update component index chore: update component index chore: update component index sync starter projects with main chore: update component index chore: update component index chore: update component index remove dead code + impl coderabbit suggestions chore: update component index chore: update component index clear options metadata before updating chore: update component index sync starter projects with main sync starter projects with main default param val (list flows) * chore: update component index * add integration tests * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Cristhian Zanforlin <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
from #10576 (moved from fork to langflow-ai)
This PR implements various improvements and optimizations (Breaking Changes) for the run flow component.
This PR implements the following improvements to the runflow component:
override_skipboolean flag to the base input mixin so that derived inputs (e.g., the id of the selected flow) can be persisted to runtime but kept hidden from the user entirely (show=False) for user-friendliness.