Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/codalab/codabench into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
Didayolo committed Dec 3, 2024
2 parents 7bf0d47 + d4ad8a1 commit 6cbb09f
Show file tree
Hide file tree
Showing 12 changed files with 689 additions and 547 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/release-version-update.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Update version.json and create PR

# Trigger the github action when a new release is published
on:
release:
types: [published]
Expand All @@ -9,50 +10,62 @@ jobs:
runs-on: ubuntu-latest

steps:

# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Get latest release version information
- name: Get release information
id: get_release
run: |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
echo "$response" | jq '.tag_name, .name, .published_at, .body, .html_url' | tee /tmp/release_info
echo "::set-output name=tag_name::$(echo "$response" | jq -r .tag_name)"
echo "::set-output name=name::$(echo "$response" | jq -r .name)"
echo "::set-output name=published_at::$(echo "$response" | jq -r .published_at)"
echo "::set-output name=body::$(echo "$response" | jq -r .body)"
echo "::set-output name=html_url::$(echo "$response" | jq -r .html_url)"
echo "tag_name=$(echo "$response" | jq -r .tag_name)" >> $GITHUB_ENV
echo "name=$(echo "$response" | jq -r .name)" >> $GITHUB_ENV
echo "published_at=$(echo "$response" | jq -r .published_at)" >> $GITHUB_ENV
echo "body=$(echo "$response" | jq -r .body)" >> $GITHUB_ENV
echo "html_url=$(echo "$response" | jq -r .html_url)" >> $GITHUB_ENV
# Step 3: Update version.json file with latest information
- name: Update version.json
run: |
echo '{
"tag_name": "${{ steps.get_release.outputs.tag_name }}",
"release_name": "${{ steps.get_release.outputs.name }}",
"published_at": "${{ steps.get_release.outputs.published_at }}",
"body": "${{ steps.get_release.outputs.body }}"
"html_url": "${{ steps.get_release.outputs.html_url }}"
"tag_name": "${{ env.tag_name }}",
"release_name": "${{ env.name }}",
"published_at": "${{ env.published_at }}",
"body": "${{ env.body }}",
"html_url": "${{ env.html_url }}"
}' > version.json
# Step 4: Configure a user to create a branch and then push changes
- name: Configure Git user
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# Step 5: Create a new branch for version updates
- name: Create new branch
run: |
git checkout -b update-version-${{ steps.get_release.outputs.tag_name }}
git checkout -b update-version-${{ env.tag_name }}
git add version.json
git commit -m "Update version.json for release ${{ steps.get_release.outputs.tag_name }}"
git commit -m "Update version.json for release ${{ env.tag_name }}"
# Step 6: Push branch
- name: Push branch
run: |
git push origin update-version-${{ steps.get_release.outputs.tag_name }}
git push origin update-version-${{ env.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Step 7: Create a pull request from the pushed branch
- name: Create Pull Request
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{
"title": "Update version.json for release ${{ steps.get_release.outputs.tag_name }}",
"title": "Update version.json for release ${{ env.tag_name }}",
"body": "This PR updates version.json with the latest release information.",
"head": "update-version-${{ steps.get_release.outputs.tag_name }}",
"head": "update-version-${{ env.tag_name }}",
"base": "develop"
}'
174 changes: 141 additions & 33 deletions compute_worker/poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions compute_worker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ name = "compute-worker"
version = "0.1.0"
description = ""
authors = ["codalab"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
celery = "4.4.0"
requests = "2.20.0"
requests = "^2.20.0"
watchdog = "2.1.1"
argh = "0.26.2"
websockets = "8.1"
Expand Down
887 changes: 417 additions & 470 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ drf-yasg = {version = "1.11.0", extras = ["validation"]}
flex = "6.12.0"
pyrabbit2 = "1.0.7"
django-enforce-host = "1.0.1"
twisted = "20.3.0"
twisted = "24.7.0"
ipdb = "0.13"
flake8 = "3.8.4"
pytest = "6.2.1"
Expand Down
2 changes: 1 addition & 1 deletion src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def creation_status(self, request, pk):
@action(detail=False, methods=('GET',), permission_classes=(AllowAny,))
def front_page(self, request):
popular_comps = get_popular_competitions()
featured_comps = get_featured_competitions(excluded_competitions=popular_comps)
featured_comps = get_featured_competitions()
popular_comps_serializer = CompetitionSerializerSimple(popular_comps, many=True)
featured_comps_serializer = CompetitionSerializerSimple(featured_comps, many=True)
return Response(data={
Expand Down
40 changes: 40 additions & 0 deletions src/apps/competitions/migrations/0049_auto_20241121_0922.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 2.2.17 on 2024-11-21 09:22

from django.db import migrations, models
import storages.backends.s3boto3
import utils.data


class Migration(migrations.Migration):

dependencies = [
('competitions', '0048_auto_20240401_1646'),
]

operations = [
migrations.AddField(
model_name='competition',
name='is_featured',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='submission',
name='detailed_result',
field=models.FileField(blank=True, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(), upload_to=utils.data.PathWrapper('detailed_result')),
),
migrations.AlterField(
model_name='submission',
name='prediction_result',
field=models.FileField(blank=True, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(), upload_to=utils.data.PathWrapper('prediction_result')),
),
migrations.AlterField(
model_name='submission',
name='scoring_result',
field=models.FileField(blank=True, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(), upload_to=utils.data.PathWrapper('scoring_result')),
),
migrations.AlterField(
model_name='submissiondetails',
name='data_file',
field=models.FileField(storage=storages.backends.s3boto3.S3Boto3Storage(), upload_to=utils.data.PathWrapper('submission_details')),
),
]
14 changes: 14 additions & 0 deletions src/apps/competitions/migrations/0051_merge_20241203_1313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.28 on 2024-12-03 13:13

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('competitions', '0050_auto_20241128_0814'),
('competitions', '0049_auto_20241121_0922'),
]

operations = [
]
3 changes: 3 additions & 0 deletions src/apps/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Competition(ChaHubSaveMixin, models.Model):
# If true, participants see the make their submissions public
can_participants_make_submissions_public = models.BooleanField(default=True)

# If true, competition is featured and may show up on the home page
is_featured = models.BooleanField(default=False)

# Count of submissions for this competition
submissions_count = models.PositiveIntegerField(default=0)

Expand Down
32 changes: 8 additions & 24 deletions src/apps/competitions/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
This file contains utilities for competitions
'''
# import random
import random
# from django.db.models import Count

from competitions.models import Competition
Expand All @@ -25,34 +25,18 @@ def get_popular_competitions(limit=4):
return competitions[:limit]


def get_featured_competitions(limit=4, excluded_competitions=None):
def get_featured_competitions(limit=4):
'''
Function to return featured competitions if they are still open.
Function to return featured competitions
:param limit: Amount of competitions to return. Default is 3
:param excluded_competitions: list of popular competitions to prevent displaying duplicates
:param limit: Amount of competitions to return. Default is 4
:rtype: list
:return: list of featured competitions
'''

# TODO: Fix the fetching of the featured competitions
# Uncomment and update the following code when a long term fix is implemented for participants count
competitions = Competition.objects.filter(is_featured=True)

# competitions = Competition.objects.filter(published=True) \
# .annotate(participant_count=Count('participants'))

# if excluded_competitions:
# competitions = competitions.exclude(pk__in=[c.pk for c in excluded_competitions])

# if len(competitions) <= limit:
# return competitions
# else:
# return random.sample(list(competitions), limit)

# Temporary solution to show specific featured competitions
try:
featured_competiion_ids = [3523, 2745, 3160, 1567]
competitions = Competition.objects.filter(id__in=featured_competiion_ids)
if len(competitions) <= limit:
return competitions
except Exception:
return []
else:
return random.sample(list(competitions), limit)
20 changes: 20 additions & 0 deletions src/apps/datasets/migrations/0008_auto_20241121_0922.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.2.17 on 2024-11-21 09:22

from django.db import migrations, models
import storages.backends.s3boto3
import utils.data


class Migration(migrations.Migration):

dependencies = [
('datasets', '0007_auto_20230609_1738'),
]

operations = [
migrations.AlterField(
model_name='data',
name='data_file',
field=models.FileField(blank=True, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(), upload_to=utils.data.PathWrapper('dataset')),
),
]
14 changes: 14 additions & 0 deletions src/apps/datasets/migrations/0009_merge_20241203_1313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.28 on 2024-12-03 13:13

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('datasets', '0008_auto_20241118_1106'),
('datasets', '0008_auto_20241121_0922'),
]

operations = [
]

0 comments on commit 6cbb09f

Please sign in to comment.