bartowski commited on
Commit
80cafae
1 Parent(s): a7a0881

Add option to make the destination repo private

Browse files

Useful if you're copying a public repository but don't want to make the destination one public

Think I did this right, difficult to test :D

Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -9,7 +9,7 @@ ENDPOINT = "https://huggingface.co"
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 +19,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
 
@@ -48,6 +48,7 @@ interface = gr.Interface(
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"),
 
9
  REPO_TYPES = ["model", "dataset", "space"]
10
 
11
 
12
+ def duplicate(source_repo, dst_repo, token, repo_type, private):
13
  try:
14
  if not repo_type in REPO_TYPES:
15
  raise ValueError("need to select valid 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, "private": private},
23
  )
24
  hf_raise_for_status(r)
25
 
 
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
+ gr.Checkbox(label="Make new repo private?"),
52
  ],
53
  outputs=[
54
  gr.Markdown(label="output"),