Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a project with active annotators leaves those annotators ineligible to join another project #411

Open
ianroberts opened this issue May 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ianroberts
Copy link
Member

Describe the bug

If an "in-progress" annotation project is deleted, any active annotator users who are assigned to that project are left permanently ineligible to be assigned to any other projects.

To Reproduce

Steps to reproduce the behavior:

  1. Create a project
  2. Assign an annotator to that project
  3. Delete the project
  4. Attempt to assign the same annotator to a different project - they are not listed in the eligible annotators list

Expected behavior

Deleting a project should free up the annotators who were assigned to that project to be able to annotate other projects.

Additional context

The root cause of this problem appears to be that the foreign key constraints on AnnotatorProject are set to simply set the project field to NULL when the referenced Project is deleted, rather than deleting the whole AnnotatorProject assignment:

annotator = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True, blank=True)
project = models.ForeignKey(Project, on_delete=models.SET_NULL, null=True, blank=True)

This means that the user is not assigned to a project, but they are still considered as "active" in rpc.get_possible_annotators:

# get a list of IDs of annotators that is currently active in any project
active_annotators = User.objects.filter(annotatorproject__status=AnnotatorProject.ACTIVE).values_list('id', flat=True)
project_annotators = project.annotators.all().values_list('id', flat=True)
# Do an exclude filter to remove annotator with the those ids
valid_annotators = User.objects.filter(is_deleted=False).exclude(id__in=active_annotators).exclude(id__in=project_annotators)

and thus not available to be assigned to any other project. When this happened to @iabufarha in production I had to delete the offending row from the backend_annotatorproject table directly in the database to unblock them.

Possible fixes

  1. use on_delete=models.CASCADE so Teamware deletes all AnnotatorProject assignments for this project when the project is deleted, and/or
  2. perform checks in rpc.delete_project and disallow deletion of a project that has active annotators. The manager would need to mark all annotators as "complete" or "rejected" before being allowed to delete the project.
@ianroberts ianroberts added the bug Something isn't working label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant