Skip to content

refactor: Replace aiofile with aiofiles for async file operations#11351

Merged
Cristhianzl merged 4 commits into
mainfrom
fix/iosync-file
Jan 19, 2026
Merged

refactor: Replace aiofile with aiofiles for async file operations#11351
Cristhianzl merged 4 commits into
mainfrom
fix/iosync-file

Conversation

@Cristhianzl
Copy link
Copy Markdown
Member

@Cristhianzl Cristhianzl commented Jan 19, 2026

This pull request updates the local storage service to use the aiofiles library instead of aiofile for asynchronous file operations. The change ensures consistency and compatibility with other parts of the codebase that may use aiofiles.

Dependency update:

  • Replaced the import of async_open from aiofile with aiofiles in src/lfx/src/lfx/services/storage/local.py, and updated all asynchronous file open calls to use aiofiles.open instead of async_open. [1] [2] [3]

Summary by CodeRabbit

  • Chores
    • Updated internal file storage implementation to enhance system stability and maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@Cristhianzl Cristhianzl self-assigned this Jan 19, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request replaces the aiofile.async_open dependency with aiofiles.open throughout the LocalStorageService. The import statement is updated and all file I/O operations are migrated to use the new library, with no changes to control flow or error handling logic.

Changes

Cohort / File(s) Summary
Async file I/O library migration
src/lfx/src/lfx/services/storage/local.py
Swapped aiofile.async_open for aiofiles.open; updated import from from aiofile import async_open to import aiofiles; replaced all file I/O operations (read/write) to use new library

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR refactors aiofile to aiofiles library swap with no new or updated test files included to verify the integration. Add or update test files to verify aiofiles library integration works correctly and document test results in the PR.
Test Quality And Coverage ⚠️ Warning The pull request updates core async file-IO operations in LocalStorageService but includes no corresponding tests to validate the new aiofiles behavior. Add pytest-based async tests for LocalStorageService's write, append, and read methods covering normal and failure cases.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: replacing the aiofile library with aiofiles for async file operations throughout the LocalStorageService.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Test File Naming And Structure ✅ Passed The PR modifies only configuration, documentation, and repository files without including any test files, making test naming and structural requirements non-applicable.
Excessive Mock Usage Warning ✅ Passed Test files demonstrate excellent design with minimal mock usage focused only on dependency injection, real file I/O operations, and actual behavior verification rather than mocked behavior.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/iosync-file

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jan 19, 2026
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jan 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 17%
17.49% (4997/28556) 10.83% (2388/22036) 11.59% (724/6244)

Unit Test Results

Tests Skipped Failures Errors Time
1998 0 💤 0 ❌ 0 🔥 27.538s ⏱️

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 33.94%. Comparing base (c7afb50) to head (8e57f31).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11351      +/-   ##
==========================================
- Coverage   34.22%   33.94%   -0.28%     
==========================================
  Files        1409     1414       +5     
  Lines       66920    67196     +276     
  Branches     9877     9910      +33     
==========================================
- Hits        22902    22809      -93     
- Misses      42817    43171     +354     
- Partials     1201     1216      +15     
Flag Coverage Δ
backend 51.31% <ø> (-2.16%) ⬇️
frontend 16.03% <ø> (ø)
lfx 41.60% <100.00%> (+0.79%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/lfx/src/lfx/services/storage/local.py 63.09% <100.00%> (+44.57%) ⬆️

... and 59 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels Jan 19, 2026
@Cristhianzl Cristhianzl merged commit ac27392 into main Jan 19, 2026
3 checks passed
@Cristhianzl Cristhianzl deleted the fix/iosync-file branch January 19, 2026 12:29
ogabrielluiz pushed a commit that referenced this pull request Jan 19, 2026
…1351)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jan 21, 2026
* fix: Remove redundant dependencies from pyproject.toml

* feat: Refactor optional dependencies in pyproject.toml for improved organization and clarity

* feat: Update optional dependencies in pyproject.toml for enhanced functionality and organization

* feat: Consolidate dependencies in pyproject.toml for better management

* feat: Expand complete installation dependencies in pyproject.toml for comprehensive support

* new lock

* feat: Update package versions and refactor complete installation dependencies in pyproject.toml

* update lock

* feat: Update dependencies in pyproject.toml to use 'local' installation and restructure complete installation groups

* feat: Add langchain_elasticsearch dependency to elasticsearch in pyproject.toml

* feat: Add types-cachetools dependency and update version constraints for existing packages in pyproject.toml

* feat: Update pyproject.toml to change langflow-base dependency from 'local' to 'complete' installation and remove dev extra

* Update pyproject.toml to modify dependencies and improve installation structure

* refactor: Remove 'deploy' and 'dev' extras from complete installation in pyproject.toml

* add missing deps

* fix: update langchain-chroma dependency version to 0.2.6

* Remove clickhouse and pypdf from main deps

* move clickhouse

* add lock

* update lockfile

* Add utility function to convert pandas/numpy scalars to int

* Update component index

* Update component index

* fix: update no_leaks decorator to include threads for test isolation

* fix: refine model_is_empty condition for better clarity

* feat: Add pluggable services architecture in lfx and comprehensive testing (#10111)

* feat: Introduce service registration decorator and enhance ServiceManager for pluggable service discovery

- Added `register_service` decorator to allow services to self-register with the ServiceManager.
- Enhanced `ServiceManager` to support multiple service discovery mechanisms, including decorator-based registration, config files, and entry points.
- Implemented methods for direct service class registration and plugin discovery from various sources, improving flexibility and extensibility of service management.

* feat: Implement VariableService for managing environment variables

- Introduced VariableService class to handle environment variables with in-memory caching.
- Added methods for getting, setting, deleting, and listing variables.
- Included logging for service initialization and variable operations.
- Created an __init__.py file to expose VariableService in the package namespace.

* feat: Enhance LocalStorageService with Service integration and async teardown

- Updated LocalStorageService to inherit from both StorageService and Service for improved functionality.
- Added a name attribute for service identification.
- Implemented an async teardown method for future extensibility, even though no cleanup is currently needed.
- Refactored the constructor to ensure proper initialization of both parent classes.

* feat: Implement telemetry service with abstract base class and minimal logging functionality

- Added `BaseTelemetryService` as an abstract base class defining the interface for telemetry services.
- Introduced `TelemetryService`, a lightweight implementation that logs telemetry events without sending data.
- Created `__init__.py` to expose the telemetry service in the package namespace.
- Ensured robust async methods for logging various telemetry events and handling exceptions.

* feat: Introduce BaseTracingService and implement minimal TracingService

- Added `BaseTracingService` as an abstract base class defining the interface for tracing services.
- Implemented `TracingService`, a lightweight version that logs trace events without external integrations.
- Included async methods for starting and ending traces, tracing components, and managing logs and outputs.
- Enhanced documentation for clarity on method usage and parameters.

* feat: Add unit tests for service registration decorators

- Introduced a new test suite for validating the functionality of the @register_service decorator.
- Implemented tests for various service types including LocalStorageService, TelemetryService, and TracingService.
- Verified behavior for service registration with and without overrides, ensuring correct service management.
- Included tests for custom service implementations and preservation of class functionality.
- Enhanced overall test coverage for the service registration mechanism.

* feat: Add comprehensive unit and integration tests for ServiceManager

- Introduced a suite of unit tests covering edge cases for service registration, lifecycle management, and dependency resolution.
- Implemented integration tests to validate service loading from configuration files and environment variables.
- Enhanced test coverage for various service types including LocalStorageService, TelemetryService, and VariableService.
- Verified behavior for service registration with and without overrides, ensuring correct service management.
- Ensured robust handling of error conditions and edge cases in service creation and configuration parsing.

* feat: Add unit and integration tests for minimal service implementations

- Introduced comprehensive unit tests for LocalStorageService, TelemetryService, TracingService, and VariableService.
- Implemented integration tests to validate the interaction between minimal services.
- Ensured robust coverage for file operations, service readiness, and exception handling.
- Enhanced documentation within tests for clarity on functionality and expected behavior.

* docs: Add detailed documentation for pluggable services architecture and usage

* feat: Add example configuration file for Langflow services

* docs: Update PLUGGABLE_SERVICES.md to enhance architecture benefits section

- Revised the documentation to highlight the advantages of the pluggable service system.
- Replaced the migration guide with a detailed overview of features such as automatic discovery, lazy instantiation, dependency injection, and lifecycle management.
- Clarified examples of service registration and improved overall documentation for better understanding.

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* test(services): improve variable service teardown test with public API assertions

* docs(pluggable-service-layer): add docstrings for service manager and implementations

* Update component index

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* test: Standardize service mocking with shared pytest fixtures for reliable test isolation (#11350)

* refactor: Replace aiofile with aiofiles for async file operations (#11351)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: update dependencies for backwards compatibility

* update index

* [autofix.ci] apply automated fixes

* fix: update duckduckgo dependency to duckduckgo-search and remove obsolete entries

* fix: update version check to reflect lfx instead of langflow

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* feat: Add dynamic options to various starter project configurations

* [autofix.ci] apply automated fixes

* fix: Update dependencies for langchain and langchain-community to latest compatible versions

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Maintenance tasks and housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant