Open
Conversation
…to_urn_list` that allows controllable behavior for superseding score sets
Add sortable collections feature allowing users to specify and maintain custom ordering of score sets and experiments within collections across all API operations (CREATE, GET, PATCH, POST, DELETE). Key Changes: - Replace simple many-to-many relationships with association object pattern using full ORM models with position column - Add CollectionScoreSetAssociation and CollectionExperimentAssociation models with position tracking - Use SQLAlchemy AssociationProxy for transparent access to related objects while maintaining ordered relationships - Implement position-based ordering in all collection endpoints API Behavior: - POST endpoints append new items to end of collection - PATCH endpoint uses replace-all semantics with implicit add/remove - DELETE endpoints remove items and re-index remaining positions - GET endpoints return items in user-specified order - Permission escalation checks for PATCH when membership changes Database Migration: - Add position column to collection association tables - Backfill with sequential positions using ROW_NUMBER() window function partitioned by collection_id for deterministic ordering - Remove server default after backfill for application control Testing: - Add 14 comprehensive router tests for ordering functionality - Test order preservation, reordering, appending, removal, implicit add/remove, error handling, and permission enforcement - Add 3 view model tests for ORM-to-view order preservation - Fix test helpers to track experiment URN changes during publishing The implementation is fully backward compatible with existing API clients and maintains all previous functionality via AssociationProxy.
…das for 3.12 support
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.
This pull request introduces ordered many-to-many relationships between
Collectionand bothExperimentandScoreSetmodels, enabling explicit user-controlled ordering of experiments and score sets within collections. It replaces the previous association tables with new association models that include apositioncolumn, updates the database schema accordingly, and refactors related ORM logic and API endpoints to support these changes.Database schema and association model changes:
CollectionExperimentAssociationandCollectionScoreSetAssociationwith apositioncolumn to maintain ordering in thecollection_experimentsandcollection_score_setstables. The corresponding Alembic migration adds thepositioncolumn and backfills existing data to preserve deterministic order. [1] [2] [3]ORM and model refactoring:
Collectionmodel to use the new association models for relationships with experiments and score sets, providing ordered access via association proxies. Removed the old association tables and updated related imports. [1] [2] [3]ExperimentandScoreSetmodels to use view-only relationships to collections via the new association tables, ensuring correct ORM behavior without direct modification from their side. [1] [2] [3] [4] [5]API and business logic updates:
Minor utility and import adjustments: