Skip to content

[REFACTOR] Move each task handler to its task package #207

@jeipollack

Description

@jeipollack

Description of Refactoring/Improvement

Put config handlers WITH the task they configure.

Goals and Objectives
Outline the goals and objectives of the refactoring or improvement effort.

Current Code Behavior

config_handler.py mixes various concerns affecting readability and maintainability.

Proposed Changes
Recommended structure:

src/wf_psf/
├── configs/
│   └── logging.conf              # ✅ Shared config files (YAML/conf)
│
├── training/
│   ├── __init__.py
│   ├── train.py
│   └── training_config_handler.py    # ✅ TrainingConfigHandler here
│
├── metrics/
│   ├── __init__.py
│   ├── evaluate.py
│   └── metrics_config_handler.py     # ✅ MetricsConfigHandler here
│
├── plotting/
│   ├── __init__.py
│   ├── plot.py
│   └── plotting_config_handler.py    # ✅ PlottingConfigHandler here
│
├── inference/
│   ├── __init__.py
│   ├── inference.py
│   └── inference_config_handler.py   # ✅ InferenceConfigHandler here (already done)
│
├── data/
│   ├── __init__.py
│   ├── data_handler.py
│   ├── simulation_data_loader.py
│   └── data_config_handler.py        # ✅ DataConfigHandler here
│
└── utils/
    ├── __init__.py
    ├── read_config.py                # ✅ Shared utilities (RecursiveNamespace, read_conf)
    └── file_io_handler.py            # ✅ Shared file I/O

Expected Benefits

  • Colocation principle

    • Config handlers live next to what they configure
    • Easy to find: "Where's training config? In training/"
    • Clear ownership: training team owns training/ directory
  • Avoids central bottleneck

    • No giant configs/ module that everyone touches
    • Each subsystem is self-contained
    • Easier parallel development
  • Matches existing pattern introduced with inference

    • InferenceConfigHandler already in inference/
    • This extends that pattern consistently
  • Clear imports

  • Add ConfigHandler ABC for type safety

Dependencies
List any dependencies or considerations related to other parts of the codebase.
Will keep backwards compatibility with a wrapper:

# utils/configs_handler.py (deprecated)
"""
DEPRECATED: Config handlers have moved to their respective packages.

Import from new locations:
- TrainingConfigHandler: wf_psf.training.training_config_handler
- MetricsConfigHandler: wf_psf.metrics.metrics_config_handler
- PlottingConfigHandler: wf_psf.plotting.plotting_config_handler
- DataConfigHandler: wf_psf.data.data_config_handler
"""
import warnings

# Backward compatibility imports
from wf_psf.training.training_config_handler import TrainingConfigHandler
from wf_psf.metrics.metrics_config_handler import MetricsConfigHandler
from wf_psf.plotting.plotting_config_handler import PlottingConfigHandler
from wf_psf.data.data_config_handler import DataConfigHandler

warnings.warn(
    "Importing config handlers from wf_psf.utils.configs_handler is deprecated. "
    "Import from their respective packages instead.",
    DeprecationWarning,
    stacklevel=2
)

__all__ = [
    'TrainingConfigHandler',
    'MetricsConfigHandler', 
    'PlottingConfigHandler',
    'DataConfigHandler',
]

Testing Plan
Repeatability validation runs

Additional Context
Include any other relevant context or information related to the refactoring or improvement.

Impact Assessment
Briefly assess the impact of these changes on the overall codebase and project.

Next Steps
Outline the next steps or actions that need to be taken for the refactoring or improvement.

Thank you for starting this request to refactor or improve the code. We will review it and collaborate to enhance the codebase together! 🛠️

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions