From fa1dd0e85d98ec514201fce6f3bb60891a713210 Mon Sep 17 00:00:00 2001 From: Rob Miller Date: Thu, 12 Dec 2024 10:35:28 -0500 Subject: [PATCH] Fix model_id bug --- .../model_monitoring_inference_aggregator/v1.py | 5 ++--- ...test_model_monitoring_inference_aggregator.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/inference/core/workflows/core_steps/sinks/roboflow/model_monitoring_inference_aggregator/v1.py b/inference/core/workflows/core_steps/sinks/roboflow/model_monitoring_inference_aggregator/v1.py index d82b74835..bd8badf4b 100644 --- a/inference/core/workflows/core_steps/sinks/roboflow/model_monitoring_inference_aggregator/v1.py +++ b/inference/core/workflows/core_steps/sinks/roboflow/model_monitoring_inference_aggregator/v1.py @@ -214,7 +214,6 @@ def __init__( api_key: Optional[str], background_tasks: Optional[BackgroundTasks], thread_pool_executor: Optional[ThreadPoolExecutor], - model_id: str, ): if api_key is None: raise ValueError( @@ -228,7 +227,6 @@ def __init__( self._background_tasks = background_tasks self._thread_pool_executor = thread_pool_executor self._predictions_aggregator = PredictionsAggregator() - self._model_id = model_id @classmethod def get_init_parameters(cls) -> List[str]: @@ -244,10 +242,11 @@ def run( predictions: Union[sv.Detections, dict], frequency: int, unique_aggregator_key: str, + model_id: str, ) -> BlockResult: self._last_report_time_cache_key = f"workflows:steps_cache:roboflow_core/model_monitoring_inference_aggregator@v1:{unique_aggregator_key}:last_report_time" if predictions: - self._predictions_aggregator.collect(predictions, self._model_id) + self._predictions_aggregator.collect(predictions, model_id) if not self._is_in_reporting_range(frequency): return { "error_status": False, diff --git a/tests/workflows/unit_tests/core_steps/sinks/roboflow/test_model_monitoring_inference_aggregator.py b/tests/workflows/unit_tests/core_steps/sinks/roboflow/test_model_monitoring_inference_aggregator.py index 75f6aa865..858641b74 100644 --- a/tests/workflows/unit_tests/core_steps/sinks/roboflow/test_model_monitoring_inference_aggregator.py +++ b/tests/workflows/unit_tests/core_steps/sinks/roboflow/test_model_monitoring_inference_aggregator.py @@ -54,13 +54,13 @@ def test_run_not_in_reporting_range_success( api_key="my_api_key", background_tasks=None, thread_pool_executor=None, - model_id="my_model_id", ) result = block.run( fire_and_forget=True, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="my_model_id", ) # then @@ -121,13 +121,13 @@ def test_run_in_reporting_range_success_with_object_detection( api_key=api_key, background_tasks=None, thread_pool_executor=None, - model_id="construction-safety/10", ) result = block.run( fire_and_forget=False, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="construction-safety/10", ) # then @@ -217,13 +217,13 @@ def test_run_in_reporting_range_success_with_single_label_classification( api_key=api_key, background_tasks=None, thread_pool_executor=None, - model_id="pills-classification/1", ) result = block.run( fire_and_forget=False, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="pills-classification/1", ) # then @@ -313,13 +313,13 @@ def test_run_in_reporting_range_success_with_multi_label_classification( api_key=api_key, background_tasks=None, thread_pool_executor=None, - model_id="animals/32", ) result = block.run( fire_and_forget=False, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="animals/32", ) # then @@ -415,13 +415,13 @@ def test_send_inference_results_to_model_monitoring_failure( api_key=api_key, background_tasks=None, thread_pool_executor=None, - model_id="my_model_id", ) result = block.run( fire_and_forget=False, frequency=1, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="my_model_id", ) # then @@ -479,13 +479,13 @@ def test_run_when_not_in_reporting_range( api_key=api_key, background_tasks=None, thread_pool_executor=None, - model_id="my_model_id", ) result = block.run( fire_and_forget=False, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="my_model_id", ) # then @@ -545,13 +545,13 @@ def test_run_when_fire_and_forget_with_background_tasks( api_key=api_key, background_tasks=background_tasks, thread_pool_executor=None, - model_id="my_model_id", ) result = block.run( fire_and_forget=True, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="my_model_id", ) # then @@ -609,13 +609,13 @@ def test_run_when_fire_and_forget_with_thread_pool( api_key=api_key, background_tasks=None, thread_pool_executor=thread_pool_executor, - model_id="my_model_id", ) result = block.run( fire_and_forget=True, frequency=10, predictions=predictions, unique_aggregator_key=unique_aggregator_key, + model_id="my_model_id", ) # then