Coverage for src/mlopus/mlflow/api/common/decorators.py: 93%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-07-13 14:49 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-07-13 14:49 +0000
1import functools
4def online(func):
5 """Decorator for API methods that are unavailable in offline mode."""
7 @functools.wraps(func)
8 def wrapper(self, *args, **kwargs):
9 if self.offline_mode:
10 raise RuntimeError(f"Cannot access `{self.__class__.__name__}.{func.__name__}` in offline mode.")
11 return func(self, *args, **kwargs)
13 return wrapper
16def require_update(func):
17 """Decorator for API methods that require updating the entity data."""
19 @functools.wraps(func)
20 def wrapper(self, *args, **kwargs):
21 retval = func(self, *args, **kwargs)
22 self.update()
23 return retval
25 return wrapper