diff --git a/CHANGELOG.md b/CHANGELOG.md index fc80fa3e7e..8271e2d8af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,12 +107,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 🐞 Fix keys in data configs to fit AnomalibDataModule parameters by @abc-125 in https://github.com/openvinotoolkit/anomalib/pull/2032 - 🐞 Fix Export docstring in CLI by @ashwinvaidya17 in https://github.com/openvinotoolkit/anomalib/pull/2058 - 🐞 Fix UFlow links by @ashwinvaidya17 in https://github.com/openvinotoolkit/anomalib/pull/2059 +- 🐞 Fix custom callbacks dirpath to be the same as default root dir by @CarlosNacher in https://github.com/openvinotoolkit/anomalib/pull/2194 ### New Contributors - @seyeon923 made their first contribution in https://github.com/openvinotoolkit/anomalib/pull/1966 - @rglkt made their first contribution in https://github.com/openvinotoolkit/anomalib/pull/1956 - @DoMaLi94 made their first contribution in https://github.com/openvinotoolkit/anomalib/pull/1847 +- @CarlosNacher made their first contribution in https://github.com/openvinotoolkit/anomalib/pull/2194 **Full Changelog**: https://github.com/openvinotoolkit/anomalib/compare/v1.0.1...v1.1.0 diff --git a/src/anomalib/engine/engine.py b/src/anomalib/engine/engine.py index 8648cf30ae..7d94de772c 100644 --- a/src/anomalib/engine/engine.py +++ b/src/anomalib/engine/engine.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 import logging +import os from collections.abc import Iterable from pathlib import Path from typing import Any @@ -409,6 +410,15 @@ def _setup_anomalib_callbacks(self) -> None: """Set up callbacks for the trainer.""" _callbacks: list[Callback] = [RichProgressBar(), RichModelSummary()] + # Update dirpath of each cached callback preppending "default_root_dir" + # (which was updated in _setup_workspace() method) + for cached_callback in self._cache.args["callbacks"]: + if hasattr(cached_callback, "dirpath"): + callback_dirpath = Path(cached_callback.dirpath) + common_prefix = Path(os.path.commonpath([str(self._cache.args["default_root_dir"]), str(callback_dirpath)])) + callback_dirpath = callback_dirpath.relative_to(common_prefix) + cached_callback.dirpath = self._cache.args["default_root_dir"] / callback_dirpath + # Add ModelCheckpoint if it is not in the callbacks list. has_checkpoint_callback = any(isinstance(c, ModelCheckpoint) for c in self._cache.args["callbacks"]) if has_checkpoint_callback is False: