Files
mlflow--mlflow/mlflow/tracking/request_header/abstract_request_header_provider.py
2026-07-13 13:22:34 +08:00

37 lines
1.0 KiB
Python

from abc import ABCMeta, abstractmethod
from mlflow.utils.annotations import developer_stable
@developer_stable
class RequestHeaderProvider:
"""
Abstract base class for specifying custom request headers to add to outgoing requests
(e.g. request headers specifying the environment from which mlflow is running).
When a request is sent, MLflow will iterate through all registered RequestHeaderProviders.
For each provider where ``in_context`` returns ``True``, MLflow calls the ``request_headers``
method on the provider to compute request headers.
All resulting request headers will then be merged together and sent with the request.
"""
__metaclass__ = ABCMeta
@abstractmethod
def in_context(self):
"""Determine if MLflow is running in this context.
Returns:
bool indicating if in this context.
"""
@abstractmethod
def request_headers(self):
"""Generate context-specific request headers.
Returns:
dict of request headers.
"""