Single integration client for all Feast–MLflow functionality. Composes :class:`FeastMlflowLogger`, :class:`FeastMlflowEntityDfBuilder`, and :class:`FeastMlflowModelResolver` so that there is exactly **one** ``mlflow`` import and **one** ``MlflowClient`` instance. Access via ``store
| 26 | |
| 27 | |
| 28 | class FeastMlflowClient: |
| 29 | """Single integration client for all Feast–MLflow functionality. |
| 30 | |
| 31 | Composes :class:`FeastMlflowLogger`, :class:`FeastMlflowEntityDfBuilder`, |
| 32 | and :class:`FeastMlflowModelResolver` so that there is exactly **one** |
| 33 | ``mlflow`` import and **one** ``MlflowClient`` instance. |
| 34 | |
| 35 | Access via ``store.mlflow`` or ``feast.mlflow``:: |
| 36 | |
| 37 | store = FeatureStore(".") |
| 38 | |
| 39 | with store.mlflow.start_run(run_name="training"): |
| 40 | df = store.get_historical_features(...).to_df() |
| 41 | model = train(df) |
| 42 | store.mlflow.log_model(model, "model") |
| 43 | """ |
| 44 | |
| 45 | def __init__(self, store: "FeatureStore"): |
| 46 | import mlflow as _mlflow_mod |
| 47 | |
| 48 | self._mlflow = _mlflow_mod |
| 49 | self._store = store |
| 50 | self._tracking_uri = store.config.mlflow.get_tracking_uri() |
| 51 | self._client = _mlflow_mod.MlflowClient(tracking_uri=self._tracking_uri) |
| 52 | self._default_experiment = store.config.project |
| 53 | |
| 54 | from feast.mlflow_integration.entity_df_builder import ( |
| 55 | FeastMlflowEntityDfBuilder, |
| 56 | ) |
| 57 | from feast.mlflow_integration.logger import FeastMlflowLogger |
| 58 | from feast.mlflow_integration.model_resolver import FeastMlflowModelResolver |
| 59 | |
| 60 | self._logger_impl = FeastMlflowLogger(store, _mlflow_mod, self._client) |
| 61 | self._entity_df_builder = FeastMlflowEntityDfBuilder( |
| 62 | store, _mlflow_mod, self._client |
| 63 | ) |
| 64 | self._model_resolver = FeastMlflowModelResolver( |
| 65 | store, _mlflow_mod, self._client |
| 66 | ) |
| 67 | |
| 68 | @property |
| 69 | def client(self): |
| 70 | """The underlying ``MlflowClient`` instance.""" |
| 71 | return self._client |
| 72 | |
| 73 | @property |
| 74 | def mlflow(self): |
| 75 | """Escape hatch: access the raw ``mlflow`` module.""" |
| 76 | return self._mlflow |
| 77 | |
| 78 | @property |
| 79 | def active_run_id(self) -> Optional[str]: |
| 80 | """Return the active MLflow run ID, or ``None``.""" |
| 81 | run = self._mlflow.active_run() |
| 82 | return run.info.run_id if run else None |
| 83 | |
| 84 | # ------------------------------------------------------------------ |
| 85 | # Run management |
no outgoing calls
no test coverage detected