Skip to content

Conversation

@Didayolo
Copy link
Member

@Didayolo Didayolo commented Feb 20, 2025

Test

Deployed at https://codabench-test.lri.fr/

Manual intervention

WARNING: we may need to prevent users to use the platform during this deployment.
Start maintenance mode:

touch maintenance/maintenance.on

1. Django migration (#1774, #1752)

docker compose exec django ./manage.py migrate

2. Reset User Quota from Bytes to GB (#1749)

docker compose exec django ./manage.py shell_plus
from profiles.quota import reset_all_users_quota_to_gb
reset_all_users_quota_to_gb()
# Convert all 16 GB quota into 15 GB
from profiles.models import User
users = User.objects.all()
for user in users:
    # Reset quota to 15 if quota is between 15 and 20
    # Do not reset quota for special users like adrien
    if user.quota > 15 and user.quota < 20:
        user.quota = 15
        user.save()

3. Important for file sizes cleanup (#1752)

We have some critical changes here so before deployment we should run the following 3 blocks of code to get the last ids of Data, Submission and SubmissionDetail

Then, in the shell_plus:

# Get the maximum ID for Data
from datasets.models import Data
latest_id_data = Data.objects.latest('id').id
print("Data Last ID: ", latest_id_data)
# Get the maximum ID for Submission
from competitions.models import Submission
latest_id_submission = Submission.objects.latest('id').id
print("Submission Last ID: ", latest_id_submission)
# Get the maximum ID for Submission Detail
from competitions.models import SubmissionDetails
latest_id_submission_detail = SubmissionDetails.objects.latest('id').id
print("SubmissionDetail Last ID: ", latest_id_submission_detail)

After we have the latest ids, we should deploy and run the 3 blocks of code below to fix the sizes i.e. to convert all kib to bytes to make everything consistent. For new files uploaded after the deployment, the sizes will be saved in bytes automatically that is why we need to run the following code for older files only.

# Run the conversion only for records with id <= latest_id
from datasets.models import Data
for data in Data.objects.filter(id__lte=latest_id_data):
    if data.file_size:
        data.file_size = data.file_size * 1024  # Convert from KiB to bytes
        data.save()
# Run the conversion only for records with id <= latest_id
from competitions.models import Submission
for sub in Submission.objects.filter(id__lte=latest_id_submission):
    updated = False  # Track if any field is updated

    if sub.prediction_result_file_size:
        sub.prediction_result_file_size = sub.prediction_result_file_size * 1024  # Convert from KiB to bytes
        updated = True
    
    if sub.scoring_result_file_size:
        sub.scoring_result_file_size = sub.scoring_result_file_size * 1024  # Convert from KiB to bytes
        updated = True

    if sub.detailed_result_file_size:
        sub.detailed_result_file_size = sub.detailed_result_file_size * 1024  # Convert from KiB to bytes
        updated = True
    
    if updated:
        sub.save()
# Run the conversion only for records with id <= latest_id
from competitions.models import SubmissionDetails
for sub_det in SubmissionDetails.objects.filter(id__lte=latest_id_submission_detail):
    if sub_det.file_size:
        sub_det.file_size = sub_det.file_size * 1024  # Convert from KiB to bytes
        sub_det.save()

Then, do not forget to stop maintenance mode:

rm maintenance/maintenance.on

Changes

@Didayolo Didayolo added the Release PR develop --> master label Feb 20, 2025
ihsaan-ullah and others added 13 commits March 5, 2025 15:41
Exclude soft-deleted submissions from leaderboard
Show server error instead of fronend parsing/JSON error
* forum enable/disable functionality added

* new forum_enabled field added to competition dump data
Competition Create form UI updates
Do not allow special chars in usernames
* on signup email stored in lower case letters. Whitelist emails conveted to lowercased

* whitespace removed

* convert email to lowercased during login
Co-authored-by: Adrien Pavão <adrien.pavao@gmail.com>
* user assigned quota will now be in GB instead of bytes

* unused counter removed
* sizes Kib to Bytes, size formatting functions cleanup

* space between size and unit, removed factor multiplication from size calcualtion

* file_size to bytes in SubmissionDetail

* added missing migration

* migration conflict resolved
@Didayolo Didayolo merged commit 4cd2f65 into master Mar 25, 2025
1 check passed
@ihsaan-ullah
Copy link
Collaborator

@Didayolo
Reset quota to 15 GB

docker compose exec django ./manage.py shell_plus
from profiles.models import User
users = User.objects.all()
for user in users:
    # Reset quota to 15 if quota is between 15 and 20
    # Do not reset quota for special users like adrien
    if user.quota > 15 and user.quota < 20:
        user.quota = 15
        user.save()

@Didayolo
Copy link
Member Author

Reset quota to 15 GB

Tested on test server and it works fine

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

Labels

Release PR develop --> master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants