aws-solutions-library-samples / osml-model-runner

MIT No Attribution
7 stars 1 forks source link

refactor: break out request helpers into new classes from app.py #99

Closed drduhe closed 1 month ago

drduhe commented 1 month ago

Issue #, if available: n/a

WIP

Notes

This PR introduces refactoring of the ImageRequestHandler and RegionRequestHandler classes to decouple them from ModelRunner. The handlers now accept their necessary dependencies through their constructors, making them self-contained, modular, and easier to test. Additionally, changes to the ModelRunner class were made to initialize these handlers with the appropriate dependencies.

Key Changes:

  1. Decoupled ImageRequestHandler from ModelRunner:

    • ImageRequestHandler now takes in the following dependencies via its constructor:
      • job_table, image_status_monitor, endpoint_statistics_table
      • tiling_strategy, region_request_queue, region_request_table
      • endpoint_utils, config
      • Functional parameters for feature selection, property addition, sinking features, and generating metrics.
    • This eliminates the direct dependency on the ModelRunner instance and improves modularity.
  2. Decoupled RegionRequestHandler from ModelRunner:

    • RegionRequestHandler now takes in its own initialization parameters:
      • region_request_table, job_table, region_status_monitor, endpoint_statistics_table
      • tiling_strategy, region_request_queue, endpoint_utils, config
    • This similarly decouples it from ModelRunner, allowing for cleaner design and unit testing.
  3. Updated ModelRunner to Inject Dependencies:

    • ModelRunner now constructs and passes all required dependencies to both ImageRequestHandler and RegionRequestHandler.
  4. Improved Modular Design and Testability:

    • By passing in functional dependencies and tables as constructor parameters, the handlers are more modular and easier to test in isolation.
  5. Renamed app.py and app_config`` files

    • Renamed app.py to model_runner.py
    • Renamed app_config.py to config.py

Checklist

Before you submit a pull request, please make sure you have the following:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.