Spaces:
Running
Running
Prevent race condition when duplicate conversion requests are done in parallel
#42
by
lysandre
HF Staff
- opened
- convert.py +7 -0
convert.py
CHANGED
|
@@ -311,6 +311,13 @@ def convert(
|
|
| 311 |
)
|
| 312 |
|
| 313 |
if operations:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
new_pr = api.create_commit(
|
| 315 |
repo_id=model_id,
|
| 316 |
revision=revision,
|
|
|
|
| 311 |
)
|
| 312 |
|
| 313 |
if operations:
|
| 314 |
+
# Checking that no PR have been created during the conversion in case of duplicate conversion requests.
|
| 315 |
+
pr = previous_pr(api, model_id, pr_title, revision=revision)
|
| 316 |
+
if pr is not None and not force:
|
| 317 |
+
url = f"https://huggingface.co/{model_id}/discussions/{pr.num}"
|
| 318 |
+
new_pr = pr
|
| 319 |
+
raise AlreadyExists(f"Model {model_id} already has an open PR check out {url}")
|
| 320 |
+
|
| 321 |
new_pr = api.create_commit(
|
| 322 |
repo_id=model_id,
|
| 323 |
revision=revision,
|