Feat: Runflow optimization and improved dropdown behavior#10576
Feat: Runflow optimization and improved dropdown behavior#10576HzaRashid wants to merge 3 commits into
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 enhances flow management by introducing new query helpers (list_flows_by_flow_folder, list_flows_by_folder_id, get_flow_by_id_or_name), refactoring RunFlowComponent with caching and dynamic graph retrieval, updating frontend metadata handling, and adding comprehensive test coverage across backend and frontend layers. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Frontend/Dropdown
participant Cache as Component Cache
participant Helper as Flow Helper
participant Graph as Graph Service
participant DB as Database
UI->>Helper: list_flows_by_flow_folder(user_id, flow_id)
Helper->>DB: Query flows in folder
DB-->>Helper: Flow list
Helper-->>UI: Populate dropdown options
UI->>UI: User selects flow
UI->>Helper: get_graph(flow_name_selected, flow_id_selected)
Helper->>Cache: Check _build_flow_cache_key
alt Cache Hit
Cache-->>Helper: Cached Graph
else Cache Miss
Helper->>DB: Fetch Flow data
DB-->>Helper: Flow Data
Helper->>Graph: Build Graph from data
Graph-->>Helper: Graph object
Helper->>Cache: Cache graph
end
Helper-->>UI: Graph
UI->>UI: update_build_config_from_graph
UI-->>UI: Populate dynamic input fields
sequenceDiagram
participant User as User/Run
participant Setup as _pre_run_setup
participant Cache as Cache Service
participant Run as _run_flow_with_cached_graph
participant Output as Output Resolution
User->>Setup: Trigger pre-run
Setup->>Cache: Clear cached run outputs
Setup->>Setup: Rebuild tweak data
Setup-->>User: Ready for run
User->>Run: Execute with tweaks/inputs
Run->>Cache: Get cached graph
Run->>Run: Build flow inputs
Run->>Run: Execute flow (arun)
Run->>Cache: Cache run outputs
Run-->>User: Execution complete
User->>Output: Resolve flow output
Output->>Cache: Fetch cached run outputs
Cache-->>Output: Outputs
Output->>Output: Extract by vertex_id + output_name
Output-->>User: Resolved output
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 (2 warnings)
✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (5)
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsx (1)
27-42: Consider stronger typing for selectedMetadata.The
selectedMetadataparameter is typed asany, which reduces type safety. Consider defining a specific type for the metadata object or using a more constrained type likeRecord<string, unknown>.const onChange = ( value: any, dbValue?: boolean, skipSnapshot?: boolean, - selectedMetadata?: any, + selectedMetadata?: Record<string, unknown>, ) => { - const changes: Record<string, any> = { + const changes: Record<string, unknown> = { value, load_from_db: dbValue, }; // If metadata provided, include it as selected_metadata if (selectedMetadata !== undefined) { changes.selected_metadata = selectedMetadata; } handleOnNewValue(changes, { skipSnapshot }); };src/frontend/src/components/core/dropdownComponent/index.tsx (1)
267-283: Consider refactoring to avoid multiple undefined parameters.Passing multiple
undefinedvalues as positional parameters (lines 274-277) reduces code readability and makes the function call fragile to parameter order changes.Consider refactoring
mutateTemplateto accept an options object instead:await mutateTemplate( value, nodeId, nodeClass!, handleNodeClass, postTemplateValue, setErrorData, { isRefresh: true, } );This would require updating the
mutateTemplatefunction signature insrc/frontend/src/CustomNodes/helpers/mutate-template.ts.src/frontend/src/types/components/index.ts (1)
66-71: Strengthen type safety for selectedMetadata.The
selectedMetadataparameter is typed asany. Consider creating a dedicated interface or using a more specific type to improve type safety and developer experience.+export type DropdownMetadata = Record<string, unknown>; + export type DropDownComponent = { // ... other fields onSelect: ( value: string, dbValue?: boolean, snapshot?: boolean, - selectedMetadata?: any, + selectedMetadata?: DropdownMetadata, ) => void; // ... rest };src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts (1)
15-22: Address the TODO comment for the is_refresh hack.The comment indicates this is a temporary workaround to avoid expensive backend re-fetches. Consider tracking this technical debt with a dedicated issue to ensure a proper solution is implemented.
Would you like me to help draft an issue description or suggest alternative approaches to optimize dropdown option fetching?
src/backend/base/langflow/helpers/flow.py (1)
30-33: Add trailing comma for consistency.The dictionary is missing a trailing comma after the last item, which is a Python best practice for easier diffs and future additions.
Apply this diff:
SORT_DISPATCHER = { "asc": asc, - "desc": desc + "desc": desc, }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
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(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 (11)
src/frontend/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
src/frontend/src/**/*.{ts,tsx,js,jsx}: All frontend TypeScript and JavaScript code should be located under src/frontend/src/ and organized into components, pages, icons, stores, types, utils, hooks, services, and assets directories as per the specified directory layout.
Use React 18 with TypeScript for all UI components in the frontend.
Format all TypeScript and JavaScript code using the make format_frontend command.
Lint all TypeScript and JavaScript code using the make lint command.
Files:
src/frontend/src/types/components/index.tssrc/frontend/src/CustomNodes/helpers/mutate-template.tssrc/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/controllers/API/queries/nodes/use-post-template-value.tssrc/frontend/src/components/core/dropdownComponent/index.tsx
src/frontend/src/types/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
All TypeScript type definitions should be placed in the types directory.
Files:
src/frontend/src/types/components/index.ts
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/services/database/models/flow/model.pysrc/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/backend/base/langflow/helpers/flow.py
src/backend/base/langflow/services/database/models/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Place database models in src/backend/base/langflow/services/database/models/
Files:
src/backend/base/langflow/services/database/models/flow/model.py
src/backend/tests/unit/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/tests/unit/components/**/*.py: Mirror the component directory structure for unit tests in src/backend/tests/unit/components/
Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
Provide file_names_mapping for backward compatibility in component tests
Create comprehensive unit tests for all new components
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
src/backend/tests/unit/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.py
src/backend/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.py
src/backend/**/*component*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In your Python component class, set the
iconattribute to a string matching the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
src/backend/**/components/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)
In your Python component class, set the
iconattribute to a string matching the frontend icon mapping exactly (case-sensitive).
Files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
src/frontend/src/components/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
All components should be styled using Tailwind CSS utility classes.
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsx
src/frontend/src/@(components|hooks)/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/frontend_development.mdc)
Implement dark mode support in components and hooks where needed.
Files:
src/frontend/src/components/core/parameterRenderComponent/components/dropdownComponent/index.tsxsrc/frontend/src/components/core/dropdownComponent/index.tsx
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components/**/@(FlowGraph|nodes)/**/*.{ts,tsx,js,jsx} : Use React Flow for flow graph visualization components.
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.487Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/
Applied to files:
src/backend/base/langflow/services/database/models/flow/model.py
📚 Learning: 2025-07-18T18:25:54.487Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.487Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/lfx/src/lfx/components/flow_controls/run_flow.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/lfx/src/lfx/custom/custom_component/custom_component.pysrc/lfx/src/lfx/base/tools/run_flow.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test component configuration updates in backend Python tests by asserting correct updates to build configuration objects.
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test flows using predefined JSON data and utility functions such as 'create_flow', 'build_flow', 'get_build_events', and 'consume_and_assert_stream' in backend Python tests.
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.pysrc/lfx/src/lfx/helpers/flow.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test backward compatibility across Langflow versions in backend Python tests by mapping component files to supported versions using 'VersionComponentMapping'.
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Validate input/output behavior and test component initialization and configuration in backend Python tests.
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/backend/tests/unit/base/tools/test_run_flow.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/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure for unit tests in src/backend/tests/unit/components/
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.pysrc/backend/tests/unit/base/tools/test_run_flow.pysrc/lfx/src/lfx/helpers/__init__.pysrc/lfx/src/lfx/custom/custom_component/custom_component.pysrc/backend/base/langflow/helpers/flow.pysrc/lfx/src/lfx/base/tools/run_flow.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Applied to files:
src/backend/tests/unit/components/logic/test_run_flow_component.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's REST API endpoints in backend Python tests using the async client fixture and asserting response codes and payloads.
Applied to files:
src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's Message objects and chat functionality in backend Python tests by asserting correct instantiation and property values.
Applied to files:
src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.pysrc/backend/tests/unit/helpers/test_flow_helpers.pysrc/lfx/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Applied to files:
src/backend/tests/unit/helpers/test_flow_helpers.py
📚 Learning: 2025-07-18T18:27:12.609Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components/**/@(FlowGraph|nodes)/**/*.{ts,tsx,js,jsx} : Use React Flow for flow graph visualization components.
Applied to files:
src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Applied to files:
src/backend/tests/unit/base/tools/test_run_flow.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Applied to files:
src/lfx/src/lfx/custom/custom_component/custom_component.py
🧬 Code graph analysis (13)
src/backend/tests/unit/components/logic/test_run_flow_component.py (5)
src/backend/base/langflow/helpers/flow.py (1)
run_flow(200-252)src/lfx/src/lfx/custom/custom_component/custom_component.py (6)
run_flow(534-550)graph(191-192)build_config(248-254)update_build_config(256-267)flow_id(201-202)flow_name(205-206)src/lfx/src/lfx/components/flow_controls/run_flow.py (2)
RunFlowComponent(8-56)update_build_config(22-56)src/lfx/src/lfx/graph/graph/base.py (1)
Graph(57-2295)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/backend/tests/integration/base/tools/run_flow/test_run_flow_integration.py (3)
src/lfx/src/lfx/helpers/flow.py (1)
run_flow(235-308)src/lfx/src/lfx/graph/graph/base.py (2)
Graph(57-2295)dump(227-251)src/lfx/src/lfx/base/tools/run_flow.py (10)
_get_tools(311-326)_pre_run_setup(615-619)_resolve_flow_output(331-365)get_graph(172-199)_build_flow_cache_key(532-536)_get_cached_flow(508-517)_set_cached_flow(519-530)_get_cached_run_outputs(550-575)_flow_cache_call(481-506)_build_graph_from_dict(538-548)
src/lfx/src/lfx/components/flow_controls/run_flow.py (2)
src/lfx/src/lfx/custom/custom_component/custom_component.py (4)
update_build_config(256-267)build_config(248-254)graph(191-192)alist_flows_by_flow_folder(564-573)src/lfx/src/lfx/base/tools/run_flow.py (2)
get_graph(172-199)update_build_config_from_graph(208-217)
src/backend/tests/unit/helpers/test_flow_helpers.py (2)
src/backend/base/langflow/helpers/flow.py (5)
get_flow_by_id_or_name(122-163)list_flows(35-48)list_flows_by_flow_folder(51-86)list_flows_by_folder_id(89-119)run_flow(200-252)src/backend/base/langflow/services/database/models/flow/model.py (2)
Flow(186-213)to_data(198-208)
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(38-48)
src/backend/tests/unit/base/tools/test_run_flow.py (4)
src/lfx/src/lfx/base/tools/run_flow.py (17)
RunFlowBaseComponent(27-619)get_flow(159-170)get_graph(172-199)_flow_cache_call(481-506)_build_flow_cache_key(532-536)_get_cached_flow(508-517)_set_cached_flow(519-530)_get_ioput_name(435-452)_extract_tweaks_from_keyed_values(577-589)_build_inputs_from_tweaks(598-613)_format_flow_outputs(405-433)delete_fields(255-265)update_input_types(292-309)data_output(90-110)message_output(134-153)_resolve_flow_output(331-365)get_required_data(267-290)src/lfx/src/lfx/graph/graph/base.py (2)
Graph(57-2295)dump(227-251)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)src/lfx/src/lfx/schema/message.py (1)
Message(34-299)
src/lfx/tests/unit/helpers/test_flow_helpers.py (2)
src/lfx/src/lfx/graph/graph/base.py (3)
Graph(57-2295)run_id(617-629)set_run_id(631-640)src/lfx/src/lfx/helpers/flow.py (9)
build_schema_from_inputs(32-47)get_arg_names(50-63)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)load_flow(205-232)run_flow(235-308)
src/lfx/src/lfx/helpers/__init__.py (2)
src/backend/base/langflow/helpers/flow.py (4)
get_flow_by_id_or_name(122-163)list_flows(35-48)list_flows_by_flow_folder(51-86)list_flows_by_folder_id(89-119)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/custom/custom_component/custom_component.py (1)
src/lfx/src/lfx/helpers/flow.py (6)
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)load_flow(205-232)run_flow(235-308)
src/backend/base/langflow/helpers/flow.py (4)
src/lfx/src/lfx/schema/data.py (1)
Data(26-288)src/lfx/src/lfx/helpers/flow.py (3)
list_flows_by_flow_folder(88-131)list_flows_by_folder_id(134-169)get_flow_by_id_or_name(172-202)src/backend/base/langflow/services/deps.py (1)
session_scope(164-198)src/backend/base/langflow/services/database/models/flow/model.py (2)
Flow(186-213)to_data(198-208)
src/lfx/src/lfx/custom/custom_component/component.py (2)
src/lfx/src/lfx/base/tools/run_flow.py (1)
update_outputs(375-403)src/lfx/tests/unit/custom/custom_component/test_update_outputs.py (2)
update_outputs(95-111)update_outputs(187-205)
src/lfx/src/lfx/helpers/flow.py (2)
src/backend/base/langflow/helpers/flow.py (3)
list_flows_by_flow_folder(51-86)list_flows_by_folder_id(89-119)get_flow_by_id_or_name(122-163)src/lfx/src/lfx/schema/data.py (1)
Data(26-288)
src/lfx/src/lfx/base/tools/run_flow.py (5)
src/backend/base/langflow/helpers/flow.py (3)
get_flow_by_id_or_name(122-163)get_flow_inputs(351-360)run_flow(200-252)src/lfx/src/lfx/helpers/flow.py (3)
get_flow_by_id_or_name(172-202)get_flow_inputs(20-29)run_flow(235-308)src/backend/base/langflow/processing/process.py (1)
process_tweaks_on_graph(207-216)src/lfx/src/lfx/custom/custom_component/component.py (3)
Component(97-1836)log(1483-1500)update_outputs(593-598)src/backend/base/langflow/services/deps.py (1)
get_shared_component_cache_service(212-220)
🪛 GitHub Actions: Ruff Style Check
src/backend/tests/unit/helpers/test_flow_helpers.py
[error] 10-10: F401 'langflow.helpers.flow.run_flow' imported but unused
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/tests/unit/helpers/test_flow_helpers.py
[failure] 10-10: Ruff (F401)
src/backend/tests/unit/helpers/test_flow_helpers.py:10:5: F401 langflow.helpers.flow.run_flow imported but unused
src/lfx/src/lfx/custom/custom_component/custom_component.py
[failure] 591-591: Ruff (E501)
src/lfx/src/lfx/custom/custom_component/custom_component.py:591:121: E501 Line too long (121 > 120)
⏰ 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). (49)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 25/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 36/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 38/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 34/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 26/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 39/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 40/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 37/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 35/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 33/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 21/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 30/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 32/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 31/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 28/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 24/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 14/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 29/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 19/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 27/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 18/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 15/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 23/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 16/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 22/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 20/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 17/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 13/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 11/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 12/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/40
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/40
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- 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 / LFX Tests - Python 3.10
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
🔇 Additional comments (20)
src/frontend/src/components/core/dropdownComponent/index.tsx (2)
115-122: Verify that excluding "id" from metadata displays is intentional.The
filterMetadataKeysfunction now excludes "id" by default. Ensure this aligns with product requirements, as some users may find the ID useful for debugging or reference purposes.
503-508: Metadata propagation looks correct.The option-specific metadata is properly passed to the
onSelectcallback, enabling downstream components to access flow/folder information.src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts (1)
39-55: Context-aware payload construction looks good.The preparedTemplate correctly includes flow and folder IDs when available, enabling the backend to filter flows appropriately. The conditional spreading pattern is clean and readable.
src/frontend/src/CustomNodes/helpers/mutate-template.ts (1)
28-101: Parameter threading through debounced function is correct.The
isRefreshparameter is properly threaded through the outer function, debounced callback, and API call. The default value offalseensures backward compatibility for existing call sites.src/lfx/src/lfx/custom/custom_component/component.py (1)
554-557: LGTM! Async/sync compatibility handled correctly.The implementation properly detects and handles both synchronous and asynchronous
update_outputsmethods, ensuring compatibility across different component implementations.src/lfx/src/lfx/graph/vertex/param_handler.py (1)
132-133: LGTM! Override skip logic is correct.The early return when
override_skipis set ensures fields marked with this flag bypass all skip checks, allowing them to be processed even when hidden from users.src/backend/tests/unit/base/tools/test_run_flow.py (1)
1-565: LGTM! Comprehensive test coverage for RunFlowBaseComponent.This test suite provides thorough coverage of initialization, flow retrieval, caching behavior, input/output handling, pre-run setup, and output methods. The tests use appropriate mocking patterns and follow pytest best practices.
Based on learnings
src/backend/tests/unit/components/logic/test_run_flow_component.py (1)
1-381: LGTM! Thorough test coverage for RunFlowComponent.The test suite comprehensively covers component initialization, metadata validation, and various
update_build_configscenarios including error handling, flow refreshing, and graph updates. Tests follow established patterns for component testing.Based on learnings
src/backend/tests/unit/helpers/test_flow_helpers.py (1)
16-241: LGTM! Comprehensive test coverage for flow helpers.The test suite thoroughly covers all flow helper functions with proper error handling validation and database interaction mocking. Well-structured and follows testing best practices.
Based on learnings
src/lfx/src/lfx/helpers/__init__.py (1)
39-43: LGTM! New flow helpers properly exported.The new flow helper functions (
get_flow_by_id_or_name,list_flows_by_flow_folder,list_flows_by_folder_id) are correctly imported across all three import paths and properly exported in__all__.As per coding guidelines
Also applies to: 75-79, 111-115, 133-137
src/lfx/src/lfx/helpers/flow.py (1)
88-202: LGTM! Appropriate stub implementations for lfx.The three new flow helper functions provide proper parameter validation and return appropriate stub values (empty lists or None) since lfx doesn't have a database backend by default. The implementations align with their backend counterparts and include helpful warning logs.
src/lfx/tests/unit/helpers/test_flow_helpers.py (1)
1-283: LGTM! Comprehensive test coverage for lfx flow helpers.This test suite provides thorough coverage of all flow helper functions including error handling, stub behavior validation, and proper interaction with Graph objects. The tests are well-structured and follow pytest best practices.
Based on learnings
src/lfx/src/lfx/custom/custom_component/custom_component.py (5)
15-22: LGTM!The new helper imports are properly organized and all are used by the new methods added in this file.
556-562: LGTM!The addition of error handling and documentation improves robustness and clarity.
564-573: LGTM!The method correctly retrieves flows from the same folder as the current flow, with proper error handling and fallback behavior.
575-584: LGTM!The implementation follows the same pattern as
alist_flows_by_flow_folderand correctly handles folder-based flow listing.
627-645: LGTM!The helper method provides a clean abstraction for retrieving attributes with proper fallback logic between runtime and frontend node contexts.
src/backend/base/langflow/helpers/flow.py (3)
9-10: LGTM!The new imports support the SQL join operations and dynamic ordering functionality added in this PR.
89-119: LGTM!The implementation correctly filters flows by folder ID with proper user scoping and dynamic ordering.
122-163: LGTM!The implementation correctly handles flow retrieval by ID or name with proper precedence (ID over name) and type conversions.
2ef3268 to
0a0c9e4
Compare
77f630f to
06537cf
Compare
1398bf1 to
2bac176
Compare
HimavarshaVS
left a comment
There was a problem hiding this comment.
Has it been tested for backwards compatibility?
Hi Himavarsha, this PR introduces breaking changes by design (e.g., dynamic outputs). I have coordinated with Rodrigo for this. Will send more info on Slack! |
e973093 to
e862bb0
Compare
|
Component Index merge conflict |
f0552e1 to
c80b784
Compare
8dc7e56 to
51f4635
Compare
|
@HzaRashid |
6e4bf36 to
c46eaec
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
83d1349 to
11d7cc3
Compare
|
merged via #10720 |
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.Summary by CodeRabbit
Release Notes
New Features
Tests