Skip to content

Conversation

@Lucashsmello
Copy link
Collaborator

This pull request introduces two new annotation entity classes for segmentation tasks (2D and 3D), refactors caching to use lazy initialization for resource and annotation entities, and cleans up the MLflow flavor integration by removing unused or redundant arguments. These changes improve support for segmentation workflows and enhance code maintainability.

Segmentation annotation support:

  • Added ImageSegmentation class for 2D image segmentation annotations, including methods for mask validation, conversion, and area calculation (datamint/entities/annotations/image_segmentation.py, datamint/entities/annotations/__init__.py). [1] [2]
  • Added VolumeSegmentation class for 3D volume segmentation annotations, supporting both semantic and instance segmentation with class mapping and validation (datamint/entities/annotations/volume_segmentation.py, datamint/entities/annotations/__init__.py). [1] [2]

Caching improvements:

  • Refactored _cache initialization in both Annotation and Resource classes to use a property with lazy instantiation, improving memory usage and avoiding unnecessary cache creation (datamint/entities/annotations/annotation.py, datamint/entities/resource.py). [1] [2]
  • Removed redundant setting of _cache to None in various code paths in Resource to simplify logic (datamint/entities/resource.py). [1] [2] [3]

MLflow flavor integration cleanup:

  • Removed unused or redundant arguments such as example_no_conversion, conda_env, and streamable from MLflow flavor API, and refactored argument names for clarity (e.g., artifact_path to name) (datamint/mlflow/flavors/datamint_flavor.py). [1] [2] [3] [4]
  • Changed import of Sequence to use collections.abc for Python 3.10+ compatibility (datamint/mlflow/flavors/datamint_flavor.py).

Minor cleanup:

  • Removed commented-out type alias in model.py (datamint/mlflow/flavors/model.py).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces segmentation annotation support for 2D images and 3D volumes, refactors caching to use lazy initialization for better memory efficiency, and simplifies the MLflow flavor integration by removing unused parameters and improving error handling.

  • Added ImageSegmentation and VolumeSegmentation classes with factory methods for creating segmentation annotations from numpy arrays and NIfTI images
  • Refactored _cache in Annotation and Resource classes to use lazy property-based initialization
  • Updated MLflow flavor API to remove unused parameters (example_no_conversion, conda_env, streamable) and renamed artifact_path to name

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
datamint/entities/annotations/image_segmentation.py New 2D segmentation annotation class with mask validation and utility methods
datamint/entities/annotations/volume_segmentation.py New 3D volume segmentation annotation class supporting semantic segmentation with class maps
datamint/entities/annotations/init.py Exports new segmentation annotation classes
datamint/entities/annotations/annotation.py Refactored _cache to use lazy property initialization instead of eager initialization
datamint/entities/resource.py Refactored _cache to use lazy property and removed redundant _cache = None assignments
datamint/mlflow/flavors/datamint_flavor.py Removed unused parameters and changed artifact_path to name, updated import for Python 3.10+ compatibility
datamint/mlflow/flavors/model.py Refactored cached attributes cleanup to use a centralized list pattern
datamint/mlflow/lightning/callbacks/modelcheckpoint.py Improved model URI restoration with search_logged_models, added error handling for signature updates, removed debug logs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Lucashsmello Lucashsmello merged commit 74fdb8b into main Dec 29, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants