ttttdiva commited on
Commit
e4905a0
1 Parent(s): 09fdf40

pr: no more public (#1)

Browse files

- a (d47e43c005d0a40654aec6ea0aa658df98afa218)

Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -4,12 +4,10 @@ from huggingface_hub import whoami
4
  from huggingface_hub.utils import build_hf_headers, hf_raise_for_status
5
 
6
  ENDPOINT = "https://huggingface.co"
7
- # ENDPOINT = "http://localhost:5564"
8
 
9
  REPO_TYPES = ["model", "dataset", "space"]
10
 
11
-
12
- def duplicate(source_repo, dst_repo, token, repo_type):
13
  try:
14
  if not repo_type in REPO_TYPES:
15
  raise ValueError("need to select valid repo type")
@@ -19,7 +17,7 @@ def duplicate(source_repo, dst_repo, token, repo_type):
19
  r = requests.post(
20
  f"{ENDPOINT}/api/{repo_type}s/{source_repo}/duplicate",
21
  headers=build_hf_headers(token=token),
22
- json={"repository": dst_repo},
23
  )
24
  hf_raise_for_status(r)
25
 
@@ -39,19 +37,20 @@ def duplicate(source_repo, dst_repo, token, repo_type):
39
  """,
40
  None,
41
  )
42
-
43
 
44
  interface = gr.Interface(
45
  fn=duplicate,
46
  inputs=[
47
- gr.Textbox(placeholder="Source repository (e.g. osanseviero/src)"),
48
- gr.Textbox(placeholder="Destination repository (e.g. osanseviero/dst)"),
49
- gr.Textbox(placeholder="Write access token", type="password"),
50
  gr.Dropdown(choices=REPO_TYPES, value="model"),
 
51
  ],
52
  outputs=[
53
  gr.Markdown(label="output"),
54
- gr.Image(show_label=False),
55
  ],
56
  title="Duplicate your repo!",
57
  description="Duplicate a Hugging Face repository! You need to specify a write token obtained in https://hf.co/settings/tokens. This Space is a an experimental demo.",
@@ -59,4 +58,4 @@ interface = gr.Interface(
59
  allow_flagging="never",
60
  live=False,
61
  )
62
- interface.launch(enable_queue=True)
 
4
  from huggingface_hub.utils import build_hf_headers, hf_raise_for_status
5
 
6
  ENDPOINT = "https://huggingface.co"
 
7
 
8
  REPO_TYPES = ["model", "dataset", "space"]
9
 
10
+ def duplicate(source_repo, dst_repo, token, repo_type, private=True):
 
11
  try:
12
  if not repo_type in REPO_TYPES:
13
  raise ValueError("need to select valid repo type")
 
17
  r = requests.post(
18
  f"{ENDPOINT}/api/{repo_type}s/{source_repo}/duplicate",
19
  headers=build_hf_headers(token=token),
20
+ json={"repository": dst_repo, "private": private},
21
  )
22
  hf_raise_for_status(r)
23
 
 
37
  """,
38
  None,
39
  )
40
+
41
 
42
  interface = gr.Interface(
43
  fn=duplicate,
44
  inputs=[
45
+ gr.Textbox(placeholder="Source repository (e.g. osanpo/src)", value=""),
46
+ gr.Textbox(placeholder="Destination repository (e.g. osanpo/dst)", value=""),
47
+ gr.Textbox(placeholder="Write access token (e.g. hf_XXXXXXXXXXXXXXXXXXXXXXXXXX)", type="password", value=""),
48
  gr.Dropdown(choices=REPO_TYPES, value="model"),
49
+ gr.Checkbox(value=True),
50
  ],
51
  outputs=[
52
  gr.Markdown(label="output"),
53
+ gr.Image(type="pil", show_label=False),
54
  ],
55
  title="Duplicate your repo!",
56
  description="Duplicate a Hugging Face repository! You need to specify a write token obtained in https://hf.co/settings/tokens. This Space is a an experimental demo.",
 
58
  allow_flagging="never",
59
  live=False,
60
  )
61
+ interface.launch()