diff --git a/src/bentoml/metrics.py b/src/bentoml/metrics.py index bc91d85950f..83a7a71c45d 100644 --- a/src/bentoml/metrics.py +++ b/src/bentoml/metrics.py @@ -35,6 +35,8 @@ def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any: return self def __getattr__(self, item: t.Any) -> t.Any: + if item in ("_attr", "_proxy", "_initialized", "_args", "_kwargs"): + raise AttributeError(f"Attribute {item} is private to {self}.") if self._proxy is None: self._load_proxy() assert self._initialized