Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	
		Abhishek Thakur
		
	commited on
		
		
					Commit 
							
							Β·
						
						5839973
	
1
								Parent(s):
							
							cba3938
								
packageify
Browse files- .gitignore +1 -0
- Dockerfile +14 -5
- LICENSE +202 -0
- Overview.py +0 -20
- __init__.py β competitions/__init__.py +1 -0
- app.py β competitions/app.py +37 -50
- config.py β competitions/config.py +1 -0
- utils.py β competitions/utils.py +2 -3
- pages/1_π₯_Submissions.py +0 -142
- pages/2_π_Leaderboard.py +0 -28
- requirements.txt +2 -1
- setup.cfg +16 -0
- setup.py +60 -0
    	
        .gitignore
    CHANGED
    
    | @@ -2,6 +2,7 @@ | |
| 2 | 
             
            .DS_Store
         | 
| 3 | 
             
            .vscode/
         | 
| 4 | 
             
            .vim/
         | 
|  | |
| 5 |  | 
| 6 | 
             
            # Byte-compiled / optimized / DLL files
         | 
| 7 | 
             
            __pycache__/
         | 
|  | |
| 2 | 
             
            .DS_Store
         | 
| 3 | 
             
            .vscode/
         | 
| 4 | 
             
            .vim/
         | 
| 5 | 
            +
            flagged/
         | 
| 6 |  | 
| 7 | 
             
            # Byte-compiled / optimized / DLL files
         | 
| 8 | 
             
            __pycache__/
         | 
    	
        Dockerfile
    CHANGED
    
    | @@ -1,5 +1,8 @@ | |
| 1 | 
             
            FROM python:3.8.9
         | 
| 2 |  | 
|  | |
|  | |
|  | |
| 3 | 
             
            RUN pip install pip==22.3.1
         | 
| 4 |  | 
| 5 | 
             
            WORKDIR /app
         | 
| @@ -9,6 +12,15 @@ RUN chown -R 1000:1000 /app | |
| 9 | 
             
            USER 1000
         | 
| 10 | 
             
            ENV HOME=/app
         | 
| 11 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 12 | 
             
            RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
         | 
| 13 | 
             
                && sh Miniconda3-latest-Linux-x86_64.sh -b -p /app/miniconda \
         | 
| 14 | 
             
                && rm -f Miniconda3-latest-Linux-x86_64.sh
         | 
| @@ -16,6 +28,7 @@ ENV PATH /app/miniconda/bin:$PATH | |
| 16 |  | 
| 17 | 
             
            RUN conda create -p /app/env -y python=3.8
         | 
| 18 |  | 
|  | |
| 19 | 
             
            SHELL ["conda", "run","--no-capture-output", "-p","/app/env", "/bin/bash", "-c"]
         | 
| 20 |  | 
| 21 | 
             
            COPY --chown=1000:1000 requirements.txt /app/requirements.txt
         | 
| @@ -24,8 +37,4 @@ RUN pip install -r requirements.txt | |
| 24 | 
             
            COPY --chown=1000:1000 *.py /app/
         | 
| 25 | 
             
            COPY --chown=1000:1000 pages/ /app/pages/
         | 
| 26 |  | 
| 27 | 
            -
            CMD  | 
| 28 | 
            -
                --server.headless true \
         | 
| 29 | 
            -
                --server.enableCORS false \
         | 
| 30 | 
            -
                --server.enableXsrfProtection false \
         | 
| 31 | 
            -
                --server.fileWatcherType none
         | 
|  | |
| 1 | 
             
            FROM python:3.8.9
         | 
| 2 |  | 
| 3 | 
            +
            ENV DEBIAN_FRONTEND=noninteractive \
         | 
| 4 | 
            +
                TZ=Europe/Paris
         | 
| 5 | 
            +
             | 
| 6 | 
             
            RUN pip install pip==22.3.1
         | 
| 7 |  | 
| 8 | 
             
            WORKDIR /app
         | 
|  | |
| 12 | 
             
            USER 1000
         | 
| 13 | 
             
            ENV HOME=/app
         | 
| 14 |  | 
| 15 | 
            +
            ENV PYTHONPATH=$HOME/app \
         | 
| 16 | 
            +
                PYTHONUNBUFFERED=1 \
         | 
| 17 | 
            +
                GRADIO_ALLOW_FLAGGING=never \
         | 
| 18 | 
            +
                GRADIO_NUM_PORTS=1 \
         | 
| 19 | 
            +
                GRADIO_SERVER_NAME=0.0.0.0 \
         | 
| 20 | 
            +
                GRADIO_THEME=huggingface \
         | 
| 21 | 
            +
                SYSTEM=spaces
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             | 
| 24 | 
             
            RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
         | 
| 25 | 
             
                && sh Miniconda3-latest-Linux-x86_64.sh -b -p /app/miniconda \
         | 
| 26 | 
             
                && rm -f Miniconda3-latest-Linux-x86_64.sh
         | 
|  | |
| 28 |  | 
| 29 | 
             
            RUN conda create -p /app/env -y python=3.8
         | 
| 30 |  | 
| 31 | 
            +
             | 
| 32 | 
             
            SHELL ["conda", "run","--no-capture-output", "-p","/app/env", "/bin/bash", "-c"]
         | 
| 33 |  | 
| 34 | 
             
            COPY --chown=1000:1000 requirements.txt /app/requirements.txt
         | 
|  | |
| 37 | 
             
            COPY --chown=1000:1000 *.py /app/
         | 
| 38 | 
             
            COPY --chown=1000:1000 pages/ /app/pages/
         | 
| 39 |  | 
| 40 | 
            +
            CMD python app.py
         | 
|  | |
|  | |
|  | |
|  | 
    	
        LICENSE
    ADDED
    
    | @@ -0,0 +1,202 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
             | 
| 2 | 
            +
                                             Apache License
         | 
| 3 | 
            +
                                       Version 2.0, January 2004
         | 
| 4 | 
            +
                                    http://www.apache.org/licenses/
         | 
| 5 | 
            +
             | 
| 6 | 
            +
               TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
         | 
| 7 | 
            +
             | 
| 8 | 
            +
               1. Definitions.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  "License" shall mean the terms and conditions for use, reproduction,
         | 
| 11 | 
            +
                  and distribution as defined by Sections 1 through 9 of this document.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  "Licensor" shall mean the copyright owner or entity authorized by
         | 
| 14 | 
            +
                  the copyright owner that is granting the License.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  "Legal Entity" shall mean the union of the acting entity and all
         | 
| 17 | 
            +
                  other entities that control, are controlled by, or are under common
         | 
| 18 | 
            +
                  control with that entity. For the purposes of this definition,
         | 
| 19 | 
            +
                  "control" means (i) the power, direct or indirect, to cause the
         | 
| 20 | 
            +
                  direction or management of such entity, whether by contract or
         | 
| 21 | 
            +
                  otherwise, or (ii) ownership of fifty percent (50%) or more of the
         | 
| 22 | 
            +
                  outstanding shares, or (iii) beneficial ownership of such entity.
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  "You" (or "Your") shall mean an individual or Legal Entity
         | 
| 25 | 
            +
                  exercising permissions granted by this License.
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  "Source" form shall mean the preferred form for making modifications,
         | 
| 28 | 
            +
                  including but not limited to software source code, documentation
         | 
| 29 | 
            +
                  source, and configuration files.
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  "Object" form shall mean any form resulting from mechanical
         | 
| 32 | 
            +
                  transformation or translation of a Source form, including but
         | 
| 33 | 
            +
                  not limited to compiled object code, generated documentation,
         | 
| 34 | 
            +
                  and conversions to other media types.
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  "Work" shall mean the work of authorship, whether in Source or
         | 
| 37 | 
            +
                  Object form, made available under the License, as indicated by a
         | 
| 38 | 
            +
                  copyright notice that is included in or attached to the work
         | 
| 39 | 
            +
                  (an example is provided in the Appendix below).
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  "Derivative Works" shall mean any work, whether in Source or Object
         | 
| 42 | 
            +
                  form, that is based on (or derived from) the Work and for which the
         | 
| 43 | 
            +
                  editorial revisions, annotations, elaborations, or other modifications
         | 
| 44 | 
            +
                  represent, as a whole, an original work of authorship. For the purposes
         | 
| 45 | 
            +
                  of this License, Derivative Works shall not include works that remain
         | 
| 46 | 
            +
                  separable from, or merely link (or bind by name) to the interfaces of,
         | 
| 47 | 
            +
                  the Work and Derivative Works thereof.
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  "Contribution" shall mean any work of authorship, including
         | 
| 50 | 
            +
                  the original version of the Work and any modifications or additions
         | 
| 51 | 
            +
                  to that Work or Derivative Works thereof, that is intentionally
         | 
| 52 | 
            +
                  submitted to Licensor for inclusion in the Work by the copyright owner
         | 
| 53 | 
            +
                  or by an individual or Legal Entity authorized to submit on behalf of
         | 
| 54 | 
            +
                  the copyright owner. For the purposes of this definition, "submitted"
         | 
| 55 | 
            +
                  means any form of electronic, verbal, or written communication sent
         | 
| 56 | 
            +
                  to the Licensor or its representatives, including but not limited to
         | 
| 57 | 
            +
                  communication on electronic mailing lists, source code control systems,
         | 
| 58 | 
            +
                  and issue tracking systems that are managed by, or on behalf of, the
         | 
| 59 | 
            +
                  Licensor for the purpose of discussing and improving the Work, but
         | 
| 60 | 
            +
                  excluding communication that is conspicuously marked or otherwise
         | 
| 61 | 
            +
                  designated in writing by the copyright owner as "Not a Contribution."
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  "Contributor" shall mean Licensor and any individual or Legal Entity
         | 
| 64 | 
            +
                  on behalf of whom a Contribution has been received by Licensor and
         | 
| 65 | 
            +
                  subsequently incorporated within the Work.
         | 
| 66 | 
            +
             | 
| 67 | 
            +
               2. Grant of Copyright License. Subject to the terms and conditions of
         | 
| 68 | 
            +
                  this License, each Contributor hereby grants to You a perpetual,
         | 
| 69 | 
            +
                  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
         | 
| 70 | 
            +
                  copyright license to reproduce, prepare Derivative Works of,
         | 
| 71 | 
            +
                  publicly display, publicly perform, sublicense, and distribute the
         | 
| 72 | 
            +
                  Work and such Derivative Works in Source or Object form.
         | 
| 73 | 
            +
             | 
| 74 | 
            +
               3. Grant of Patent License. Subject to the terms and conditions of
         | 
| 75 | 
            +
                  this License, each Contributor hereby grants to You a perpetual,
         | 
| 76 | 
            +
                  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
         | 
| 77 | 
            +
                  (except as stated in this section) patent license to make, have made,
         | 
| 78 | 
            +
                  use, offer to sell, sell, import, and otherwise transfer the Work,
         | 
| 79 | 
            +
                  where such license applies only to those patent claims licensable
         | 
| 80 | 
            +
                  by such Contributor that are necessarily infringed by their
         | 
| 81 | 
            +
                  Contribution(s) alone or by combination of their Contribution(s)
         | 
| 82 | 
            +
                  with the Work to which such Contribution(s) was submitted. If You
         | 
| 83 | 
            +
                  institute patent litigation against any entity (including a
         | 
| 84 | 
            +
                  cross-claim or counterclaim in a lawsuit) alleging that the Work
         | 
| 85 | 
            +
                  or a Contribution incorporated within the Work constitutes direct
         | 
| 86 | 
            +
                  or contributory patent infringement, then any patent licenses
         | 
| 87 | 
            +
                  granted to You under this License for that Work shall terminate
         | 
| 88 | 
            +
                  as of the date such litigation is filed.
         | 
| 89 | 
            +
             | 
| 90 | 
            +
               4. Redistribution. You may reproduce and distribute copies of the
         | 
| 91 | 
            +
                  Work or Derivative Works thereof in any medium, with or without
         | 
| 92 | 
            +
                  modifications, and in Source or Object form, provided that You
         | 
| 93 | 
            +
                  meet the following conditions:
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  (a) You must give any other recipients of the Work or
         | 
| 96 | 
            +
                      Derivative Works a copy of this License; and
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  (b) You must cause any modified files to carry prominent notices
         | 
| 99 | 
            +
                      stating that You changed the files; and
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  (c) You must retain, in the Source form of any Derivative Works
         | 
| 102 | 
            +
                      that You distribute, all copyright, patent, trademark, and
         | 
| 103 | 
            +
                      attribution notices from the Source form of the Work,
         | 
| 104 | 
            +
                      excluding those notices that do not pertain to any part of
         | 
| 105 | 
            +
                      the Derivative Works; and
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                  (d) If the Work includes a "NOTICE" text file as part of its
         | 
| 108 | 
            +
                      distribution, then any Derivative Works that You distribute must
         | 
| 109 | 
            +
                      include a readable copy of the attribution notices contained
         | 
| 110 | 
            +
                      within such NOTICE file, excluding those notices that do not
         | 
| 111 | 
            +
                      pertain to any part of the Derivative Works, in at least one
         | 
| 112 | 
            +
                      of the following places: within a NOTICE text file distributed
         | 
| 113 | 
            +
                      as part of the Derivative Works; within the Source form or
         | 
| 114 | 
            +
                      documentation, if provided along with the Derivative Works; or,
         | 
| 115 | 
            +
                      within a display generated by the Derivative Works, if and
         | 
| 116 | 
            +
                      wherever such third-party notices normally appear. The contents
         | 
| 117 | 
            +
                      of the NOTICE file are for informational purposes only and
         | 
| 118 | 
            +
                      do not modify the License. You may add Your own attribution
         | 
| 119 | 
            +
                      notices within Derivative Works that You distribute, alongside
         | 
| 120 | 
            +
                      or as an addendum to the NOTICE text from the Work, provided
         | 
| 121 | 
            +
                      that such additional attribution notices cannot be construed
         | 
| 122 | 
            +
                      as modifying the License.
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  You may add Your own copyright statement to Your modifications and
         | 
| 125 | 
            +
                  may provide additional or different license terms and conditions
         | 
| 126 | 
            +
                  for use, reproduction, or distribution of Your modifications, or
         | 
| 127 | 
            +
                  for any such Derivative Works as a whole, provided Your use,
         | 
| 128 | 
            +
                  reproduction, and distribution of the Work otherwise complies with
         | 
| 129 | 
            +
                  the conditions stated in this License.
         | 
| 130 | 
            +
             | 
| 131 | 
            +
               5. Submission of Contributions. Unless You explicitly state otherwise,
         | 
| 132 | 
            +
                  any Contribution intentionally submitted for inclusion in the Work
         | 
| 133 | 
            +
                  by You to the Licensor shall be under the terms and conditions of
         | 
| 134 | 
            +
                  this License, without any additional terms or conditions.
         | 
| 135 | 
            +
                  Notwithstanding the above, nothing herein shall supersede or modify
         | 
| 136 | 
            +
                  the terms of any separate license agreement you may have executed
         | 
| 137 | 
            +
                  with Licensor regarding such Contributions.
         | 
| 138 | 
            +
             | 
| 139 | 
            +
               6. Trademarks. This License does not grant permission to use the trade
         | 
| 140 | 
            +
                  names, trademarks, service marks, or product names of the Licensor,
         | 
| 141 | 
            +
                  except as required for reasonable and customary use in describing the
         | 
| 142 | 
            +
                  origin of the Work and reproducing the content of the NOTICE file.
         | 
| 143 | 
            +
             | 
| 144 | 
            +
               7. Disclaimer of Warranty. Unless required by applicable law or
         | 
| 145 | 
            +
                  agreed to in writing, Licensor provides the Work (and each
         | 
| 146 | 
            +
                  Contributor provides its Contributions) on an "AS IS" BASIS,
         | 
| 147 | 
            +
                  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
         | 
| 148 | 
            +
                  implied, including, without limitation, any warranties or conditions
         | 
| 149 | 
            +
                  of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
         | 
| 150 | 
            +
                  PARTICULAR PURPOSE. You are solely responsible for determining the
         | 
| 151 | 
            +
                  appropriateness of using or redistributing the Work and assume any
         | 
| 152 | 
            +
                  risks associated with Your exercise of permissions under this License.
         | 
| 153 | 
            +
             | 
| 154 | 
            +
               8. Limitation of Liability. In no event and under no legal theory,
         | 
| 155 | 
            +
                  whether in tort (including negligence), contract, or otherwise,
         | 
| 156 | 
            +
                  unless required by applicable law (such as deliberate and grossly
         | 
| 157 | 
            +
                  negligent acts) or agreed to in writing, shall any Contributor be
         | 
| 158 | 
            +
                  liable to You for damages, including any direct, indirect, special,
         | 
| 159 | 
            +
                  incidental, or consequential damages of any character arising as a
         | 
| 160 | 
            +
                  result of this License or out of the use or inability to use the
         | 
| 161 | 
            +
                  Work (including but not limited to damages for loss of goodwill,
         | 
| 162 | 
            +
                  work stoppage, computer failure or malfunction, or any and all
         | 
| 163 | 
            +
                  other commercial damages or losses), even if such Contributor
         | 
| 164 | 
            +
                  has been advised of the possibility of such damages.
         | 
| 165 | 
            +
             | 
| 166 | 
            +
               9. Accepting Warranty or Additional Liability. While redistributing
         | 
| 167 | 
            +
                  the Work or Derivative Works thereof, You may choose to offer,
         | 
| 168 | 
            +
                  and charge a fee for, acceptance of support, warranty, indemnity,
         | 
| 169 | 
            +
                  or other liability obligations and/or rights consistent with this
         | 
| 170 | 
            +
                  License. However, in accepting such obligations, You may act only
         | 
| 171 | 
            +
                  on Your own behalf and on Your sole responsibility, not on behalf
         | 
| 172 | 
            +
                  of any other Contributor, and only if You agree to indemnify,
         | 
| 173 | 
            +
                  defend, and hold each Contributor harmless for any liability
         | 
| 174 | 
            +
                  incurred by, or claims asserted against, such Contributor by reason
         | 
| 175 | 
            +
                  of your accepting any such warranty or additional liability.
         | 
| 176 | 
            +
             | 
| 177 | 
            +
               END OF TERMS AND CONDITIONS
         | 
| 178 | 
            +
             | 
| 179 | 
            +
               APPENDIX: How to apply the Apache License to your work.
         | 
| 180 | 
            +
             | 
| 181 | 
            +
                  To apply the Apache License to your work, attach the following
         | 
| 182 | 
            +
                  boilerplate notice, with the fields enclosed by brackets "[]"
         | 
| 183 | 
            +
                  replaced with your own identifying information. (Don't include
         | 
| 184 | 
            +
                  the brackets!)  The text should be enclosed in the appropriate
         | 
| 185 | 
            +
                  comment syntax for the file format. We also recommend that a
         | 
| 186 | 
            +
                  file or class name and description of purpose be included on the
         | 
| 187 | 
            +
                  same "printed page" as the copyright notice for easier
         | 
| 188 | 
            +
                  identification within third-party archives.
         | 
| 189 | 
            +
             | 
| 190 | 
            +
               Copyright [2022] [Hugging Face Inc.]
         | 
| 191 | 
            +
             | 
| 192 | 
            +
               Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 193 | 
            +
               you may not use this file except in compliance with the License.
         | 
| 194 | 
            +
               You may obtain a copy of the License at
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                   http://www.apache.org/licenses/LICENSE-2.0
         | 
| 197 | 
            +
             | 
| 198 | 
            +
               Unless required by applicable law or agreed to in writing, software
         | 
| 199 | 
            +
               distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 200 | 
            +
               WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 201 | 
            +
               See the License for the specific language governing permissions and
         | 
| 202 | 
            +
               limitations under the License.
         | 
    	
        Overview.py
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            import streamlit as st
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            import config
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            st.set_page_config(
         | 
| 6 | 
            -
                page_title="Overview",
         | 
| 7 | 
            -
                page_icon="π€",
         | 
| 8 | 
            -
            )
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            st.write(f"# Welcome to {config.competition_info.competition_name}! π")
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            st.markdown(
         | 
| 13 | 
            -
                f"""
         | 
| 14 | 
            -
                {config.competition_info.competition_description}
         | 
| 15 | 
            -
            """
         | 
| 16 | 
            -
            )
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            st.markdown("## Dataset")
         | 
| 19 | 
            -
            # st.sidebar.header("Dataset")
         | 
| 20 | 
            -
            st.write(f"""{config.competition_info.dataset_description}""")
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
    	
        __init__.py β competitions/__init__.py
    RENAMED
    
    | @@ -1,3 +1,4 @@ | |
| 1 | 
             
            import config
         | 
| 2 |  | 
|  | |
| 3 | 
             
            __version__ = "0.0.1"
         | 
|  | |
| 1 | 
             
            import config
         | 
| 2 |  | 
| 3 | 
            +
             | 
| 4 | 
             
            __version__ = "0.0.1"
         | 
    	
        app.py β competitions/app.py
    RENAMED
    
    | @@ -2,14 +2,13 @@ import uuid | |
| 2 | 
             
            from datetime import datetime
         | 
| 3 | 
             
            from functools import partial
         | 
| 4 |  | 
|  | |
| 5 | 
             
            import gradio as gr
         | 
| 6 | 
            -
            import numpy as np
         | 
| 7 | 
             
            import pandas as pd
         | 
|  | |
| 8 | 
             
            from huggingface_hub import HfApi
         | 
| 9 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 10 |  | 
| 11 | 
            -
            import config
         | 
| 12 | 
            -
            import utils
         | 
| 13 |  | 
| 14 | 
             
            SUBMISSION_TEXT = f"""You can make upto {config.competition_info.submission_limit} submissions per day.
         | 
| 15 | 
             
            The test data has been divided into public and private splits.
         | 
| @@ -32,7 +31,7 @@ def get_subs(user_info, private=False): | |
| 32 | 
             
                    user_submissions = utils.fetch_submissions(user_id)
         | 
| 33 | 
             
                except EntryNotFoundError:
         | 
| 34 | 
             
                    return_value = "No submissions found"
         | 
| 35 | 
            -
                    return [gr. | 
| 36 | 
             
                submissions_df = pd.DataFrame(user_submissions)
         | 
| 37 | 
             
                if not private:
         | 
| 38 | 
             
                    submissions_df = submissions_df.drop(columns=["private_score"])
         | 
| @@ -43,20 +42,19 @@ def get_subs(user_info, private=False): | |
| 43 | 
             
                    submissions_df = submissions_df[
         | 
| 44 | 
             
                        ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
         | 
| 45 | 
             
                    ]
         | 
| 46 | 
            -
                return [gr. | 
| 47 |  | 
| 48 |  | 
| 49 | 
             
            def my_submissions(user_token):
         | 
| 50 | 
             
                if user_token != "":
         | 
| 51 | 
             
                    user_info = utils.user_authentication(token=user_token)
         | 
| 52 | 
            -
                    print(user_info)
         | 
| 53 | 
             
                    if "error" in user_info:
         | 
| 54 | 
             
                        return_value = "Invalid token"
         | 
| 55 | 
            -
                        return [gr. | 
| 56 |  | 
| 57 | 
             
                    if user_info["emailVerified"] is False:
         | 
| 58 | 
             
                        return_value = "Please verify your email on Hugging Face Hub"
         | 
| 59 | 
            -
                        return [gr. | 
| 60 |  | 
| 61 | 
             
                    current_date_time = datetime.now()
         | 
| 62 | 
             
                    private = False
         | 
| @@ -64,41 +62,34 @@ def my_submissions(user_token): | |
| 64 | 
             
                        private = True
         | 
| 65 | 
             
                    subs = get_subs(user_info, private=private)
         | 
| 66 | 
             
                    return subs
         | 
| 67 | 
            -
                return [gr. | 
| 68 |  | 
| 69 |  | 
| 70 | 
            -
            def new_submission(user_token):
         | 
| 71 | 
            -
                 | 
| 72 | 
            -
                uploaded_file = st.file_uploader("Choose a file")
         | 
| 73 | 
            -
                submit_button = st.button("Submit")
         | 
| 74 | 
            -
                if uploaded_file is not None and user_token != "" and submit_button:
         | 
| 75 | 
             
                    # verify token
         | 
| 76 | 
             
                    user_info = utils.user_authentication(token=user_token)
         | 
| 77 | 
             
                    if "error" in user_info:
         | 
| 78 | 
            -
                         | 
| 79 | 
            -
                        return
         | 
| 80 |  | 
| 81 | 
             
                    if user_info["emailVerified"] is False:
         | 
| 82 | 
            -
                         | 
| 83 | 
            -
                        return
         | 
| 84 |  | 
| 85 | 
             
                    # check if user can submit to the competition
         | 
| 86 | 
             
                    if utils.check_user_submission_limit(user_info) is False:
         | 
| 87 | 
            -
                         | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
                    bytes_data = uploaded_file.getvalue()
         | 
| 91 | 
             
                    # verify file is valid
         | 
| 92 | 
             
                    if not utils.verify_submission(bytes_data):
         | 
| 93 | 
            -
                         | 
| 94 | 
            -
                        gr.Markdown(SUBMISSION_ERROR)
         | 
| 95 | 
             
                        # write a horizontal html line
         | 
| 96 | 
            -
                        gr.Markdown("<hr/>", unsafe_allow_html=True)
         | 
| 97 | 
             
                    else:
         | 
| 98 | 
            -
                        # TODO: add spinner here
         | 
| 99 | 
             
                        user_id = user_info["id"]
         | 
| 100 | 
             
                        submission_id = str(uuid.uuid4())
         | 
| 101 | 
            -
                        file_extension = uploaded_file. | 
| 102 | 
             
                        # upload file to hf hub
         | 
| 103 | 
             
                        api = HfApi()
         | 
| 104 | 
             
                        api.upload_file(
         | 
| @@ -121,10 +112,9 @@ def new_submission(user_token): | |
| 121 | 
             
                            submission_dataset=user_id,
         | 
| 122 | 
             
                            model="generic_competition",
         | 
| 123 | 
             
                        )
         | 
| 124 | 
            -
                     | 
| 125 | 
            -
                     | 
| 126 | 
            -
             | 
| 127 | 
            -
                    )
         | 
| 128 |  | 
| 129 |  | 
| 130 | 
             
            with gr.Blocks() as demo:
         | 
| @@ -137,35 +127,32 @@ with gr.Blocks() as demo: | |
| 137 | 
             
                    gr.Markdown(f"{config.competition_info.dataset_description}")
         | 
| 138 |  | 
| 139 | 
             
                with gr.Tab("Public Leaderboard"):
         | 
| 140 | 
            -
                     | 
| 141 | 
            -
                    gr. | 
|  | |
|  | |
|  | |
|  | |
| 142 | 
             
                with gr.Tab("Private Leaderboard"):
         | 
| 143 | 
             
                    current_date_time = datetime.now()
         | 
| 144 | 
             
                    if current_date_time >= config.competition_info.end_date:
         | 
| 145 | 
             
                        lb = utils.fetch_leaderboard(private=True)
         | 
| 146 | 
            -
                        gr.Markdown(lb | 
| 147 | 
             
                    else:
         | 
| 148 | 
             
                        gr.Markdown("Private Leaderboard will be available after the competition ends")
         | 
| 149 | 
             
                with gr.Tab("New Submission"):
         | 
| 150 | 
            -
                     | 
| 151 | 
            -
                     | 
| 152 | 
            -
                     | 
|  | |
|  | |
|  | |
|  | |
| 153 | 
             
                with gr.Tab("My Submissions"):
         | 
| 154 | 
             
                    gr.Markdown(SUBMISSION_LIMIT_TEXT)
         | 
| 155 | 
             
                    user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
         | 
| 156 | 
            -
                    output_text = gr. | 
| 157 | 
            -
                     | 
| 158 | 
            -
                        columns=[
         | 
| 159 | 
            -
                            "date",
         | 
| 160 | 
            -
                            "submission_id",
         | 
| 161 | 
            -
                            "public_score",
         | 
| 162 | 
            -
                            "private_score",
         | 
| 163 | 
            -
                            "submission_comment",
         | 
| 164 | 
            -
                            "selected",
         | 
| 165 | 
            -
                            "status",
         | 
| 166 | 
            -
                        ]
         | 
| 167 | 
            -
                    )
         | 
| 168 | 
            -
                    output_df = gr.Dataframe(visible=False, value=empty_df)
         | 
| 169 | 
             
                    my_subs_button = gr.Button("Fetch Submissions")
         | 
| 170 | 
             
                    my_subs_button.click(fn=my_submissions, inputs=[user_token], outputs=[output_text, output_df])
         | 
| 171 |  | 
|  | |
| 2 | 
             
            from datetime import datetime
         | 
| 3 | 
             
            from functools import partial
         | 
| 4 |  | 
| 5 | 
            +
            import config
         | 
| 6 | 
             
            import gradio as gr
         | 
|  | |
| 7 | 
             
            import pandas as pd
         | 
| 8 | 
            +
            import utils
         | 
| 9 | 
             
            from huggingface_hub import HfApi
         | 
| 10 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 11 |  | 
|  | |
|  | |
| 12 |  | 
| 13 | 
             
            SUBMISSION_TEXT = f"""You can make upto {config.competition_info.submission_limit} submissions per day.
         | 
| 14 | 
             
            The test data has been divided into public and private splits.
         | 
|  | |
| 31 | 
             
                    user_submissions = utils.fetch_submissions(user_id)
         | 
| 32 | 
             
                except EntryNotFoundError:
         | 
| 33 | 
             
                    return_value = "No submissions found"
         | 
| 34 | 
            +
                    return [gr.Markdown.update(visible=True, value=return_value), gr.DataFrame.update(visible=False)]
         | 
| 35 | 
             
                submissions_df = pd.DataFrame(user_submissions)
         | 
| 36 | 
             
                if not private:
         | 
| 37 | 
             
                    submissions_df = submissions_df.drop(columns=["private_score"])
         | 
|  | |
| 42 | 
             
                    submissions_df = submissions_df[
         | 
| 43 | 
             
                        ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
         | 
| 44 | 
             
                    ]
         | 
| 45 | 
            +
                return [gr.Markdown.update(visible=False), gr.DataFrame.update(visible=True, value=submissions_df)]
         | 
| 46 |  | 
| 47 |  | 
| 48 | 
             
            def my_submissions(user_token):
         | 
| 49 | 
             
                if user_token != "":
         | 
| 50 | 
             
                    user_info = utils.user_authentication(token=user_token)
         | 
|  | |
| 51 | 
             
                    if "error" in user_info:
         | 
| 52 | 
             
                        return_value = "Invalid token"
         | 
| 53 | 
            +
                        return [gr.Markdown.update(visible=True, value=return_value), gr.DataFrame.update(visible=False)]
         | 
| 54 |  | 
| 55 | 
             
                    if user_info["emailVerified"] is False:
         | 
| 56 | 
             
                        return_value = "Please verify your email on Hugging Face Hub"
         | 
| 57 | 
            +
                        return [gr.Markdown.update(visible=True, value=return_value), gr.DataFrame.update(visible=False)]
         | 
| 58 |  | 
| 59 | 
             
                    current_date_time = datetime.now()
         | 
| 60 | 
             
                    private = False
         | 
|  | |
| 62 | 
             
                        private = True
         | 
| 63 | 
             
                    subs = get_subs(user_info, private=private)
         | 
| 64 | 
             
                    return subs
         | 
| 65 | 
            +
                return [gr.Markdown.update(visible=True, value="Invalid token"), gr.DataFrame.update(visible=False)]
         | 
| 66 |  | 
| 67 |  | 
| 68 | 
            +
            def new_submission(user_token, uploaded_file):
         | 
| 69 | 
            +
                if uploaded_file is not None and user_token != "":
         | 
|  | |
|  | |
|  | |
| 70 | 
             
                    # verify token
         | 
| 71 | 
             
                    user_info = utils.user_authentication(token=user_token)
         | 
| 72 | 
             
                    if "error" in user_info:
         | 
| 73 | 
            +
                        return "Invalid token"
         | 
|  | |
| 74 |  | 
| 75 | 
             
                    if user_info["emailVerified"] is False:
         | 
| 76 | 
            +
                        return "Please verify your email on Hugging Face Hub"
         | 
|  | |
| 77 |  | 
| 78 | 
             
                    # check if user can submit to the competition
         | 
| 79 | 
             
                    if utils.check_user_submission_limit(user_info) is False:
         | 
| 80 | 
            +
                        return "You have reached your submission limit for today"
         | 
| 81 | 
            +
                    with open(uploaded_file.name, "rb") as f:
         | 
| 82 | 
            +
                        bytes_data = f.read()
         | 
|  | |
| 83 | 
             
                    # verify file is valid
         | 
| 84 | 
             
                    if not utils.verify_submission(bytes_data):
         | 
| 85 | 
            +
                        return "Invalid submission"
         | 
| 86 | 
            +
                        # gr.Markdown(SUBMISSION_ERROR)
         | 
| 87 | 
             
                        # write a horizontal html line
         | 
| 88 | 
            +
                        # gr.Markdown("<hr/>", unsafe_allow_html=True)
         | 
| 89 | 
             
                    else:
         | 
|  | |
| 90 | 
             
                        user_id = user_info["id"]
         | 
| 91 | 
             
                        submission_id = str(uuid.uuid4())
         | 
| 92 | 
            +
                        file_extension = uploaded_file.orig_name.split(".")[-1]
         | 
| 93 | 
             
                        # upload file to hf hub
         | 
| 94 | 
             
                        api = HfApi()
         | 
| 95 | 
             
                        api.upload_file(
         | 
|  | |
| 112 | 
             
                            submission_dataset=user_id,
         | 
| 113 | 
             
                            model="generic_competition",
         | 
| 114 | 
             
                        )
         | 
| 115 | 
            +
                    return_text = f"Submission scheduled for evaluation. You have {config.competition_info.submission_limit - submissions_made} submissions left for today."
         | 
| 116 | 
            +
                    return return_text
         | 
| 117 | 
            +
                return "Error"
         | 
|  | |
| 118 |  | 
| 119 |  | 
| 120 | 
             
            with gr.Blocks() as demo:
         | 
|  | |
| 127 | 
             
                    gr.Markdown(f"{config.competition_info.dataset_description}")
         | 
| 128 |  | 
| 129 | 
             
                with gr.Tab("Public Leaderboard"):
         | 
| 130 | 
            +
                    output_markdown = gr.Markdown("")
         | 
| 131 | 
            +
                    fetch_lb = gr.Button("Fetch Leaderboard")
         | 
| 132 | 
            +
                    fetch_lb_partial = partial(utils.fetch_leaderboard, private=False)
         | 
| 133 | 
            +
                    fetch_lb.click(fn=fetch_lb_partial, outputs=[output_markdown])
         | 
| 134 | 
            +
                    # lb = utils.fetch_leaderboard(private=False)
         | 
| 135 | 
            +
                    # gr.Markdown(lb.to_markdown())
         | 
| 136 | 
             
                with gr.Tab("Private Leaderboard"):
         | 
| 137 | 
             
                    current_date_time = datetime.now()
         | 
| 138 | 
             
                    if current_date_time >= config.competition_info.end_date:
         | 
| 139 | 
             
                        lb = utils.fetch_leaderboard(private=True)
         | 
| 140 | 
            +
                        gr.Markdown(lb)
         | 
| 141 | 
             
                    else:
         | 
| 142 | 
             
                        gr.Markdown("Private Leaderboard will be available after the competition ends")
         | 
| 143 | 
             
                with gr.Tab("New Submission"):
         | 
| 144 | 
            +
                    gr.Markdown(SUBMISSION_TEXT)
         | 
| 145 | 
            +
                    user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
         | 
| 146 | 
            +
                    uploaded_file = gr.File()
         | 
| 147 | 
            +
                    output_text = gr.Markdown(visible=True, show_label=False)
         | 
| 148 | 
            +
                    new_sub_button = gr.Button("Upload Submission")
         | 
| 149 | 
            +
                    new_sub_button.click(fn=new_submission, inputs=[user_token, uploaded_file], outputs=[output_text])
         | 
| 150 | 
            +
             | 
| 151 | 
             
                with gr.Tab("My Submissions"):
         | 
| 152 | 
             
                    gr.Markdown(SUBMISSION_LIMIT_TEXT)
         | 
| 153 | 
             
                    user_token = gr.Textbox(max_lines=1, value="hf_XXX", label="Please enter your Hugging Face token")
         | 
| 154 | 
            +
                    output_text = gr.Markdown(visible=True, show_label=False)
         | 
| 155 | 
            +
                    output_df = gr.Dataframe(visible=False)
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 156 | 
             
                    my_subs_button = gr.Button("Fetch Submissions")
         | 
| 157 | 
             
                    my_subs_button.click(fn=my_submissions, inputs=[user_token], outputs=[output_text, output_df])
         | 
| 158 |  | 
    	
        config.py β competitions/config.py
    RENAMED
    
    | @@ -7,6 +7,7 @@ from dotenv import load_dotenv | |
| 7 | 
             
            from huggingface_hub import hf_hub_download
         | 
| 8 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 9 |  | 
|  | |
| 10 | 
             
            if Path(".env").is_file():
         | 
| 11 | 
             
                load_dotenv(".env")
         | 
| 12 |  | 
|  | |
| 7 | 
             
            from huggingface_hub import hf_hub_download
         | 
| 8 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 9 |  | 
| 10 | 
            +
             | 
| 11 | 
             
            if Path(".env").is_file():
         | 
| 12 | 
             
                load_dotenv(".env")
         | 
| 13 |  | 
    	
        utils.py β competitions/utils.py
    RENAMED
    
    | @@ -5,13 +5,12 @@ import json | |
| 5 | 
             
            import os
         | 
| 6 | 
             
            import time
         | 
| 7 |  | 
|  | |
| 8 | 
             
            import pandas as pd
         | 
| 9 | 
             
            import requests
         | 
| 10 | 
             
            from huggingface_hub import HfApi, hf_hub_download, snapshot_download
         | 
| 11 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 12 |  | 
| 13 | 
            -
            import config
         | 
| 14 | 
            -
             | 
| 15 |  | 
| 16 | 
             
            def get_auth_headers(token: str, prefix: str = "Bearer"):
         | 
| 17 | 
             
                return {"Authorization": f"{prefix} {token}"}
         | 
| @@ -303,4 +302,4 @@ def fetch_leaderboard(private=False): | |
| 303 | 
             
                    columns = ["rank", "name", "private_score", "submission_datetime"]
         | 
| 304 | 
             
                else:
         | 
| 305 | 
             
                    columns = ["rank", "name", "public_score", "submission_datetime"]
         | 
| 306 | 
            -
                return df[columns]
         | 
|  | |
| 5 | 
             
            import os
         | 
| 6 | 
             
            import time
         | 
| 7 |  | 
| 8 | 
            +
            import config
         | 
| 9 | 
             
            import pandas as pd
         | 
| 10 | 
             
            import requests
         | 
| 11 | 
             
            from huggingface_hub import HfApi, hf_hub_download, snapshot_download
         | 
| 12 | 
             
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 13 |  | 
|  | |
|  | |
| 14 |  | 
| 15 | 
             
            def get_auth_headers(token: str, prefix: str = "Bearer"):
         | 
| 16 | 
             
                return {"Authorization": f"{prefix} {token}"}
         | 
|  | |
| 302 | 
             
                    columns = ["rank", "name", "private_score", "submission_datetime"]
         | 
| 303 | 
             
                else:
         | 
| 304 | 
             
                    columns = ["rank", "name", "public_score", "submission_datetime"]
         | 
| 305 | 
            +
                return df[columns].to_markdown()
         | 
    	
        pages/1_π₯_Submissions.py
    DELETED
    
    | @@ -1,142 +0,0 @@ | |
| 1 | 
            -
            import uuid
         | 
| 2 | 
            -
            from datetime import datetime
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            import pandas as pd
         | 
| 5 | 
            -
            import streamlit as st
         | 
| 6 | 
            -
            from huggingface_hub import HfApi
         | 
| 7 | 
            -
            from huggingface_hub.utils._errors import EntryNotFoundError
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            import config
         | 
| 10 | 
            -
            import utils
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            SUBMISSION_TEXT = f"""You can make upto {config.competition_info.submission_limit} submissions per day.
         | 
| 13 | 
            -
            The test data has been divided into public and private splits.
         | 
| 14 | 
            -
            Your score on the public split will be shown on the leaderboard.
         | 
| 15 | 
            -
            Your final score will be based on your private split performance.
         | 
| 16 | 
            -
            The final rankings will be based on the private split performance.
         | 
| 17 | 
            -
            """
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            SUBMISSION_ERROR = """Submission is not in a proper format.
         | 
| 20 | 
            -
            Please check evaluation instructions for more details."""
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            SUBMISSION_LIMIT_TEXT = f"""You can select upto {config.competition_info.selection_limit}
         | 
| 23 | 
            -
             submissions for private leaderboard."""
         | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
            def get_subs(user_info, private=False):
         | 
| 27 | 
            -
                # get user submissions
         | 
| 28 | 
            -
                user_id = user_info["id"]
         | 
| 29 | 
            -
                try:
         | 
| 30 | 
            -
                    user_submissions = utils.fetch_submissions(user_id)
         | 
| 31 | 
            -
                except EntryNotFoundError:
         | 
| 32 | 
            -
                    st.error("No submissions found")
         | 
| 33 | 
            -
                    return
         | 
| 34 | 
            -
                submissions_df = pd.DataFrame(user_submissions)
         | 
| 35 | 
            -
                if not private:
         | 
| 36 | 
            -
                    submissions_df = submissions_df.drop(columns=["private_score"])
         | 
| 37 | 
            -
                    submissions_df = submissions_df[
         | 
| 38 | 
            -
                        ["date", "submission_id", "public_score", "submission_comment", "selected", "status"]
         | 
| 39 | 
            -
                    ]
         | 
| 40 | 
            -
                else:
         | 
| 41 | 
            -
                    submissions_df = submissions_df[
         | 
| 42 | 
            -
                        ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
         | 
| 43 | 
            -
                    ]
         | 
| 44 | 
            -
                st.write(submissions_df)
         | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
            def new_submission(user_token):
         | 
| 48 | 
            -
                st.markdown(SUBMISSION_TEXT)
         | 
| 49 | 
            -
                uploaded_file = st.file_uploader("Choose a file")
         | 
| 50 | 
            -
                submit_button = st.button("Submit")
         | 
| 51 | 
            -
                if uploaded_file is not None and user_token != "" and submit_button:
         | 
| 52 | 
            -
                    # verify token
         | 
| 53 | 
            -
                    user_info = utils.user_authentication(token=user_token)
         | 
| 54 | 
            -
                    if "error" in user_info:
         | 
| 55 | 
            -
                        st.error("Invalid token")
         | 
| 56 | 
            -
                        return
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                    if user_info["emailVerified"] is False:
         | 
| 59 | 
            -
                        st.error("Please verify your email on Hugging Face Hub")
         | 
| 60 | 
            -
                        return
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                    # check if user can submit to the competition
         | 
| 63 | 
            -
                    if utils.check_user_submission_limit(user_info) is False:
         | 
| 64 | 
            -
                        st.error("You have reached your submission limit for today")
         | 
| 65 | 
            -
                        return
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                    bytes_data = uploaded_file.getvalue()
         | 
| 68 | 
            -
                    # verify file is valid
         | 
| 69 | 
            -
                    if not utils.verify_submission(bytes_data):
         | 
| 70 | 
            -
                        st.error("Invalid submission")
         | 
| 71 | 
            -
                        st.write(SUBMISSION_ERROR)
         | 
| 72 | 
            -
                        # write a horizontal html line
         | 
| 73 | 
            -
                        st.markdown("<hr/>", unsafe_allow_html=True)
         | 
| 74 | 
            -
                    else:
         | 
| 75 | 
            -
                        with st.spinner("Creating submission... Please wait"):
         | 
| 76 | 
            -
                            user_id = user_info["id"]
         | 
| 77 | 
            -
                            submission_id = str(uuid.uuid4())
         | 
| 78 | 
            -
                            file_extension = uploaded_file.name.split(".")[-1]
         | 
| 79 | 
            -
                            # upload file to hf hub
         | 
| 80 | 
            -
                            api = HfApi()
         | 
| 81 | 
            -
                            api.upload_file(
         | 
| 82 | 
            -
                                path_or_fileobj=bytes_data,
         | 
| 83 | 
            -
                                path_in_repo=f"submissions/{user_id}-{submission_id}.{file_extension}",
         | 
| 84 | 
            -
                                repo_id=config.COMPETITION_ID,
         | 
| 85 | 
            -
                                repo_type="dataset",
         | 
| 86 | 
            -
                                token=config.AUTOTRAIN_TOKEN,
         | 
| 87 | 
            -
                            )
         | 
| 88 | 
            -
                            # update submission limit
         | 
| 89 | 
            -
                            submissions_made = utils.increment_submissions(
         | 
| 90 | 
            -
                                user_id=user_id,
         | 
| 91 | 
            -
                                submission_id=submission_id,
         | 
| 92 | 
            -
                                submission_comment="",
         | 
| 93 | 
            -
                            )
         | 
| 94 | 
            -
                            # schedule submission for evaluation
         | 
| 95 | 
            -
                            utils.create_project(
         | 
| 96 | 
            -
                                project_id=f"{submission_id}",
         | 
| 97 | 
            -
                                dataset=f"{config.COMPETITION_ID}",
         | 
| 98 | 
            -
                                submission_dataset=user_id,
         | 
| 99 | 
            -
                                model="generic_competition",
         | 
| 100 | 
            -
                            )
         | 
| 101 | 
            -
                        st.success("Submission scheduled for evaluation")
         | 
| 102 | 
            -
                        st.success(
         | 
| 103 | 
            -
                            f"You have {config.competition_info.submission_limit - submissions_made} submissions left for today."
         | 
| 104 | 
            -
                        )
         | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 107 | 
            -
            def my_submissions(user_token):
         | 
| 108 | 
            -
                st.markdown(SUBMISSION_LIMIT_TEXT)
         | 
| 109 | 
            -
                if user_token != "":
         | 
| 110 | 
            -
                    user_info = utils.user_authentication(token=user_token)
         | 
| 111 | 
            -
                    if "error" in user_info:
         | 
| 112 | 
            -
                        st.error("Invalid token")
         | 
| 113 | 
            -
                        return
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                    if user_info["emailVerified"] is False:
         | 
| 116 | 
            -
                        st.error("Please verify your email on Hugging Face Hub")
         | 
| 117 | 
            -
                        return
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                    current_date_time = datetime.now()
         | 
| 120 | 
            -
                    private = False
         | 
| 121 | 
            -
                    if current_date_time >= config.competition_info.end_date:
         | 
| 122 | 
            -
                        private = True
         | 
| 123 | 
            -
                    get_subs(user_info, private=private)
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
            def app():
         | 
| 127 | 
            -
                st.set_page_config(page_title="Submissions", page_icon="π€")
         | 
| 128 | 
            -
                st.markdown("## Submissions")
         | 
| 129 | 
            -
                # enter token link to: https://huggingface.co/settings/tokens
         | 
| 130 | 
            -
                user_token = st.text_input("Enter your Hugging Face token", value="", type="password")
         | 
| 131 | 
            -
                user_token = user_token.strip()
         | 
| 132 | 
            -
                new_sub, my_sub = st.tabs(["New Submission", "My Submissions"])
         | 
| 133 | 
            -
             | 
| 134 | 
            -
                with new_sub:
         | 
| 135 | 
            -
                    new_submission(user_token)
         | 
| 136 | 
            -
             | 
| 137 | 
            -
                with my_sub:
         | 
| 138 | 
            -
                    my_submissions(user_token)
         | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
            if __name__ == "__main__":
         | 
| 142 | 
            -
                app()
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
    	
        pages/2_π_Leaderboard.py
    DELETED
    
    | @@ -1,28 +0,0 @@ | |
| 1 | 
            -
            from datetime import datetime
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            import streamlit as st
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            import config
         | 
| 6 | 
            -
            import utils
         | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
            def app():
         | 
| 10 | 
            -
                st.set_page_config(page_title="Leaderboard", page_icon="π€")
         | 
| 11 | 
            -
                st.markdown("## Leaderboard")
         | 
| 12 | 
            -
                public_lb, private_lb = st.tabs(["Public", "Private"])
         | 
| 13 | 
            -
                current_date_time = datetime.now()
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                with public_lb:
         | 
| 16 | 
            -
                    lb = utils.fetch_leaderboard(private=False)
         | 
| 17 | 
            -
                    st.table(lb)
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                with private_lb:
         | 
| 20 | 
            -
                    if current_date_time >= config.competition_info.end_date:
         | 
| 21 | 
            -
                        lb = utils.fetch_leaderboard(private=True)
         | 
| 22 | 
            -
                        st.table(lb)
         | 
| 23 | 
            -
                    else:
         | 
| 24 | 
            -
                        st.error("Private Leaderboard will be available after the competition ends")
         | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
            if __name__ == "__main__":
         | 
| 28 | 
            -
                app()
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
    	
        requirements.txt
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 | 
             
            gradio==3.9.1
         | 
| 2 | 
             
            pandas==1.5.0
         | 
| 3 | 
             
            python-dotenv==0.20.0
         | 
| 4 | 
            -
            huggingface_hub==0.10.1
         | 
|  | 
|  | |
| 1 | 
             
            gradio==3.9.1
         | 
| 2 | 
             
            pandas==1.5.0
         | 
| 3 | 
             
            python-dotenv==0.20.0
         | 
| 4 | 
            +
            huggingface_hub==0.10.1
         | 
| 5 | 
            +
            tabulate==0.9.0
         | 
    	
        setup.cfg
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            [metadata]
         | 
| 2 | 
            +
            license_file = LICENSE
         | 
| 3 | 
            +
            version = attr: competitions.__version__
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            [isort]
         | 
| 6 | 
            +
            ensure_newline_before_comments = True
         | 
| 7 | 
            +
            force_grid_wrap = 0
         | 
| 8 | 
            +
            include_trailing_comma = True
         | 
| 9 | 
            +
            line_length = 119
         | 
| 10 | 
            +
            lines_after_imports = 2
         | 
| 11 | 
            +
            multi_line_output = 3
         | 
| 12 | 
            +
            use_parentheses = True
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            [flake8]
         | 
| 15 | 
            +
            ignore = E203, E501, W503
         | 
| 16 | 
            +
            max-line-length = 119
         | 
    	
        setup.py
    ADDED
    
    | @@ -0,0 +1,60 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            # coding=utf-8
         | 
| 2 | 
            +
            # Copyright 2022 Hugging Face Inc
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Lint as: python3
         | 
| 5 | 
            +
            # pylint: enable=line-too-long
         | 
| 6 | 
            +
            """Hugging Face Competitions
         | 
| 7 | 
            +
            """
         | 
| 8 | 
            +
            from setuptools import find_packages, setup
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 11 | 
            +
            with open("README.md") as f:
         | 
| 12 | 
            +
                long_description = f.read()
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            QUALITY_REQUIRE = [
         | 
| 15 | 
            +
                "black~=22.0",
         | 
| 16 | 
            +
                "isort==5.8.0",
         | 
| 17 | 
            +
                "flake8==3.9.2",
         | 
| 18 | 
            +
                "mypy==0.901",
         | 
| 19 | 
            +
            ]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            TEST_REQUIRE = ["pytest", "pytest-cov"]
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            EXTRAS_REQUIRE = {
         | 
| 24 | 
            +
                "dev": QUALITY_REQUIRE,
         | 
| 25 | 
            +
                "quality": QUALITY_REQUIRE,
         | 
| 26 | 
            +
                "test": TEST_REQUIRE,
         | 
| 27 | 
            +
                "docs": [
         | 
| 28 | 
            +
                    "recommonmark",
         | 
| 29 | 
            +
                    "sphinx==3.1.2",
         | 
| 30 | 
            +
                    "sphinx-markdown-tables",
         | 
| 31 | 
            +
                    "sphinx-rtd-theme==0.4.3",
         | 
| 32 | 
            +
                    "sphinx-copybutton",
         | 
| 33 | 
            +
                ],
         | 
| 34 | 
            +
            }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            with open("requirements.txt") as f:
         | 
| 37 | 
            +
                INSTALL_REQUIRES = f.read().splitlines()
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            setup(
         | 
| 40 | 
            +
                name="competitions",
         | 
| 41 | 
            +
                description="Hugging Face Competitions",
         | 
| 42 | 
            +
                long_description=long_description,
         | 
| 43 | 
            +
                author="HuggingFace Inc.",
         | 
| 44 | 
            +
                url="https://github.com/huggingface/competitions",
         | 
| 45 | 
            +
                download_url="https://github.com/huggingface/competitions/tags",
         | 
| 46 | 
            +
                packages=find_packages("."),
         | 
| 47 | 
            +
                install_requires=INSTALL_REQUIRES,
         | 
| 48 | 
            +
                extras_require=EXTRAS_REQUIRE,
         | 
| 49 | 
            +
                python_requires=">=3.8",
         | 
| 50 | 
            +
                classifiers=[
         | 
| 51 | 
            +
                    "Intended Audience :: Developers",
         | 
| 52 | 
            +
                    "Intended Audience :: Education",
         | 
| 53 | 
            +
                    "Intended Audience :: Science/Research",
         | 
| 54 | 
            +
                    "License :: OSI Approved :: Apache Software License",
         | 
| 55 | 
            +
                    "Operating System :: OS Independent",
         | 
| 56 | 
            +
                    "Programming Language :: Python :: 3.8",
         | 
| 57 | 
            +
                    "Topic :: Scientific/Engineering :: Artificial Intelligence",
         | 
| 58 | 
            +
                ],
         | 
| 59 | 
            +
                keywords="huggingface competitions machine learning ai nlp",
         | 
| 60 | 
            +
            )
         | 
