Skip to content

Add opt-in per-phase team (organization) submission quota - #2683

Merged
ObadaS merged 2 commits into
codalab:feature/team-submission-quotafrom
asortubay:feature/team-submission-quota
Nov 3, 2026
Merged

ObadaS merged 2 commits into
codalab:feature/team-submission-quotafrom
asortubay:feature/team-submission-quota

Conversation

@asortubay

@asortubay asortubay commented Oct 23, 2026 •

Copy link
Copy Markdown

A brief description of the purpose of the changes contained in this PR.

Adds an opt-in, per-phase team (organization) submission quota, requested by the organizers of EEG/EMG Challenge 2026. Today max_submissions / max_submissions_per_day apply per user, so a team of N members gets N× the sealed submissions.

New field Phase.max_submissions_scope:

  • participant (default): current behavior. Migration 0066 adds the field with this default, so existing competitions are unchanged.
  • organization: both limits are shared by all current members of each of the user's organizations.

Team usage. Every submission in the phase whose owner is a current member of the organization (Membership.ALL_GROUP, so pending invites don't count). This includes tagged and untagged submissions, so a member can't get around the team cap by submitting as themselves. The exclusion filters are the same as today: parent submissions only, no organizer re-submissions, no Failed.

Enforcement. A user is blocked when any of their teams has reached either limit. The message names the team: Team "<name>" has reached the maximum allowed submissions [for today] for this phase. The logic lives in Phase.can_user_make_submissions, so all three existing call sites pick it up unchanged: SubmissionCreationSerializer.validate, the can_make_submission endpoint and Submission.save(). Users without a team keep individual limits and the existing messages. The daily cap is the same UTC calendar day as the individual limit.

Edge cases (documented in Yaml-Structure.md):

  • Membership is evaluated at submit time. A member who joins brings their earlier submissions in the phase, and a member who leaves takes theirs away.
  • A user in several organizations counts toward each of them and is blocked as soon as any one is full.

Exposed in: both phase serializers, the v1/v2 YAML unpackers (optional key, default participant; invalid values fail serializer validation), the competition YAML export (PHASE_FIELDS), the phase editor (Advanced → "Max Submissions Scope") and the docs:

phases:
  - name: Final Phase
    max_submissions: 5
    max_submissions_scope: organization  # the 5 submissions are shared by each team

Badges. In organization-scoped phases, the submission-limit badges show team usage. For a user in several teams, they show the team closest to its limit.

Notes for reviewers

  • The editor field is a native <select>, to keep the diff minimal. I'm happy to switch it to a Semantic UI dropdown like the rest of the editor.
  • This PR comes from a fork, so if CircleCI doesn't trigger, feel free to mirror the branch into the main repo.
  • Known follow-up: the badge has no "team" label yet. A label would also need to handle users without a team.

Pre-existing inconsistencies noticed (not changed here)

  1. The participant-scope badge counters don't exclude resubmitted_from, but enforcement does, so the badge over-reports after an organizer re-submission.
  2. The badge counters duplicate the model's counting logic instead of reusing it.
  3. Submission.re_run() copies skip the limit check when created, but then count toward the owner's quota afterwards. Re-Submit copies are excluded instead.
  4. unpacker_test_data.py uses the key max_submissions_per_person, but the unpackers read max_submissions. The tests only pass because both defaults are 100.

Issues this PR resolves

No existing issue. Requested by the organizers of EEG/EMG Challenge 2026.

A checklist for hand testing

  • Phase editor → Advanced: "Max Submissions Scope" defaults to "Per participant". Phases imported from a bundle without the key are participant too.
  • Set a phase to "Per organization (team)" with max per person = 2, save, reopen: the value persists. GET /api/phases/<id>/ returns "max_submissions_scope": "organization".
  • Organization-scoped phase with a cap of 2, and a PARTICIPANT and a MEMBER of one org: one tagged and one untagged submission. Both badges show "2 out of 2", and a 3rd attempt is rejected with the team message.
  • Max per day = 1: after one team submission today, the other member gets the "for today" message.
  • A user who is only invited to the org is limited individually and doesn't use the team's quota.
  • A user in two orgs is blocked when either is full, and the message names that org.
  • Bundle with max_submissions_scope: organization imports correctly. An invalid value (e.g. team) fails the upload.
  • Export (Dump) includes max_submissions_scope in competition.yaml.

The unticked items are covered by unit tests except export.

Tests run on the docker compose stack with .env_circleci, as in CircleCI:

  • py.test src/: 455 passed, 2 skipped, 0 failed, including the 9 new tests
  • flake8 src/: clean
  • makemigrations --check --dry-run: no changes

New tests: competitions/tests/test_submissions.py::TeamMaxSubmissionsTests (shared total across tagged and untagged submissions, daily cap, default scope unchanged, no-team fallback, user in two teams, invited users, badge counts) and test_phase_max_submissions_scope_unpacking in test_v2_unpacker.py / test_v15_unpacker.py.

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

New Phase.max_submissions_scope field ('participant' default, 'organization').
With 'organization', max_submissions_per_person and max_submissions_per_day
are shared by all current (non-invited) members of each of the user's
organizations, counting tagged and untagged submissions. A user is blocked
when any of their teams is full; users without a team keep individual limits.

The field is exposed in the phase serializers, the v1/v2 YAML unpackers
(optional key), the competition YAML export, the phase editor and the docs.
The submission limit badges show team usage for organization-scoped phases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018Ukqzbbc6mAQxHhfWygTcN
@ObadaS
ObadaS changed the base branch from develop to feature/team-submission-quota November 3, 2026 09:53
@ObadaS
ObadaS merged commit dded6dd into codalab:feature/team-submission-quota Nov 3, 2026
@ObadaS ObadaS mentioned this pull request Nov 3, 2026
15 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants