Skip to content

Cannot delete unused tasks #984

Closed
Closed

Description

@Didayolo

Note that I have 138 unused tasks. When I try to delete them by clicking on Delete unused tasks, I get the following error message:

Capture d’écran 2023-06-23 à 15 38 13

I see no specific logs in the containers.

Todos:

  • decide solution for this problem
  • Fix the problem

Activity

  1. ihsaan-ullah commented on Jun 23, 2023

    @ihsaan-ullah
    Collaborator

    are you getting this when you click this new button Delete unused tasks?

  2. ihsaan-ullah commented on Jun 23, 2023

    @ihsaan-ullah
    Collaborator

    I am going to add logs so that we can see the real error in django

  3. Didayolo commented on Jun 23, 2023

    @Didayolo
    MemberAuthor

    are you getting this when you click this new button Delete unused tasks?

    Yes

  4. ihsaan-ullah commented on Jun 23, 2023

    @ihsaan-ullah
    Collaborator

    This is happening because of this line of code

    task = models.ForeignKey(Task, on_delete=models.PROTECT, null=True, blank=True, related_name="submissions")

    The reason of this is that you had a task used in a competition, now you have removed it from the competiiton but one or more submissions have already used this task.

  5. ihsaan-ullah commented on Jun 23, 2023

    @ihsaan-ullah
    Collaborator

    Solutions for this:

    1. change model.PROTECT to SETNULL
    2. don't delete tasks used in a submission
  6. ihsaan-ullah commented on Jun 23, 2023

    @ihsaan-ullah
    Collaborator

    @Didayolo can you also check if you still have 138 tasks after the error or some are deleted?

  7. added
    P1
    on Jun 24, 2023
  8. Didayolo commented on Jun 26, 2023

    @Didayolo
    MemberAuthor

    Thanks for the input.

    can you also check if you still have 138 tasks after the error or some are deleted?

    The 138 tasks are remaining

  9. Didayolo commented on Jun 28, 2023

    @Didayolo
    MemberAuthor

    don't delete tasks used in a submission

    I'm not sure if I understand this point

  10. Didayolo commented on Jun 29, 2023

    @Didayolo
    MemberAuthor

    With the new change, the logger returns this when it fails:

    django_1          | UNUSED TASKS DELETION --- ("Cannot delete some instances of model 'Task' because they are referenced through a protected foreign key: 'Submission.task'", <QuerySet [<Submission: Cross-Domain MetaDL submission PK=4037 by pavaotest>, <Submission: Mini-AutoML submission PK=8351 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9219 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=8923 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=8925 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=8926 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=8927 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=8928 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9070 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9071 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9116 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9227 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9195 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9228 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9036 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9238 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9240 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9054 by bdonnot>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9220 by pavao>, <Submission: [L2RPN 2023] Paris Region AI Challenge Energy Transition submission PK=9254 by bdonnot>, '...(remaining elements truncated)...']>)

    The reason of this is that you had a task used in a competition, now you have removed it from the competiiton but one or more submissions have already used this task.

    Given the logs, I think that you are right.

    Solution 1: change model.PROTECT to SETNULL

    This is done by this PR: #994

    Solution 2: don't delete tasks used in a submission

    Then would it be possible to remove a task used in a submission? Solution 1 seems more satisfying but I am not sure of the implications

  11. Didayolo commented on Jun 29, 2023

    @Didayolo
    MemberAuthor

    I merged the Solution 1. It is the responsability of organizers to not delete unused tasks if they plan to re-use a task that have previous submissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugP1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions