ops_utils

pyops-service-toolkit.

Welcome to the documentation for pyops-service-toolkit. Use the sidebar menu on the left to browse available submodules, or search our documentation if you're looking for something specific! If there's something missing, or if you have questions, reach out to the Operations team at support@pipeline-ops.zendesk.com.

 1r"""
 2# pyops-service-toolkit.
 3
 4Welcome to the documentation for
 5[pyops-service-toolkit](https://github.com/broadinstitute/pyops-service-toolkit).
 6Use the sidebar menu on the left to browse available submodules, or search our documentation
 7if you're looking for something specific! If there's something missing, or if you have
 8questions, reach out to the Operations team at `support@pipeline-ops.zendesk.com`.
 9
10"""
11
12import warnings
13import functools
14
15
16# To avoid breaking changes and converting these to have underscores,
17# we can instead add the @private annotation in the docstring
18def comma_separated_list(value: str) -> list:
19    """Return a list of values from a comma-separated string.
20
21    Can be used as type in argparse.
22    @private
23    """
24    return value.split(",")
25
26
27def deprecated(reason: str):  # type: ignore[no-untyped-def]
28    """Use as wrapper function for deprecated functionality.
29
30    Use the @deprecated decorator for a function and provide a reason. 
31    Anytime the function is called, a deprecation warning will be raised.
32    @private
33    """
34    def decorator(func):  # type: ignore[no-untyped-def]
35        @functools.wraps(func)
36        def wrapper(*args, **kwargs):  # type: ignore[no-untyped-def]
37            warnings.warn(
38                f"{func.__name__} is deprecated: {reason}",
39                category=DeprecationWarning,
40                stacklevel=2
41            )
42            return func(*args, **kwargs)
43        return wrapper
44    return decorator