diff --git a/codecarbon/emissions_tracker.py b/codecarbon/emissions_tracker.py index 6a5cb3fdd..acb151859 100644 --- a/codecarbon/emissions_tracker.py +++ b/codecarbon/emissions_tracker.py @@ -451,11 +451,11 @@ def start_task(self, task_name=None) -> None: ) self._active_task = task_name - def stop_task(self, task_name: str = None) -> float: + def stop_task(self, task_name: str = None) -> EmissionsData: """ Stop tracking a dedicated execution task. Delta energy is computed by task, to isolate its contribution to total emissions. - :return: None + :return: EmissionData for an execution task """ task_name = task_name if task_name else self._active_task self._measure_power_and_energy() @@ -472,6 +472,7 @@ def stop_task(self, task_name: str = None) -> float: self._tasks[task_name].emissions_data = task_emission_data self._tasks[task_name].is_active = False self._active_task = None + return task_emission_data @suppress(Exception)