Administrator procedures - codalab/codabench GitHub Wiki
During testing, if you want to update or restart some services (e.g : Django), you should follow the following steps:
docker compose stop django
docker compose rm django # remove old django container
docker compose create django # create new django container with the changes from your development
docker compose start django
This procedure helps you update changes of your development on Django without having to restart every Codabench container.
With superuser privileges, the user can edit any benchmark and can access the Django admin interface.
docker compose exec django ./manage.py shell_plus
>>> u = User.objects.get(username='<USERNAME>') # can also use email
>>> u.is_staff = True
>>> u.is_superuser = True
>>> u.save()
docker compose exec django ./manage.py shell_plus
>>> u = User.objects.get(username='<USERNAME>') # can also use email
>>> u.quota = u.quota * 3
>>> u.save()
docker compose exec django ./manage.py makemigrations
docker compose exec django ./manage.py migrate
docker compose exec django ./manage.py collectstatic --noinput
# Begin in codabench root directory
cd codabench
sudo rm -r var/postgres/*
sudo rm -r var/minio/*
ls var
docker compose down
docker compose up -d
docker compose exec django ./manage.py migrate
There are two ways of setting a competition as featured:
- Use Django admin (see below) -> click the competition -> scroll down to is featured filed -> Check/Uncheck it
- Use competition ID in the django bash to feature or unfeature a competition
docker compose exec django ./manage.py shell_plus
>>> comp = Competition.objects.get(id=<ID>) # replace <ID> with competition id
>>> comp.is_featured = True # set to False if you want to unfeature a competition
>>> comp.save()
If you're running your own Codabench instance, there are different ways to interact with the application. Inside the django
container (docker compose exec django bash
) you can use python manage.py help
to display all available commands and a brief description. By far the most useful are createsuperuser
and shell/shell_plus
.
Once you log in an account with superuser privileges, you have access to the "Django Admin" interface:
From this interface, you can change a user's quota, change their staff and superuser status, change the featured competitions displayed on the homepage, manage user accounts and more.
In the Django admin interface, click on Announcements
or New posts
:
For announcement, only the first announcement is read by the front page. For news, all objects are read as separate news. You can create and edit objects using the interface. Write the announcement and news using HTML to format the text, add links, and more:
Go to Users
:
Select it, select the Delete selected users
action and click on Go
:
The RabbitMQ management tool allows you to see the status of various queues, virtual hosts, and jobs. By default, you can access it at: http://<your_codalab_instance>:15672/
. The username/password is your RabbitMQ .env
settings for username and password. The port is hard-set in docker-compose.yml
to 15672, but you can always change this if needed. For more information, see:
https://www.rabbitmq.com/management.html
Flower is a web based tool for monitoring and administrating Celery clusters. By default, you can access the Flower web portal at http://<your_codalab_instance>:5555/
. The username/password is your Flower .env
settings for username and password. 5555 is the default port, and cannot be changed without editing the docker-compose.yml
file.
For more information on flower, please visit: https://flower.readthedocs.io/en/latest/
The storage analytics page is accessible at codabench-url/analytics/ under the storage tab.
From this interface, you will have access to various analytics data:
- A Storage usage history chart
- A Competitions focused storage evolution, distribution and table
- A Users focused storage evolution, distribution and table
All of those data can be filtered by date range and resolution, and exported as CSVs.
The data displayed in those charts are only calculated from a background analytics task that takes place every Sunday at 02:00 UTC time (value editable in the src/settings/base.py
).
The analytics task is a celery tasked named analytics.tasks.create_storage_analytics_snapshot
.
What it does:
- It scans the database looking for file sizes that are not set or flagged in error
- Actually measures their size and saves it in the database
- Aggregate the storage space used by day and by Competition/User (for example every day for the last year for each competition) by looking at the database file size fields
- For data related to the Platform Administration it measures as well the database backup folder directly from the storage instance.
- Everything is saved as multiple snapshot in time in each Category table (i.g.:
UserStorageDataPoint
) - This tasks also runs a database <-> storage inconsistency check and saves the results in a log file located in the
var/logs/
folder
To manually start the task, you can do the following:
- Start codabench
docker compose up -d
- Bash into the django container and start a python console:
docker compose exec django ./manage.py shell_plus
- Manually start the task:
from analytics.tasks import create_storage_analytics_snapshot
eager_results = create_storage_analytics_snapshot.apply_async()
- If you check the logs (
docker compose logs -f
) of the app you should see "Task create_storage_analytics_snapshot started" coming from the site_worker container - If you have to restart the task, don't worry, it will only compute the size of the files that hasn't been computed yet.
- Once the task is over you should be able to see the results on the web page
There is also a daily background task counting users, competitions and submissions, in order to display it on the homepage.
You can manually run it:
docker compose exec django ./manage.py shell_plus
from analytics.tasks import update_home_page_counters
eager_results = update_home_page_counters.apply_async()
To increase a user quota:
- Go to the Django admin page
- Click user table
- Select the user for whom you want to increase/decrease quota
- Update the quota field with new quota
You can create a CSV file with competitions statistics by following the steps below:
- Start codabench
docker compose up -d
- Bash into the django container and start a python console:
docker compose exec django ./manage.py shell_plus
- Import and call the function:
from competitions.statistics import create_codabench_statistics
create_codabench_statistics()
Note: the csv file is named codabench_metadata.csv
and is generated in statistics
folder