Skip to content

Conversation

bmartel
Copy link
Contributor

@bmartel bmartel commented Sep 2, 2025

This pull request introduces a foundational set of models and supporting code for tracking state transitions (finite state machine, FSM) for Label Studio core entities: Tasks, Annotations, and Projects. It adds new migration files, core state models, state choice enums, and improves the state manager interface for clarity and extensibility.

The most important changes are:

Core FSM Models and Schema:

  • Added new Django models TaskState, AnnotationState, and ProjectState in fsm/models.py to track state transitions for their respective entities, including denormalized fields for performance and index optimizations. These models are registered for FSM use and support a simple 3-state workflow for each entity.
  • Introduced the initial migration (0001_initial.py) that creates the above state models with all necessary fields, relationships, and indexes to support efficient querying and reporting.

State Choices Registry:

  • Added state_choices.py, defining TaskStateChoices, AnnotationStateChoices, and ProjectStateChoices as Django TextChoices enums, and registered them for FSM usage. This centralizes and standardizes the possible states for each entity type.

State Manager API Improvements:

  • Renamed the core state retrieval method from get_current_state to get_current_state_value for clarity, and provided a backward-compatible alias. This makes the API clearer and future-proof. [1] [2] [3] [4]

Imports and Registry Integration:

  • Updated imports in fsm/models.py to use the new registry system for state models and choices, ensuring all FSM components are properly registered and discoverable.

Improved Test Coverage

  • Added more test coverage for the additional code as well as missing lines from the previous PR.

Copy link
Contributor

@mcanu mcanu left a comment

Choose a reason for hiding this comment

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

Some small comments, LGTM

bmartel and others added 5 commits September 8, 2025 11:36
Co-authored-by: Marcel Canu <marcel@humansignal.com>
Co-authored-by: Marcel Canu <marcel@humansignal.com>
…nd utilize get_current_state_value and get_current_state_object as the only means for retrieving current_state
@bmartel
Copy link
Contributor Author

bmartel commented Sep 9, 2025

/fm sync

Workflow run

@bmartel
Copy link
Contributor Author

bmartel commented Sep 9, 2025

/fm sync

Workflow run

@bmartel
Copy link
Contributor Author

bmartel commented Sep 10, 2025

/fm sync

Workflow run

@bmartel
Copy link
Contributor Author

bmartel commented Sep 10, 2025

/fm sync

Workflow run

@bmartel
Copy link
Contributor Author

bmartel commented Sep 10, 2025

/fm sync

Workflow run

@bmartel
Copy link
Contributor Author

bmartel commented Sep 11, 2025

/fm sync

Workflow run

@robot-ci-heartex robot-ci-heartex merged commit 93633f7 into develop Sep 11, 2025
53 checks passed
@robot-ci-heartex robot-ci-heartex deleted the fb-fit-610-fsm-models branch September 11, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants