Spaces:
Running
Running
David Dale
commited on
Commit
·
eafce3d
1
Parent(s):
2dc1a73
remove argilla-related code
Browse files- app.py +0 -171
- requirements.txt +0 -1
app.py
CHANGED
|
@@ -5,43 +5,13 @@
|
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
-
from huggingface_hub import whoami
|
| 9 |
-
from huggingface_hub.errors import LocalTokenNotFoundError
|
| 10 |
-
import argilla as rg
|
| 11 |
import os
|
| 12 |
-
from requests.exceptions import HTTPError
|
| 13 |
import csv
|
| 14 |
import pandas as pd
|
| 15 |
from collections import defaultdict
|
| 16 |
|
| 17 |
from leaderboard import leaderboard_tab
|
| 18 |
|
| 19 |
-
CLA = """
|
| 20 |
-
Meta Platforms, Inc. Individual Contributor License Agreement ("Agreement"), v2.0
|
| 21 |
-
|
| 22 |
-
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Meta Platforms, Inc. ("Meta"). Except for the license granted herein to Meta and recipients of software distributed by Meta, You reserve all right, title, and interest in and to Your Contributions.
|
| 23 |
-
|
| 24 |
-
1. Definitions.
|
| 25 |
-
|
| 26 |
-
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Meta. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
| 27 |
-
|
| 28 |
-
"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Meta for inclusion in, or documentation of, any of the products owned or managed by Meta (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to Meta or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Meta for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
|
| 29 |
-
|
| 30 |
-
2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to Meta and to recipients of software distributed by Meta a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
|
| 31 |
-
|
| 32 |
-
3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to Meta and to recipients of software distributed by Meta a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
| 33 |
-
|
| 34 |
-
4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to Meta, or that your employer has executed a separate Corporate CLA with Meta.
|
| 35 |
-
|
| 36 |
-
5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
|
| 37 |
-
|
| 38 |
-
6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
| 39 |
-
|
| 40 |
-
7. Should You wish to submit work that is not Your original creation, You may submit it to Meta separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
|
| 41 |
-
|
| 42 |
-
8. You agree to notify Meta of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.
|
| 43 |
-
"""
|
| 44 |
-
|
| 45 |
DLA = """
|
| 46 |
Note that the dataset collected by the BOUQuET initiative and your contributions to this dataset will be released under the following open source license.
|
| 47 |
|
|
@@ -97,28 +67,6 @@ Meta may make changes to this Agreement at any time with notice to You and the o
|
|
| 97 |
No failure to exercise and no delay in exercising any right, remedy or power hereunder will operate as a waiver thereof, nor will any single or partial exercise of any right, remedy or power hereunder will operate as a waiver thereof, or the exercise of any other right, remedy or power provided herein or by law or in equity.
|
| 98 |
"""
|
| 99 |
|
| 100 |
-
argilla_endpoint = os.getenv('argilla_endpoint')
|
| 101 |
-
|
| 102 |
-
rg_client = None
|
| 103 |
-
try:
|
| 104 |
-
rg_client = rg.Argilla(
|
| 105 |
-
api_url=argilla_endpoint,
|
| 106 |
-
api_key=os.getenv('argilla_api_key'),
|
| 107 |
-
)
|
| 108 |
-
except:
|
| 109 |
-
# for now ignore if we can't connect
|
| 110 |
-
pass
|
| 111 |
-
|
| 112 |
-
def existing_user(username):
|
| 113 |
-
return f"""
|
| 114 |
-
- Your user has been created with username **{username}**, thank you for agreeing to the [CLA](https://code.facebook.com/cla/individual).
|
| 115 |
-
- Please go to [the translation tool]({argilla_endpoint}) and login to get started,
|
| 116 |
-
- Once you are logged in, select a workspace for the language you can translate from,
|
| 117 |
-
- Then choose the target language you want to translate to,
|
| 118 |
-
**if you do not see your language right now, don't worry, we are still populating the tool with new languages, make sure to come back later.**
|
| 119 |
-
- You can now submit translations for each sentence showed to you.
|
| 120 |
-
"""
|
| 121 |
-
|
| 122 |
def guidelines_tab():
|
| 123 |
with gr.Tab("Translation guidelines"):
|
| 124 |
gr.Markdown("""
|
|
@@ -248,124 +196,6 @@ It may be the case that some words or expressions of the source language have mo
|
|
| 248 |
* Recurring items are consistently translated throughout the dataset; i.e., please do not alternate between translation options if not necessary.
|
| 249 |
""")
|
| 250 |
|
| 251 |
-
def please_login():
|
| 252 |
-
gr.Markdown("""
|
| 253 |
-
If you want to contribute, please login with HuggingFace.
|
| 254 |
-
|
| 255 |
-
We will use your huggingface username to idenfity you, we will not store any other
|
| 256 |
-
information (while HF login might provide your name, we do not store this).
|
| 257 |
-
|
| 258 |
-
Once you are logged in, we will create an account for you in our translation tool.
|
| 259 |
-
""")
|
| 260 |
-
gr.LoginButton()
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
def create_account(cla, username, password):
|
| 264 |
-
if not cla:
|
| 265 |
-
return "Cannot create account until you agree to CLA."
|
| 266 |
-
|
| 267 |
-
if not username or len(username) == 0:
|
| 268 |
-
return "Please specify a username."
|
| 269 |
-
|
| 270 |
-
if len(username) < 8:
|
| 271 |
-
return "Please choose a username with at least eight characters."
|
| 272 |
-
|
| 273 |
-
if len(password) < 8:
|
| 274 |
-
return "Please choose a password with at least eight characters."
|
| 275 |
-
|
| 276 |
-
rg_user = rg_client.users(username)
|
| 277 |
-
if rg_user:
|
| 278 |
-
return "Looks like you already have an account."
|
| 279 |
-
|
| 280 |
-
user_to_create = rg.User(
|
| 281 |
-
username=username,
|
| 282 |
-
password=password,
|
| 283 |
-
client=rg_client
|
| 284 |
-
)
|
| 285 |
-
created_user = user_to_create.create()
|
| 286 |
-
|
| 287 |
-
# add to all workplaces
|
| 288 |
-
|
| 289 |
-
for workspace in rg_client.workspaces:
|
| 290 |
-
created_user.add_to_workspace(workspace)
|
| 291 |
-
|
| 292 |
-
return existing_user(username)
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
def update_button(checked):
|
| 296 |
-
return gr.Button.update(interactive=checked)
|
| 297 |
-
|
| 298 |
-
def new_user():
|
| 299 |
-
with gr.Blocks():
|
| 300 |
-
gr.Markdown(f"""
|
| 301 |
-
# Contributing to Meta Open Source Projects
|
| 302 |
-
|
| 303 |
-
We welcome you to contribute to this collaborative project.
|
| 304 |
-
Before you can contribute, we need to ask you to complete the Contributor License Agreement (CLA) below.
|
| 305 |
-
|
| 306 |
-
This agreement clarifies the ability for us to incorporate your contributions.
|
| 307 |
-
Your agreement of this CLA will be recorded with the username you choose below.
|
| 308 |
-
""")
|
| 309 |
-
|
| 310 |
-
gr.Textbox(
|
| 311 |
-
label="Contributor License Agreement",
|
| 312 |
-
elem_id="cla",
|
| 313 |
-
value=CLA,
|
| 314 |
-
interactive=False
|
| 315 |
-
)
|
| 316 |
-
with gr.Accordion("BOUQUET Dataset License Agreement", open=False):
|
| 317 |
-
gr.Markdown(DLA)
|
| 318 |
-
|
| 319 |
-
cla_checkbox = gr.Checkbox(label="Accept CLA and Dataset License Agreement", key="cla")
|
| 320 |
-
|
| 321 |
-
gr.Markdown(f"""
|
| 322 |
-
## Create a Translator Account
|
| 323 |
-
|
| 324 |
-
The BOUQuET 💐 dataset is being translated with [this tool]({argilla_endpoint}).
|
| 325 |
-
For you to participate in the data collection, we need to create a translator account in
|
| 326 |
-
the annotation tool.
|
| 327 |
-
|
| 328 |
-
Please agree to the CLA and create a new password for your translator account.
|
| 329 |
-
""")
|
| 330 |
-
|
| 331 |
-
name_input = gr.Textbox(label="Username")
|
| 332 |
-
password_input = gr.Textbox(label="Password", type="password")
|
| 333 |
-
|
| 334 |
-
out = gr.Markdown()
|
| 335 |
-
gr.Button("Create Translator Account", key="submit", interactive=True).click(
|
| 336 |
-
create_account,
|
| 337 |
-
inputs=[cla_checkbox, name_input, password_input],
|
| 338 |
-
outputs=[out],
|
| 339 |
-
)
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
def safe_whoami():
|
| 343 |
-
try:
|
| 344 |
-
return whoami()
|
| 345 |
-
except (LocalTokenNotFoundError, HTTPError, KeyError) as e:
|
| 346 |
-
print(e)
|
| 347 |
-
return None
|
| 348 |
-
|
| 349 |
-
def maybe_loggedin() -> str:
|
| 350 |
-
new_user()
|
| 351 |
-
# me = safe_whoami()
|
| 352 |
-
# if me is None:
|
| 353 |
-
# print("me is none")
|
| 354 |
-
# please_login()
|
| 355 |
-
# else:
|
| 356 |
-
# username = me['name']
|
| 357 |
-
# rg_user = rg_client.users(username)
|
| 358 |
-
# if rg_user is None:
|
| 359 |
-
# new_user(username)
|
| 360 |
-
# else:
|
| 361 |
-
# gr.Markdown(existing_user(username))
|
| 362 |
-
|
| 363 |
-
def login_tab():
|
| 364 |
-
with gr.Tab("Contribute"):
|
| 365 |
-
if not rg_client:
|
| 366 |
-
gr.Markdown("We are currently setting up the translation collection system, it will be available for contributions later today.")
|
| 367 |
-
else:
|
| 368 |
-
maybe_loggedin()
|
| 369 |
|
| 370 |
def dla_tab():
|
| 371 |
with gr.Tab("Dataset License"):
|
|
@@ -426,7 +256,6 @@ with gr.Blocks(
|
|
| 426 |
""")
|
| 427 |
intro_tab()
|
| 428 |
leaderboard_tab()
|
| 429 |
-
# login_tab()
|
| 430 |
guidelines_tab()
|
| 431 |
dla_tab()
|
| 432 |
|
|
|
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 8 |
import os
|
|
|
|
| 9 |
import csv
|
| 10 |
import pandas as pd
|
| 11 |
from collections import defaultdict
|
| 12 |
|
| 13 |
from leaderboard import leaderboard_tab
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
DLA = """
|
| 16 |
Note that the dataset collected by the BOUQuET initiative and your contributions to this dataset will be released under the following open source license.
|
| 17 |
|
|
|
|
| 67 |
No failure to exercise and no delay in exercising any right, remedy or power hereunder will operate as a waiver thereof, nor will any single or partial exercise of any right, remedy or power hereunder will operate as a waiver thereof, or the exercise of any other right, remedy or power provided herein or by law or in equity.
|
| 68 |
"""
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def guidelines_tab():
|
| 71 |
with gr.Tab("Translation guidelines"):
|
| 72 |
gr.Markdown("""
|
|
|
|
| 196 |
* Recurring items are consistently translated throughout the dataset; i.e., please do not alternate between translation options if not necessary.
|
| 197 |
""")
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
def dla_tab():
|
| 201 |
with gr.Tab("Dataset License"):
|
|
|
|
| 256 |
""")
|
| 257 |
intro_tab()
|
| 258 |
leaderboard_tab()
|
|
|
|
| 259 |
guidelines_tab()
|
| 260 |
dla_tab()
|
| 261 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
argilla
|
| 2 |
gradio[oauth]
|
| 3 |
pandas
|
| 4 |
matplotlib # for background_gradient
|
|
|
|
|
|
|
| 1 |
gradio[oauth]
|
| 2 |
pandas
|
| 3 |
matplotlib # for background_gradient
|