feat: log project annotations as a zipped MLflow artifact - #420
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds optional provenance logging for cross-validation runs by zipping the project’s jabs/annotations directory and uploading it as a consistent MLflow run artifact (annotations.zip). This strengthens reproducibility by allowing metrics to be traced back to the exact label set used for a run, and integrates the behavior into jabs-cli cross-validation with an explicit opt-out.
Changes:
- Add
archive_annotations()and extendlog_cross_validation_to_mlflow()to (optionally) uploadannotations.zipalongside the report. - Plumb new CLI wiring/flags (
--mlflow-no-annotations) throughjabs-cli cross-validationinto the cross-validation runner. - Update documentation and tests to cover the new artifact and opt-out behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/jabs/classifier/mlflow_logging.py |
Adds annotation zipping + MLflow artifact upload support. |
src/jabs/scripts/cli/cross_validation.py |
Passes project.annotation_dir into MLflow logging and adds a toggle param. |
src/jabs/scripts/cli/cli.py |
Introduces --mlflow-no-annotations and forwards the opt-out into CV execution. |
tests/classifier/test_mlflow_logging.py |
Adds unit tests for archive creation, opt-outs, and failure tolerance. |
tests/scripts/test_cross_validation_cli.py |
Adds CLI test coverage for the new opt-out flag and default behavior. |
docs/user-guide/cli-tools.md |
Documents the new artifact and opt-out flag for the published user guide. |
src/jabs/resources/docs/user_guide/cli-tools.md |
Mirrors the same documentation update for in-app docs resources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jabs-cli cross-validation --mlflownow zips the project'sjabs/annotationsdirectory and uploads it as anannotations.ziprun artifact, alongside the training report. This captures the label set a run's metrics were computed from, so a run can be traced back to (and reproduced from) the exact annotations.Changes
jabs/classifier/mlflow_logging.py— newarchive_annotations()helper. Zips withZIP_DEFLATED, storing members under a single top-levelannotations/prefix so unpacking recreates the directory rather than scattering JSON into the cwd. Files are added in sorted order for reproducible archives. ReturnsNone(no error) when the directory is missing or empty.log_cross_validation_to_mlflow()gainedannotations_dirandlog_annotations_artifact; the archive is staged in aTemporaryDirectoryinside the run and logged asannotations.zip— a constant name, so the artifact is easy to find and compare across runs.jabs/scripts/cli/cross_validation.py— passesproject.annotation_dirthrough, plus amlflow_log_annotationsparameter.jabs/scripts/cli/cli.py— new--mlflow-no-annotationsopt-out flag.Notes for review
Two judgment calls worth a look:
--mlflow-no-annotationsflag.--mlflow-no-reportalready existed and its help text promised "metrics + params only", so an unconditional second artifact would have contradicted it. A skip flag also matters for projects with a large annotations directory, since the archive uploads on every run. The--mlflow-no-reporthelp text was updated to drop the now-inaccurate parenthetical.OSErrorwhile zipping logs a warning and the run keeps its metrics, params, and report artifact, consistent with this module's existing stance that a logging failure never costs you the results. The alternative would be exit code 3 on a run whose metrics already landed.Testing
log_artifacttime, since the staging directory is gone by the time assertions run — this is what proves the archive is still on disk when uploaded.