Refactor app.py and adapter.py for better maintainability #37

Closed
opened 2026-03-19 00:22:11 +00:00 by david · 3 comments
Owner

Problem

The app.py and adapter.py files are growing large and may benefit from refactoring or chunking into smaller, more maintainable modules.

Proposed Changes

  1. app.py: Split into smaller modules (e.g., app/main.py, app/cli.py, app/pipeline_runner.py)
  2. adapter.py: Review and potentially split adapter classes into separate files based on functionality

Benefits

  • Better code organization
  • Easier testing
  • Improved maintainability
  • Clearer separation of concerns

Acceptance Criteria

  • Analyze current structure of app.py and adapter.py
  • Propose modular structure
  • Create tickets for specific refactoring tasks
  • Ensure no functionality is lost during refactoring
## Problem The `app.py` and `adapter.py` files are growing large and may benefit from refactoring or chunking into smaller, more maintainable modules. ## Proposed Changes 1. **app.py**: Split into smaller modules (e.g., `app/main.py`, `app/cli.py`, `app/pipeline_runner.py`) 2. **adapter.py**: Review and potentially split adapter classes into separate files based on functionality ## Benefits - Better code organization - Easier testing - Improved maintainability - Clearer separation of concerns ## Acceptance Criteria - [ ] Analyze current structure of app.py and adapter.py - [ ] Propose modular structure - [ ] Create tickets for specific refactoring tasks - [ ] Ensure no functionality is lost during refactoring
Author
Owner

Current State Analysis (2026-03-18)

What Actually Exists

After analyzing the codebase:

  1. engine/app.py (14 lines) - Already a thin wrapper!

    from engine.app import main, run_pipeline_mode, run_pipeline_mode_direct
    
    • Re-exports from engine.app package
  2. engine/pipeline/adapters.py (50 lines) - Already deprecated wrapper!

    # DEPRECATED: This file is now a compatibility wrapper.
    from engine.pipeline.adapters import (...)
    
    • Re-exports from engine.pipeline.adapters package

Actual Package Structure

  • engine/app/main.py - Main entry point (420 lines)
  • engine/app/pipeline_runner.py - Pipeline execution (701 lines)
  • engine/pipeline/adapters/ - Package with actual adapters

Proposed Reorganization

Instead of "splitting" these files (they're already split!), the real task is:

  1. Audit all imports in the codebase:

    • Find files importing from engine.app wrapper
    • Find files importing from engine.pipeline.adapters wrapper
    • Update to use package imports directly
  2. Remove wrapper files:

    • Delete engine/app.py
    • Delete engine/pipeline/adapters.py
  3. Update entry points:

    • Fix __main__.py if needed
    • Update CLI scripts

Files to Audit

Search for imports like:

from engine.app import ...
from engine.pipeline.adapters import ...

Risk Assessment

  • Low risk - Just updating import paths
  • Backwards compatibility - Will need to update any external imports

Should we proceed with this plan?

## Current State Analysis (2026-03-18) ### What Actually Exists After analyzing the codebase: 1. **`engine/app.py`** (14 lines) - Already a thin wrapper! ```python from engine.app import main, run_pipeline_mode, run_pipeline_mode_direct ``` - Re-exports from `engine.app` package 2. **`engine/pipeline/adapters.py`** (50 lines) - Already deprecated wrapper! ```python # DEPRECATED: This file is now a compatibility wrapper. from engine.pipeline.adapters import (...) ``` - Re-exports from `engine.pipeline.adapters` package ### Actual Package Structure - `engine/app/main.py` - Main entry point (420 lines) - `engine/app/pipeline_runner.py` - Pipeline execution (701 lines) - `engine/pipeline/adapters/` - Package with actual adapters ### Proposed Reorganization Instead of "splitting" these files (they're already split!), the real task is: 1. **Audit all imports** in the codebase: - Find files importing from `engine.app` wrapper - Find files importing from `engine.pipeline.adapters` wrapper - Update to use package imports directly 2. **Remove wrapper files**: - Delete `engine/app.py` - Delete `engine/pipeline/adapters.py` 3. **Update entry points**: - Fix `__main__.py` if needed - Update CLI scripts ### Files to Audit Search for imports like: ```python from engine.app import ... from engine.pipeline.adapters import ... ``` ### Risk Assessment - **Low risk** - Just updating import paths - **Backwards compatibility** - Will need to update any external imports Should we proceed with this plan?
Author
Owner

Completed

The refactoring has been completed in commit c57617b:

  • engine/app.py is now a thin wrapper re-exporting from engine.app package
  • Created engine/app/__init__.py, engine/app/main.py, engine/app/pipeline_runner.py
  • engine/pipeline/adapters.py is now a deprecated wrapper
  • Created engine/pipeline/adapters/ package with modular adapters:
    • camera.py, data_source.py, display.py, effect_plugin.py, factory.py, transform.py

This issue is now resolved.

## Completed The refactoring has been completed in commit `c57617b`: - ✅ `engine/app.py` is now a thin wrapper re-exporting from `engine.app` package - ✅ Created `engine/app/__init__.py`, `engine/app/main.py`, `engine/app/pipeline_runner.py` - ✅ `engine/pipeline/adapters.py` is now a deprecated wrapper - ✅ Created `engine/pipeline/adapters/` package with modular adapters: - `camera.py`, `data_source.py`, `display.py`, `effect_plugin.py`, `factory.py`, `transform.py` This issue is now resolved.
david closed this issue 2026-03-19 10:35:18 +00:00
Author
Owner

Completed in commit c57617b:

  • Created engine/app/ package with main.py and pipeline_runner.py
  • Created engine/pipeline/adapters/ package with modular adapters
  • Updated engine/app.py to be a thin wrapper
  • Updated engine/pipeline/adapters.py to be a deprecated wrapper

The working directory changes further improve the app package with pipeline hot-rebuild functionality.

Completed in commit c57617b: - Created `engine/app/` package with `main.py` and `pipeline_runner.py` - Created `engine/pipeline/adapters/` package with modular adapters - Updated `engine/app.py` to be a thin wrapper - Updated `engine/pipeline/adapters.py` to be a deprecated wrapper The working directory changes further improve the app package with pipeline hot-rebuild functionality.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: klubhaus/sideline#37