diff --git a/inference/core/registries/roboflow.py b/inference/core/registries/roboflow.py index fddb1c0099..04e875b856 100644 --- a/inference/core/registries/roboflow.py +++ b/inference/core/registries/roboflow.py @@ -335,7 +335,8 @@ def _save_model_metadata_in_cache( def construct_model_type_cache_path( dataset_id: Union[DatasetID, ModelID], version_id: Optional[VersionID] ) -> str: - cache_dir = os.path.join( - MODEL_CACHE_DIR, dataset_id, version_id if version_id else "" - ) - return os.path.join(cache_dir, "model_type.json") + # Combine all path parts at once for efficiency + if version_id: + return os.path.join(MODEL_CACHE_DIR, dataset_id, version_id, "model_type.json") + else: + return os.path.join(MODEL_CACHE_DIR, dataset_id, "model_type.json")