Skip to content

Refactor: Make pipeline use ModelFactory instead of ModelBuilder #17

Description

@nikolaitennant

Problem

The pipeline has two parallel model creation paths:

  1. ModelFactory (model_factory.py, 727 lines) — Clean factory pattern with BaseModel, CNNModel, MLPModel, etc. Has register_model() and list_models() for extensibility. Not used by the pipeline — only used in tests.

  2. ModelBuilder (model.py, 1,434 lines) — Legacy class with create_cnn_model(), create_mlp_model(), etc. that duplicate the factory's model definitions. This is what the pipeline actually calls via ModelManager.

Fix

  • Make ModelBuilder.build_model() delegate to ModelFactory.create_model() instead of its own create_* methods
  • Delete the duplicate create_cnn_model(), create_mlp_model(), create_logistic_regression(), create_random_forest(), create_xgboost_model() from ModelBuilder
  • Keep ModelBuilder for training logic (train_model(), _train_neural_network(), _train_sklearn_model()) and checkpoint management
  • This would cut model.py from ~1,434 lines to ~800 lines and make ModelFactory the single source of truth for model definitions

Impact

  • ModelFactory.register_model() and list_models() become actually useful
  • Users can register custom models that work with the full pipeline
  • Eliminates ~600 lines of duplicate code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions