Skip to content

Comments

SCKAN-450 fix: Set population index on invalid statements#531

Merged
afonsobspinto merged 7 commits intorelease/6.0.0from
feature/SCKAN-450
Nov 6, 2025
Merged

SCKAN-450 fix: Set population index on invalid statements#531
afonsobspinto merged 7 commits intorelease/6.0.0from
feature/SCKAN-450

Conversation

@afonsobspinto
Copy link
Member

@afonsobspinto afonsobspinto commented Nov 5, 2025

Closes https://metacell.atlassian.net/browse/SCKAN-450

I believe the problem was caused by the fact that statements that were originally ingested into invalid state never got a population_index.

To fix it, this PR:

  • Creates a django command that synchronizes the population_index of all exported/invalid statements with the expected population_index according to the curie_id. See the command readme for more details. (fixes the current problems)
  • Updates the transition to Invalid to set the population_index (prevents this from happening again)

When deployed run:
python manage.py reassign_population_indices --dry-run

And if you are happy with the changes that would happen run without the --dry-run flag.

Example of log file when running the command locally:

population_index_reassignment_2025-11-05_12-23-17.log

@afonsobspinto afonsobspinto requested a review from Copilot November 5, 2025 11:57
Copy link
Contributor

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 PR addresses an issue where statements that were originally ingested into an invalid state never received a population_index. The fix ensures that all exported/invalid statements have consistent population indices based on their curie_id values.

Key Changes:

  • Updates the invalid state transition to properly set the population_index by calling _perform_export_logic() instead of just setting the has_statement_been_exported flag
  • Adds a Django management command to synchronize existing population indices with expected values based on curie_id patterns
  • Includes comprehensive documentation for the new management command

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
applications/composer/backend/composer/models.py Updates the invalid transition method to use _perform_export_logic() to ensure population_index is set
applications/composer/backend/composer/management/commands/reassign_population_indices.py Adds a new Django management command that synchronizes population indices for exported statements based on their curie_id patterns
applications/composer/backend/composer/management/commands/README_reassign_population_indices.md Provides detailed documentation for the new management command including usage examples and expected behavior

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

@afonsobspinto
Copy link
Member Author

Note:
With this new command I made it so that the population_index are synced with the curie_id when possible but this is a band-aid solution to the real problem addressed in #524 (comment).
To have a proper solution we need to understand from neurondm:

  • how are the statements created in composer re-ingested in neurondm, will aacar 16 in composer be aacar 16 in neurondm.
  • how to handle on composer side when neurondm curie_id name has an hyphen in the population index space like:
    neuron type femrep 40-3
    neuron type femrep 40-2

@afonsobspinto afonsobspinto merged commit 4c83d00 into release/6.0.0 Nov 6, 2025
@ddelpiano ddelpiano deleted the feature/SCKAN-450 branch November 14, 2025 10:56
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