This commit is contained in:
Christian Mantha
2026-03-02 19:10:52 -05:00
commit 2ca0b9ef7c
28907 changed files with 5233713 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import logging
from mlflow.tracking.context.abstract_context import RunContextProvider
from mlflow.tracking.context.default_context import _get_main_file
from mlflow.utils.git_utils import get_git_commit
from mlflow.utils.mlflow_tags import MLFLOW_GIT_COMMIT
_logger = logging.getLogger(__name__)
def _get_source_version():
main_file = _get_main_file()
if main_file is not None:
return get_git_commit(main_file)
return None
class GitRunContext(RunContextProvider):
def __init__(self):
self._cache = {}
@property
def _source_version(self):
if "source_version" not in self._cache:
self._cache["source_version"] = _get_source_version()
return self._cache["source_version"]
def in_context(self):
return self._source_version is not None
def tags(self):
return {MLFLOW_GIT_COMMIT: self._source_version}