Repository: Cloud-CV/EvalAI
Issue: Add Prize Money to Challenges
GitHub labels: hard-to-fix

frontend

backend

new-feature

good first issue

needs-more-work

python

javascript

GSoC-2023

### Description

Currently it is difficult to find know which challenges have prizes, and if yes, what are the first/second/thrid prizes, etc. This feature will help us understand which challenges on EvalAI have prizes. The idea is to add a new prize money section here:

<img width="1198" alt="Screenshot 2023-03-21 at 2 09 51 AM" src="https://user-images.githubusercontent.com/29076344/226530377-8ca88302-5536-4168-8cc6-8e93c687cff1.png">

There are several components to be designed here:
1. The idea is to create a new model `ChallengePrizes` with the following details:
```
- challenge_pk
- amount
- rank
```
2. The challenge prizes will be a new section in the challenge configuration. Example:
```yaml
prizes:
- rank: 1
   amount: "1000USD"
- rank: 2
   amount: "500USD"
```
3. This will also require you to add changes to the [challenge validation script](https://github.com/Cloud-CV/EvalAI/blob/19130726790e4cb79b0d2e8603dd6817b16dba69/apps/challenges/challenge_config_utils.py#L223) to ensure people put appropriate values for prizes.
4. Add a new attribute `has_prizes` in the Challenge model.
5. You will also need to modify the `create_or_update_github_challenge` function to update the challenge and the entries.
7. Display the prizes for the challenge if the challenge has prizes. This will require you to modify the frontend.

### Pre-requisites/Learnings
This issue essentially requires background on a few things:
- An understanding of the [challenge configuration](https://evalai.readthedocs.io/en/latest/configuration.html).
- A deep understanding of [EvalAI challenges](https://evalai.readthedocs.io/en/latest/host_challenge.html).
- An understanding of [our frontend](https://github.com/Cloud-CV/EvalAI/tree/master/frontend).
- How the [challenge validation](https://github.com/Cloud-CV/EvalAI/blob/19130726790e4cb79b0d2e8603dd6817b16dba69/apps/challenges/challenge_config_utils.py#L223) works.
- How [GitHub Challenge Creation](https://github.com/Cloud-CV/EvalAI/blob/fbfc7f04cf8570704fd41808c0c5f5cfed518505/apps/challenges/views.py#L3298) works.

### How to Approach
- You can start by setting up EvalAI locally. Set up the dev version locally (preferred) using the steps [here](https://github.com/Cloud-CV/EvalAI/tree/master#installation-instructions).
- Add the new models, the new attribute to the backend.
- Update the challenge configuration, the validation and the create/update method to handle this.
- Play around with the the frontend, and create a PR. Please add screenshots of the changes.
- Reach out to us regarding any issues that you face or if you need any help with understanding any of the above.

Hi @gchhablani 
Please assign me this issue.

@gchhablani What's difference between 'prize_amount' and 'amount' in model?

@b9aurav My bad, they are the same thing.

@gchhablani hey i would also like to work on this issue? can i start working on this as you have assigned this one already ?


@ADITYA97-CODER Can you please take up one of the other issues?

@gchhablani sure . Can you assign me "contacting host using a form issue"
Also i am getting an error while setting up locally
"failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed"
Can you help?

@gchhablani I've done my coding part, Now I am struggling in hosting a challenge locally to test it.
According to [docs](https://evalai.readthedocs.io/en/latest/host_challenge.html), I tried `"evalai_host_url": "https://staging.eval.ai"` and `"evalai_host_url": "127.0.0.1:8888"`. But failed.

Workflow error log for `https://staging.eval.ai`
`File "github/challenge_processing_script.py", line 74, in <module>
    response.raise_for_status()
  File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://staging.eval.ai/api/challenges/challenge/challenge_host_team/1/validate_challenge_config/`

Workflow error log for '127.0.0.1:8888'
`Following errors occurred while validating the challenge config: HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url: /api/challenges/challenge/challenge_host_team/1/validate_challenge_config/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9e197adb50>: Failed to establish a new connection: [Errno 111] Connection refused'))`

I am guessing, there's another way to host challenge locally (For testing purpose).

> @gchhablani I've done my coding part, Now I am struggling in hosting a challenge locally to test it. According to [docs](https://evalai.readthedocs.io/en/latest/host_challenge.html), I tried `"evalai_host_url": "https://staging.eval.ai"` and `"evalai_host_url": "127.0.0.1:8888"`. But failed.
> 
> Workflow error log for `https://staging.eval.ai` `File "github/challenge_processing_script.py", line 74, in <module> response.raise_for_status() File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://staging.eval.ai/api/challenges/challenge/challenge_host_team/1/validate_challenge_config/`
> 
> Workflow error log for '127.0.0.1:8888' `Following errors occurred while validating the challenge config: HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url: /api/challenges/challenge/challenge_host_team/1/validate_challenge_config/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9e197adb50>: Failed to establish a new connection: [Errno 111] Connection refused'))`
> 
> I am guessing, there's another way to host challenge locally (For testing purpose).

@b9aurav I had the same problem and I fixed by creating a script to test the challenges locally you can refer to my pull request [here](https://github.com/Cloud-CV/EvalAI-Starters/pull/71) It include script along with the documentation. It will solve your issue

> > @gchhablani I've done my coding part, Now I am struggling in hosting a challenge locally to test it. According to [docs](https://evalai.readthedocs.io/en/latest/host_challenge.html), I tried `"evalai_host_url": "https://staging.eval.ai"` and `"evalai_host_url": "127.0.0.1:8888"`. But failed.
> > Workflow error log for `https://staging.eval.ai` `File "github/challenge_processing_script.py", line 74, in <module> response.raise_for_status() File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://staging.eval.ai/api/challenges/challenge/challenge_host_team/1/validate_challenge_config/`
> > Workflow error log for '127.0.0.1:8888' `Following errors occurred while validating the challenge config: HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url: /api/challenges/challenge/challenge_host_team/1/validate_challenge_config/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9e197adb50>: Failed to establish a new connection: [Errno 111] Connection refused'))`
> > I am guessing, there's another way to host challenge locally (For testing purpose).
> 
> @b9aurav I had the same problem and I fixed by creating a script to test the challenges locally you can refer to my pull request [here](https://github.com/Cloud-CV/EvalAI-Starters/pull/71) It include script along with the documentation. It will solve your issue

@AyushR1 Thanks, I'll definitely give it try

@gchhablani It seems like my pull request #3906 build failed due to test case failure, Do I need to add test cases along with my other commits?

@gchhablani please assign me.