Download lib/python3.12/site-packages/datasets/utils/experimental.py from parallel-reasoner/env-full: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/parallel-reasoner/env-full/resolve/b7f3eae63e243d6cdeeb4bf3ea233ae95cf99cc8/lib/python3.12/site-packages/datasets/utils/experimental.py
- Command line
-
hf download hf://parallel-reasoner/env-full@b7f3eae63e243d6cdeeb4bf3ea233ae95cf99cc8/lib/python3.12/site-packages/datasets/utils/experimental.py
-
curl -L -o experimental.py https://huggingface.co/parallel-reasoner/env-full/resolve/b7f3eae63e243d6cdeeb4bf3ea233ae95cf99cc8/lib/python3.12/site-packages/datasets/utils/experimental.py
1.1 kB
| """Contains utilities to flag a feature as "experimental" in datasets.""" | |
| import warnings | |
| from functools import wraps | |
| from typing import Callable | |
| def experimental(fn: Callable) -> Callable: | |
| """Decorator to flag a feature as experimental. | |
| An experimental feature trigger a warning when used as it might be subject to breaking changes in the future. | |
| Args: | |
| fn (`Callable`): | |
| The function to flag as experimental. | |
| Returns: | |
| `Callable`: The decorated function. | |
| Example: | |
| ```python | |
| >>> from datasets.utils import experimental | |
| >>> @experimental | |
| ... def my_function(): | |
| ... print("Hello world!") | |
| >>> my_function() | |
| UserWarning: 'my_function' is experimental and might be subject to breaking changes in the future. | |
| Hello world! | |
| ``` | |
| """ | |
| def _inner_fn(*args, **kwargs): | |
| warnings.warn( | |
| (f"'{fn.__name__}' is experimental and might be subject to breaking changes in the future."), | |
| UserWarning, | |
| ) | |
| return fn(*args, **kwargs) | |
| return _inner_fn | |