Pierre Andrews commited on
Commit
c2dd664
·
1 Parent(s): 512f701

new username

Browse files
Files changed (1) hide show
  1. app.py +28 -25
app.py CHANGED
@@ -110,6 +110,7 @@ def existing_user(username):
110
  - Please go to [the translation tool]({argilla_endpoint}) and login to get started,
111
  - Once you are logged in, select a workspace for the language you can translate from,
112
  - Then choose the target language you want to translate to,
 
113
  - You can now submit translations for each sentence showed to you.
114
  """
115
 
@@ -258,14 +259,19 @@ def create_account(cla, username, password):
258
  if not cla:
259
  return "Cannot create account until you agree to CLA."
260
 
261
- if len(password) < 8:
262
- return "Please a password with more than eight characters."
263
 
 
 
264
 
265
- rg_user = rg_client.users(username)
266
- if rg_user is not None:
267
- return existing_user(username)
268
 
 
 
 
 
269
  user_to_create = rg.User(
270
  username=username,
271
  password=password,
@@ -284,19 +290,16 @@ def create_account(cla, username, password):
284
  def update_button(checked):
285
  return gr.Button.update(interactive=checked)
286
 
287
- def new_user(username):
288
  with gr.Blocks():
289
  gr.Markdown(f"""
290
- Thank you for login, your HuggingFace username is `{username.value}`,
291
- we will use the same username for our annotation tool.
292
-
293
  # Contributing to Meta Open Source Projects
294
 
295
  We welcome you to contribute to this collaborative project.
296
  Before you can contribute, we need to ask you to complete the Contributor License Agreement (CLA) below.
297
 
298
  This agreement clarifies the ability for us to incorporate your contributions.
299
- Your agreement of this CLA will be recorded with your huggingface username.
300
  """)
301
 
302
  gr.Textbox(
@@ -315,13 +318,12 @@ def new_user(username):
315
 
316
  The BOUQuET 💐 dataset is being translated with [this tool]({argilla_endpoint}).
317
  For you to participate in the data collection, we need to create a translator account in
318
- the annotation tool. This is separate from your huggingface account but will share the same
319
- username: {username.value}.
320
 
321
  Please agree to the CLA and create a new password for your translator account.
322
  """)
323
 
324
- name_input = gr.Textbox(label="Username", interactive=False, value=username.value)
325
  password_input = gr.Textbox(label="Password", type="password")
326
 
327
  out = gr.Markdown()
@@ -340,21 +342,22 @@ def safe_whoami():
340
  return None
341
 
342
  def maybe_loggedin() -> str:
343
- me = safe_whoami()
344
- if me is None:
345
- print("me is none")
346
- please_login()
347
- else:
348
- username = me['name']
349
- rg_user = rg_client.users(username)
350
- if rg_user is None:
351
- new_user(username)
352
- else:
353
- gr.Markdown(existing_user(username))
 
354
 
355
  def login_tab():
356
  with gr.Tab("Contribute"):
357
- if True:
358
  gr.Markdown("We are currently setting up the translation collection system, it will be available for contributions later today.")
359
  else:
360
  maybe_loggedin()
 
110
  - Please go to [the translation tool]({argilla_endpoint}) and login to get started,
111
  - Once you are logged in, select a workspace for the language you can translate from,
112
  - Then choose the target language you want to translate to,
113
+ **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.**
114
  - You can now submit translations for each sentence showed to you.
115
  """
116
 
 
259
  if not cla:
260
  return "Cannot create account until you agree to CLA."
261
 
262
+ if not username or len(username) == 0:
263
+ return "Please specify a username."
264
 
265
+ if len(username) < 8:
266
+ return "Please choose a username with at least eight characters."
267
 
268
+ if len(password) < 8:
269
+ return "Please choose a password with at least eight characters."
 
270
 
271
+ rg_user = rg_client.users(username)
272
+ if rg_user:
273
+ return "Looks like you already have an account."
274
+
275
  user_to_create = rg.User(
276
  username=username,
277
  password=password,
 
290
  def update_button(checked):
291
  return gr.Button.update(interactive=checked)
292
 
293
+ def new_user():
294
  with gr.Blocks():
295
  gr.Markdown(f"""
 
 
 
296
  # Contributing to Meta Open Source Projects
297
 
298
  We welcome you to contribute to this collaborative project.
299
  Before you can contribute, we need to ask you to complete the Contributor License Agreement (CLA) below.
300
 
301
  This agreement clarifies the ability for us to incorporate your contributions.
302
+ Your agreement of this CLA will be recorded with the username you choose below.
303
  """)
304
 
305
  gr.Textbox(
 
318
 
319
  The BOUQuET 💐 dataset is being translated with [this tool]({argilla_endpoint}).
320
  For you to participate in the data collection, we need to create a translator account in
321
+ the annotation tool.
 
322
 
323
  Please agree to the CLA and create a new password for your translator account.
324
  """)
325
 
326
+ name_input = gr.Textbox(label="Username")
327
  password_input = gr.Textbox(label="Password", type="password")
328
 
329
  out = gr.Markdown()
 
342
  return None
343
 
344
  def maybe_loggedin() -> str:
345
+ new_user()
346
+ # me = safe_whoami()
347
+ # if me is None:
348
+ # print("me is none")
349
+ # please_login()
350
+ # else:
351
+ # username = me['name']
352
+ # rg_user = rg_client.users(username)
353
+ # if rg_user is None:
354
+ # new_user(username)
355
+ # else:
356
+ # gr.Markdown(existing_user(username))
357
 
358
  def login_tab():
359
  with gr.Tab("Contribute"):
360
+ if not rg_client:
361
  gr.Markdown("We are currently setting up the translation collection system, it will be available for contributions later today.")
362
  else:
363
  maybe_loggedin()