Repository navigation
Log prediction runs to MLflow and Snowflake through the tracking adapters #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. | ||
| # All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| r"""MLflow tracking and models for `Trainer.fit` | ||
| (``pip install 'kumo-engine[mlflow]'``).""" | ||
| r"""MLflow tracking and models for `Trainer.fit`, `Trainer.predict` and | ||
| monitoring (``pip install 'kumo-engine[mlflow]'``).""" | ||
|
|
||
| import hashlib | ||
| import json | ||
|
|
@@ -30,7 +30,7 @@ | |
| from kumoapi.plugin import ModelRegistryLocation, PublishedModel | ||
|
|
||
| from kumo.engine._events import Event | ||
| from kumo.engine._tracking import DROPPED_PARAMS, RunRecord | ||
| from kumo.engine._tracking import DROPPED_PARAMS, RunRecord, record_failure | ||
| from kumo.engine._version import __version__ | ||
| from kumo.engine.connector._extras import import_provider | ||
|
|
||
|
|
@@ -63,6 +63,9 @@ class MlflowTracking: | |
| Catalog then links them to a model registered from the run), file and | ||
| object-store sources by URI. Params MLflow rejects are counted in | ||
| ``kumo.dropped_params``. Concurrent fits in one process are not supported. | ||
| As ``kumo.MLOps(tracking=...)``, it also records each prediction run and | ||
| each monitoring call as one run named after it, placed like a fit run; | ||
| ``run_name`` and ``tags`` apply to fit runs only. | ||
|
|
||
| Args: | ||
| experiment_name: experiment for the fit run, created if missing. | ||
|
|
@@ -78,7 +81,8 @@ class MlflowTracking: | |
| serving_snapshot: exported snapshot URI the served model loads at | ||
| startup (see `log_model`). | ||
|
|
||
| ``run_id`` is the MLflow id of the latest fit run, once it has started. | ||
| ``run_id`` is the MLflow id of the most recent tracked run, once it has | ||
| started. | ||
| """ | ||
|
|
||
| def __init__( | ||
|
|
@@ -153,6 +157,10 @@ def start(self, record: RunRecord) -> None: | |
| self._log_artifacts(record.artifacts) | ||
| _log_inputs(mlflow, self._client, self._parent, record.inputs) | ||
|
|
||
| def log_prediction_run(self, record: RunRecord) -> None: | ||
| self.start(record) | ||
| self.finish(record, record_failure(record)) | ||
|
Comment on lines
+161
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finish a run when If MLflow creates the run but |
||
|
|
||
| def log_monitoring(self, record: RunRecord) -> None: | ||
| self.start(record) | ||
| experiment_id, run_id = self._experiment_id, self.run_id | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent overlapping runs on one tracker.
If a prediction’s tracking call exceeds the 30-second wait, its worker continues. A later
predictcall can start another worker on the same tracker. Both adapters reset and update run state on that instance, so the workers can assign records to the wrong run or leave a run unfinished. Serialize calls per tracker or give each prediction an independent run session while preserving the timeout.