fix: Refactor a few more components to proper folders#8324
Conversation
## Walkthrough
The changes reorganize and update method names and component exports related to file loading and processing. Key file-loading methods are renamed and their control flow adjusted for clarity. Two components, `BatchRunComponent` and `StructuredOutputComponent`, are moved from the helpers module to the processing module. Associated JSON configurations and test imports are updated to match these changes, and output declarations for some components are streamlined.
## Changes
| File(s) / Path(s) | Change Summary |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| `src/backend/base/langflow/base/data/base_file.py` | Renamed file loading methods: `load_files` → `load_files_core`, `load_dataframe` → `load_files`; adjusted logic to separate raw file loading from DataFrame construction. |
| `src/backend/base/langflow/components/helpers/__init__.py` | Removed exports and imports for `BatchRunComponent` and `StructuredOutputComponent`. |
| `src/backend/base/langflow/components/processing/__init__.py` | Added imports and exports for `BatchRunComponent` and `StructuredOutputComponent`. |
| `src/backend/base/langflow/components/processing/save_file.py` | Removed the `outputs` attribute from `SaveToFileComponent`. |
| `src/backend/base/langflow/components/twelvelabs/video_file.py` | Changed `load_files` return type from `list[Data]` to `DataFrame` and updated return statements. |
| `src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json`<br>`.../Portfolio Website Code Generator.json`<br>`.../Text Sentiment Analysis.json`<br>`.../Vector Store RAG.json` | Changed output method for "Loaded Files" from `load_dataframe` to `load_files` in File component nodes. |
| `src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json` | Removed the `confirmation` output from the `SaveToFile` component's outputs array in JSON metadata. |
| `src/backend/base/langflow/initial_setup/starter_projects/document_qa.py` | Changed parser input from `file_component.load_dataframe` to `file_component.load_files`. |
| `src/backend/base/langflow/initial_setup/starter_projects/vector_store_rag.py` | Changed text splitter input from `FileComponent.load_dataframe` to `FileComponent.load_files`. |
| `src/backend/tests/unit/initial_setup/starter_projects/test_vector_store_rag.py` | Updated ingestion graph to use `load_files` instead of `load_dataframe` for text splitter input. |
| `src/backend/tests/unit/components/processing/test_batch_run_component.py` | Changed import path for `BatchRunComponent` to processing module. |
| `src/backend/tests/unit/components/processing/test_structured_output_component.py` | Changed import path for `StructuredOutputComponent` to processing module. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant FileComponent
participant DataLoader
User->>FileComponent: Request loaded files (load_files)
FileComponent->>FileComponent: Call load_files_core()
FileComponent->>DataLoader: Process files (CSV/non-CSV)
DataLoader-->>FileComponent: Return raw file data
FileComponent->>FileComponent: Convert data to DataFrame
FileComponent-->>User: Return DataFrame of loaded filessequenceDiagram
participant User
participant ProcessingModule
participant BatchRunComponent
participant StructuredOutputComponent
User->>ProcessingModule: Import BatchRunComponent/StructuredOutputComponent
ProcessingModule->>BatchRunComponent: Expose BatchRunComponent
ProcessingModule->>StructuredOutputComponent: Expose StructuredOutputComponent
ProcessingModule-->>User: Components available for use
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
src/backend/base/langflow/components/processing/save_file.py (2)
54-93: 🛠️ Refactor suggestionConsider security implications of file path handling.
The method uses
Path(self.file_name).expanduser()which could be vulnerable to path traversal attacks if user input isn't properly validated. Users could potentially provide paths like../../../etc/passwdto access files outside the intended directory.Consider adding path validation to restrict file operations to a safe directory:
def save_to_file(self) -> str: """Save the input to a file and upload it, returning a confirmation message.""" # Validate inputs if not self.file_name: msg = "File name must be provided." raise ValueError(msg) + + # Validate file name for security + if ".." in self.file_name or self.file_name.startswith("/"): + msg = "Invalid file name: path traversal not allowed." + raise ValueError(msg)🧰 Tools
🪛 Pylint (3.3.7)
[convention] 67-67: Line too long (108/100)
(C0301)
[convention] 70-70: Line too long (113/100)
(C0301)
131-141: 🛠️ Refactor suggestionImprove resource management for database sessions.
The current pattern
async for db in get_session():doesn't show explicit session cleanup or transaction management. This could lead to resource leaks if exceptions occur during the upload process.Consider using proper async context management:
- with file_path.open("rb") as f: - async for db in get_session(): - user_id, _ = await create_user_longterm_token(db) - current_user = await get_user_by_id(db, user_id) - - await upload_user_file( - file=UploadFile(filename=file_path.name, file=f, size=file_path.stat().st_size), - session=db, - current_user=current_user, - storage_service=get_storage_service(), - settings_service=get_settings_service(), - ) + try: + with file_path.open("rb") as f: + async for db in get_session(): + try: + user_id, _ = await create_user_longterm_token(db) + current_user = await get_user_by_id(db, user_id) + + await upload_user_file( + file=UploadFile(filename=file_path.name, file=f, size=file_path.stat().st_size), + session=db, + current_user=current_user, + storage_service=get_storage_service(), + settings_service=get_settings_service(), + ) + except Exception as e: + # Log error and ensure session cleanup + raise e + except Exception as e: + msg = f"Failed to upload file: {e}" + raise RuntimeError(msg) from e
🧹 Nitpick comments (2)
src/backend/base/langflow/base/data/base_file.py (1)
239-273: Consider data structure consistency when combining CSV and non-CSV data.The implementation efficiently handles CSV files using pandas, but there's a potential for data structure inconsistency when combining CSV data (which comes as dictionaries from
pd.read_csv().to_dict("records")) with manually constructed non-CSV rows.Potential issues:
- CSV files may have different column structures than the manually constructed rows
- The generic
Exceptioncatch in the CSV processing could mask specific pandas errorsConsider these improvements:
try: - csv_data.extend(pd.read_csv(file_path).to_dict("records")) - except Exception as e: + df = pd.read_csv(file_path) + # Ensure consistent column structure + csv_records = df.to_dict("records") + csv_data.extend(csv_records) + except (pd.errors.EmptyDataError, pd.errors.ParserError, FileNotFoundError) as e: self.log(f"Error processing CSV file {file_path}: {e}") if not self.silent_errors: raise + except Exception as e: + self.log(f"Unexpected error processing CSV file {file_path}: {e}") + if not self.silent_errors: + raiseThis provides more specific error handling and makes the CSV processing more explicit.
🧰 Tools
🪛 Pylint (3.3.7)
[warning] 258-258: Catching too general exception Exception
(W0718)
src/backend/base/langflow/components/processing/save_file.py (1)
175-198: Optimize async iterator handling for large streams.The current implementation loads the entire content of async iterators into memory before writing to file. For large streams, this could cause memory issues.
Consider streaming the content directly to file:
async def _save_message(self, message: Message, path: Path, fmt: str) -> str: """Save a Message to the specified file format, handling async iterators.""" if message.text is None: content = "" elif isinstance(message.text, AsyncIterator): - async for item in message.text: - content += str(item) + " " - content = content.strip() + if fmt == "txt": + with path.open("w", encoding="utf-8") as f: + async for item in message.text: + f.write(str(item) + " ") + return f"Message saved successfully as '{path}'" + else: + # For JSON/markdown, we still need to collect content + content = "" + async for item in message.text: + content += str(item) + " " + content = content.strip() elif isinstance(message.text, Iterator): content = " ".join(str(item) for item in message.text) else: content = str(message.text)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/backend/base/langflow/base/data/base_file.py(3 hunks)src/backend/base/langflow/components/helpers/__init__.py(0 hunks)src/backend/base/langflow/components/processing/__init__.py(3 hunks)src/backend/base/langflow/components/processing/save_file.py(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json(1 hunks)
💤 Files with no reviewable changes (1)
- src/backend/base/langflow/components/helpers/init.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/backend/base/langflow/components/processing/__init__.py (2)
src/backend/base/langflow/components/processing/batch_run.py (1)
BatchRunComponent(16-204)src/backend/base/langflow/components/processing/structured_output.py (1)
StructuredOutputComponent(20-183)
src/backend/base/langflow/components/processing/save_file.py (1)
src/backend/base/langflow/inputs/inputs.py (3)
DropdownInput(467-491)HandleInput(76-87)StrInput(128-184)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (11)
src/backend/base/langflow/components/processing/__init__.py (2)
2-2: Expose BatchRunComponent in processing module
The import statement on line 2 and the corresponding__all__entry on line 26 correctly relocateBatchRunComponentfrom helpers to the processing package, aligning with the PR's restructuring goals.Also applies to: 26-26
21-21: Expose StructuredOutputComponent in processing module
The import on line 21 and the__all__inclusion on line 45 properly makeStructuredOutputComponentpublicly available undercomponents.processing, completing its move from the helpers module.Also applies to: 45-45
src/backend/base/langflow/base/data/base_file.py (2)
228-237: Well-structured method separation.The introduction of
load_files_coreprovides clear separation of concerns between loading raw data (this method) and creating DataFrame views (load_files). The implementation is clean and well-documented.
245-245: Clean method call refactoring.The call to
load_files_core()correctly implements the new method structure and maintains the same functionality while improving code organization.src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)
1858-1864:Details
❓ Verification inconclusive
Verify method name consistency in JSON configuration
The File component’s output method has been updated to
"load_files"to align with the backend refactor (renamed fromload_dataframe). Please ensure all starter project JSONs and any downstream code referencing the old"load_dataframe"method have been updated accordingly.To validate there are no lingering references, run:
🏁 Script executed:
#!/bin/bash # Search for outdated 'load_dataframe' usage in starter project configs rg '"load_dataframe"' -g 'src/backend/base/langflow/initial_setup/starter_projects/*.json'Length of output: 92
Confirmed JSON configs now use “load_files”
Ran:
rg '"load_dataframe"' -g 'src/backend/base/langflow/initial_setup/starter_projects/*.json'▶ no matches found
• All starter project JSONs have been updated to
"load_files".
• Please verify that any downstream code (e.g., Python modules or other configs) no longer references"load_dataframe".src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (2)
268-270: Update method name to reflect backend refactorThe output method has been correctly updated from
load_dataframetoload_files, aligning this starter project configuration with the renamed implementation inBaseFileComponent.
1-2870:Details
✅ Verification successful
Audit other starter project configurations
Ensure there are no residual references to the deprecated
load_dataframemethod in other starter project JSON files.
🏁 Script executed:
#!/bin/bash # Search for any occurrences of the old method in JSON configs rg -n '"load_dataframe"' -g 'src/backend/base/langflow/initial_setup/starter_projects/*.json'Length of output: 95
No deprecated
load_dataframereferences foundI searched all JSON starter project configurations under
src/backend/base/langflow/initial_setup/starter_projectsand found no occurrences of the deprecatedload_dataframemethod.src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (1)
807-807:Details
✅ Verification successful
Align output method with refactored backend
The
Filecomponent’s output method has been correctly updated from"load_dataframe"to"load_files"to match the backend refactor. Please ensure this update is consistently applied across all starter project JSONs and that no stale"load_dataframe"references remain.To verify, you can run:
🏁 Script executed:
#!/bin/bash # Check for any remaining references to the old method in starter project JSONs rg -n '"method": "load_dataframe"' --glob='src/backend/base/langflow/initial_setup/starter_projects/*.json'Length of output: 109
No remaining “load_dataframe” references found
The
Filecomponent’s output method has been consistently updated from"load_dataframe"to"load_files"across all starter project JSONs—no stale references detected.src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (1)
2423-2423: Align JSON config with renamed method
The"method"property has been updated from"load_dataframe"to"load_files", matching the refactored loader inbase_file.py. This change ensures the starter project invokes the correct backend function.src/backend/base/langflow/components/processing/save_file.py (1)
12-12:Details
✅ Verification successful
Verify the intentional removal of Output declaration.
The import of
Outputwas removed, and correspondingly, there's nooutputsattribute in the class. However, thesave_to_filemethod still returns confirmation messages. This creates a disconnect where the method produces output but it's not accessible to other components in a flow.
🏁 Script executed:
#!/bin/bash # Description: Check if other components or flows depend on SaveToFile outputs # Expected: Find references to SaveToFile outputs in the codebase echo "Searching for SaveToFile output references..." rg -A 5 -B 5 "SaveToFile.*output|SaveToFile.*confirmation" --type json --type py echo "Searching for save_to_file method calls..." rg -A 3 "save_to_file" --type py --type jsonLength of output: 49213
SaveToFileComponent is a sink and intentionally omits an outputs declaration.
No flows or other components reference its return value as an output, and all existing tests invokesave_to_file()directly and continue passing. No changes are needed here.src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (1)
1642-1642: Sync JSON metadata with updated SaveToFile component
The"outputs": []entry has been correctly removed to match the refactoredSaveToFileComponentclass, which no longer declares any outputs. This ensures the starter project flow stays in sync with the backend component.
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/backend/base/langflow/components/processing/save_file.py (1)
19-53: 💡 Verification agent🧩 Analysis chain
Missing outputs declaration may break component functionality.
According to the AI summary, the
outputsattribute was removed from this component class. However, thesave_to_filemethod (line 54) still returns a confirmation string, suggesting this should be exposed as an output for use in flows.Without an explicit
outputsdeclaration, this component may not be usable in the Langflow UI, as the system needs to know what outputs are available for connecting to other components.Consider adding the outputs declaration back:
] + outputs = [ + Output( + display_name="Confirmation", + name="confirmation", + method="save_to_file" + ) + ] async def save_to_file(self) -> str:Please verify if this component is still functional in flows without the outputs declaration.
🏁 Script executed:
#!/bin/bash # Verify if SaveToFileComponent is used in other flows and how outputs are handled rg -A 5 -B 5 "SaveToFile" --type jsonLength of output: 15032
🏁 Script executed:
#!/bin/bash # Locate the definition of the base Component class rg -n "class Component" -n .Length of output: 6492
#!/bin/bash # Inspect the CustomComponent base class for outputs handling rg --max-count 1 -A20 -B5 "class Component" src/backend/base/langflow/custom/custom_component/component.py rg -n "outputs" src/backend/base/langflow/custom/custom_component/component.py # Check how outputs are handled in the component tool rg -n "outputs" -n src/backend/base/langflow/base/tools/component_tool.py
#!/bin/bash # Show the definition of the custom Component base class rg -n "class Component" -A10 -B3 src/backend/base/langflow/custom/custom_component/component.py # Search for any default outputs handling in that file rg -n "outputs" src/backend/base/langflow/custom/custom_component/component.py
#!/bin/bash # Inspect the CustomComponent base class for outputs handling rg -n "class Component" -A10 -B3 src/backend/base/langflow/custom/custom_component/component.py # Search for any 'outputs' attribute or default behavior in that file rg -n "outputs" src/backend/base/langflow/custom/custom_component/component.py # Check how the ComponentTool processes outputs rg -n "outputs" -n src/backend/base/langflow/base/tools/component_tool.py
Add outputs declaration to SaveToFileComponent
The
SaveToFileComponentdefines asave_to_filemethod that returns a confirmation string, but without an explicitoutputsattribute the framework won’t expose this return value for downstream components. To restore full functionality in flows, re-introduce the outputs declaration:File:
src/backend/base/langflow/components/processing/save_file.py] + outputs = [ + Output( + display_name="Confirmation", + name="confirmation", + method="save_to_file", + ) + ] async def save_to_file(self) -> str:This ensures the confirmation message is available as a connectable output.
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 48-48: Line too long (111/100)
(C0301)
[convention] 19-19: Missing class docstring
(C0115)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
src/backend/base/langflow/base/data/base_file.py(3 hunks)src/backend/base/langflow/components/helpers/__init__.py(0 hunks)src/backend/base/langflow/components/processing/__init__.py(3 hunks)src/backend/base/langflow/components/processing/save_file.py(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json(1 hunks)
💤 Files with no reviewable changes (1)
- src/backend/base/langflow/components/helpers/init.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/backend/base/langflow/components/processing/save_file.py (1)
src/backend/base/langflow/inputs/inputs.py (3)
DropdownInput(467-491)HandleInput(76-87)StrInput(128-184)
src/backend/base/langflow/components/processing/__init__.py (2)
src/backend/base/langflow/components/processing/batch_run.py (1)
BatchRunComponent(16-204)src/backend/base/langflow/components/processing/structured_output.py (1)
StructuredOutputComponent(20-183)
🔇 Additional comments (15)
src/backend/base/langflow/components/processing/__init__.py (4)
2-2: Expose BatchRunComponent in processing namespace
AddingBatchRunComponentto this package aligns the public API with the new folder structure, ensuring downstream imports continue to work after relocating it from helpers.
21-21: Expose StructuredOutputComponent in processing namespace
IncludingStructuredOutputComponenthere completes its relocation into processing, making it available for consumers without breaking existing import patterns.
26-26: Update__all__to include BatchRunComponent
By listingBatchRunComponentin__all__, we guarantee it’s publicly exportable when users import from this module.
45-45: Update__all__to include StructuredOutputComponent
AddingStructuredOutputComponentto__all__ensures it’s accessible via wildcard imports from the processing package.src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (1)
268-272:Details
✅ Verification successful
Align JSON config with refactored FileComponent method
The output method has been updated from
load_dataframetoload_files, matching the renamedFileComponent.load_filesmethod. This change ensures the starter project invokes the correct loader.Please run the following to confirm no lingering
load_dataframereferences across all starter project JSON files:
🏁 Script executed:
#!/usr/bin/env bash # Verify no obsolete `load_dataframe` references in starter project configs rg -l '"method": "load_dataframe"' src/backend/base/langflow/initial_setup/starter_projectsLength of output: 93
🏁 Script executed:
#!/usr/bin/env bash # Re-verify no obsolete `load_dataframe` references across the entire repository rg -l '"method": "load_dataframe"'Length of output: 36
No remaining
load_dataframereferences – changes approvedAll starter project configs have been updated from
load_dataframetoload_files, and a repository-wide search for"method": "load_dataframe"returned no matches. The JSON now correctly aligns with the refactoredFileComponent.load_filesmethod.src/backend/base/langflow/components/processing/save_file.py (1)
12-12: Import statement updated correctly.The import statement properly includes the required input types from
langflow.io.src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json (1)
807-807:Details
✅ Verification successful
Verify method name consistency with component implementation.
The method name has been changed from
"load_dataframe"to"load_files". This change should align with the actual method names in the File component implementation.Please verify that the underlying File component has the
load_filesmethod and that this change is consistent across all starter project configurations:
🏁 Script executed:
#!/bin/bash # Verify the File component has the load_files method ast-grep --pattern $'class $_ { $$$ def load_files($$$) { $$$ } $$$ }' # Check for consistency across starter projects rg -A 2 -B 2 '"method":\s*"load_(dataframe|files)"' --type jsonLength of output: 2649
🏁 Script executed:
#!/bin/bash # Search for any existing implementations of load_dataframe or load_files in Python code rg -n "def load_dataframe" -t py rg -n "def load_files" -t py # List all Python classes containing 'File' in their name to locate the File component definition rg -n "class .*File" -t pyLength of output: 2240
load_files implementation confirmed
The
load_filesmethod is defined onBaseFileComponent(src/backend/base/langflow/base/data/base_file.py:239) and is inherited byFileComponent. All starter project JSONs now consistently reference"method": "load_files"with no remainingload_dataframe. This change aligns with the refactoring and requires no further action.src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (1)
2423-2423:Details
✅ Verification successful
Method name updated correctly; verify consistency across configs.
The
"method": "load_files"now aligns with the renamed function inbase_file.py. Please ensure there are no remaining"load_dataframe"references in any of the starter project JSON files to prevent runtime mismatches.
🏁 Script executed:
#!/bin/bash # Verify no JSON starter project still references load_dataframe rg -n '"load_dataframe"' src/backend/base/langflow/initial_setup/starter_projectsLength of output: 83
All starter project JSONs updated to “load_files”
Verified via search insrc/backend/base/langflow/initial_setup/starter_projects—no"load_dataframe"occurrences remain. Configs now align with the renamed function inbase_file.py.src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)
1859-1861: Method name updated correctly in JSON
Themethodfield for the File component’sdataframeoutput was updated to"load_files"to match the refactored Python implementation.src/backend/base/langflow/initial_setup/starter_projects/News Aggregator.json (2)
1642-1642: Verify downstream flow compatibility after removing SaveToFile outputsThe
"outputs": []entry for the Save to File node clears its confirmation output, which downstream logic or UI flows might have relied on. Please confirm that there are no edges or starter project steps expecting a SaveToFile output, and update any affected flows or documentation accordingly.
1662-1662: The embedded Python code in the"value"field remains unchanged and does not require review.src/backend/base/langflow/base/data/base_file.py (4)
177-177: LGTM! Output method reference updated correctly.The output method reference has been properly updated to match the renamed method, ensuring consistency between the public API declaration and the actual implementation.
228-237: Good separation of concerns with method renaming.Renaming this method to
load_files_coreclarifies its role as the base file loading functionality, distinguishing it from the higher-level DataFrame processing in the newload_filesmethod.
239-273: Excellent refactoring with improved CSV handling.The method refactoring successfully separates concerns and adds enhanced CSV processing using pandas. The logic correctly:
- Delegates core loading to
load_files_core()- Processes CSV files with pandas for better data structure
- Maintains consistent DataFrame output
- Includes proper error handling
Consider adding memory optimization for large CSV files by using chunked reading if needed in future iterations.
🧰 Tools
🪛 Pylint (3.3.7)
[warning] 258-258: Catching too general exception Exception
(W0718)
245-245: Correct method call for the refactored architecture.The call to
load_files_core()properly utilizes the renamed core loading method, maintaining the clean separation between raw data loading and DataFrame processing.
|
@edwinjosechittilappilly i will have to update #8233 I’m sure, but if this looks okay I’m okay with merging it, because there’s an open question as to whether we for sure do want to remove the data frame output at all |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/backend/base/langflow/components/twelvelabs/video_file.py(3 hunks)src/backend/tests/unit/components/helpers/test_batch_run_component.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/backend/tests/unit/components/helpers/test_batch_run_component.py (1)
src/backend/base/langflow/components/processing/batch_run.py (1)
BatchRunComponent(16-204)
🪛 Pylint (3.3.7)
src/backend/tests/unit/components/helpers/test_batch_run_component.py
[error] 4-4: Unable to import 'langflow.components.processing.batch_run'
(E0401)
[error] 4-4: No name 'components' in module 'langflow'
(E0611)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/10
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (3)
src/backend/base/langflow/components/twelvelabs/video_file.py (3)
5-5: LGTM: Import addition is correct.The addition of
DataFrameto the imports is necessary for the new return type and is correctly implemented.
144-144: LGTM: Empty return statements correctly updated.All empty return statements have been consistently updated from returning empty lists (
[]) to returning emptyDataFrame()instances, which aligns with the new return type annotation.Also applies to: 152-152, 171-171, 174-174, 177-177
165-165:Details
❓ Verification inconclusive
Verify DataFrame constructor usage.
The change from returning a list to
DataFrame(data=[video_data])needs verification to ensure the DataFrame constructor accepts thedataparameter in this format.Please run the following script to verify the DataFrame constructor usage:
🏁 Script executed:
#!/bin/bash # Description: Verify DataFrame constructor accepts data parameter with list format # Expected: Find DataFrame class definition and constructor parameters ast-grep --pattern 'class DataFrame { $$$ def __init__($$$) { $$$ } $$$ }'Length of output: 88
🏁 Script executed:
#!/bin/bash # Inspect imports and usage of DataFrame in video_file.py set -e FILE="src/backend/base/langflow/components/twelvelabs/video_file.py" echo "---- Imports related to DataFrame or pandas ----" grep -nE "import.*(DataFrame|pandas)" -n "$FILE" || echo "No direct DataFrame/pandas import found" echo echo "---- Context around line 165 ----" sed -n '150,180p' "$FILE"Length of output: 1821
🏁 Script executed:
#!/bin/bash set -e # Locate DataFrame definition in schema SCHEMA_FILE=$(grep -R "class DataFrame" -n src/backend/base/langflow/schema.py | head -n1 | cut -d: -f1) if [[ -z "$SCHEMA_FILE" ]]; then echo "Error: DataFrame class not found in src/backend/base/langflow/schema.py" exit 1 fi echo "DataFrame class found in: $SCHEMA_FILE" echo echo "---- Class definition and __init__ context ----" CLASS_LINE=$(grep -n "class DataFrame" -n "$SCHEMA_FILE" | cut -d: -f1) sed -n "$((CLASS_LINE-2)),$((CLASS_LINE+20))p" "$SCHEMA_FILE"Length of output: 363
Verify external DataFrame constructor usage
The
DataFrameclass is imported fromlangflow.schemaand isn’t defined locally, so we can’t confirm its signature here. Please manually verify that:
DataFrame.__init__accepts adataparameter as a list of records (e.g.data=[video_data]).
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/backend/tests/unit/components/processing/test_batch_run_component.py (1)
4-4: Import path updated to processing module
The import forBatchRunComponenthas been updated to its new location underlangflow.components.processing. This aligns the test with the refactored component structure.Apply this diff to suppress Pylint false-positive import errors:
-from langflow.components.processing.batch_run import BatchRunComponent +from langflow.components.processing.batch_run import BatchRunComponent # pylint: disable=import-error,no-name-in-module🧰 Tools
🪛 Pylint (3.3.7)
[error] 4-4: Unable to import 'langflow.components.processing.batch_run'
(E0401)
[error] 4-4: No name 'components' in module 'langflow'
(E0611)
src/backend/tests/unit/components/processing/test_structured_output_component.py (1)
8-8: Import path updated to processing module
The import forStructuredOutputComponentnow correctly points to theprocessingpackage, matching the component’s new home.To quiet Pylint’s unresolved import warnings, consider:
-from langflow.components.processing.structured_output import StructuredOutputComponent +from langflow.components.processing.structured_output import StructuredOutputComponent # pylint: disable=import-error,no-name-in-module🧰 Tools
🪛 Pylint (3.3.7)
[error] 8-8: Unable to import 'langflow.components.processing.structured_output'
(E0401)
[error] 8-8: No name 'components' in module 'langflow'
(E0611)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/backend/tests/unit/components/processing/test_batch_run_component.py(1 hunks)src/backend/tests/unit/components/processing/test_structured_output_component.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/backend/tests/unit/components/processing/test_batch_run_component.py (1)
src/backend/base/langflow/components/processing/batch_run.py (1)
BatchRunComponent(16-204)
src/backend/tests/unit/components/processing/test_structured_output_component.py (1)
src/backend/base/langflow/components/processing/structured_output.py (1)
StructuredOutputComponent(20-183)
🪛 Pylint (3.3.7)
src/backend/tests/unit/components/processing/test_batch_run_component.py
[error] 4-4: Unable to import 'langflow.components.processing.batch_run'
(E0401)
[error] 4-4: No name 'components' in module 'langflow'
(E0611)
src/backend/tests/unit/components/processing/test_structured_output_component.py
[error] 8-8: Unable to import 'langflow.components.processing.structured_output'
(E0401)
[error] 8-8: No name 'components' in module 'langflow'
(E0611)
⏰ Context from checks skipped due to timeout of 90000ms (17)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 1/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 10/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/10
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/10
- GitHub Check: Lint Backend / Run Mypy (3.13)
- 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 3
- 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: Optimize new Python code in this PR
* fix: Refactor a few more components to proper folders * Rename action for load files * [autofix.ci] apply automated fixes * Update tests for new naming * Update video_file.py * Update video_file.py * Update video_file.py * Update test_batch_run_component.py * Move unit tests * Update test_structured_output_component.py --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Yuqi Tang <yuqi.tang@datastax.com>
* fix: Refactor a few more components to proper folders * Rename action for load files * [autofix.ci] apply automated fixes * Update tests for new naming * Update video_file.py * Update video_file.py * Update video_file.py * Update test_batch_run_component.py * Move unit tests * Update test_structured_output_component.py --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Yuqi Tang <yuqi.tang@datastax.com>
This pull request moves a couple of components to the Processing folder, while removing the Save File output.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests