Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update convert.py
Browse files- convert.py +6 -6
convert.py
CHANGED
|
@@ -86,7 +86,7 @@ def convert_multi(model_id: str, folder: str, api: "HfApi") -> ConversionResult:
|
|
| 86 |
)
|
| 87 |
os.remove(pt_filename)
|
| 88 |
os.remove(sf_filename)
|
| 89 |
-
return new_pr
|
| 90 |
|
| 91 |
|
| 92 |
def convert_single(model_id: str, folder: str, api: "HfApi") -> ConversionResult:
|
|
@@ -103,7 +103,7 @@ def convert_single(model_id: str, folder: str, api: "HfApi") -> ConversionResult
|
|
| 103 |
commit_description=COMMIT_DESCRIPTION,
|
| 104 |
create_pr=True,
|
| 105 |
)
|
| 106 |
-
return new_pr
|
| 107 |
|
| 108 |
|
| 109 |
def convert_file(
|
|
@@ -208,7 +208,7 @@ def convert_generic(model_id: str, folder: str, filenames: Set[str], api: "HfApi
|
|
| 208 |
os.remove(sf_filename)
|
| 209 |
except Exception as e:
|
| 210 |
errors.append((pt_filename, e))
|
| 211 |
-
return new_pr
|
| 212 |
|
| 213 |
|
| 214 |
def convert(api: "HfApi", model_id: str, force: bool = False) -> Tuple["CommitInfo", List["Exception"]]:
|
|
@@ -232,13 +232,13 @@ def convert(api: "HfApi", model_id: str, force: bool = False) -> Tuple["CommitIn
|
|
| 232 |
raise AlreadyExists(f"Model {model_id} already has an open PR check out {url}")
|
| 233 |
elif library_name == "transformers":
|
| 234 |
if "pytorch_model.bin" in filenames:
|
| 235 |
-
new_pr = convert_single(model_id, folder, api)
|
| 236 |
elif "pytorch_model.bin.index.json" in filenames:
|
| 237 |
-
new_pr = convert_multi(model_id, folder, api)
|
| 238 |
else:
|
| 239 |
raise RuntimeError(f"Model {model_id} doesn't seem to be a valid pytorch model. Cannot convert")
|
| 240 |
else:
|
| 241 |
-
new_pr = convert_generic(model_id, folder, filenames, api)
|
| 242 |
|
| 243 |
print(f"Pr created at {new_pr.pr_url}")
|
| 244 |
finally:
|
|
|
|
| 86 |
)
|
| 87 |
os.remove(pt_filename)
|
| 88 |
os.remove(sf_filename)
|
| 89 |
+
return new_pr, []
|
| 90 |
|
| 91 |
|
| 92 |
def convert_single(model_id: str, folder: str, api: "HfApi") -> ConversionResult:
|
|
|
|
| 103 |
commit_description=COMMIT_DESCRIPTION,
|
| 104 |
create_pr=True,
|
| 105 |
)
|
| 106 |
+
return new_pr, []
|
| 107 |
|
| 108 |
|
| 109 |
def convert_file(
|
|
|
|
| 208 |
os.remove(sf_filename)
|
| 209 |
except Exception as e:
|
| 210 |
errors.append((pt_filename, e))
|
| 211 |
+
return new_pr, errors
|
| 212 |
|
| 213 |
|
| 214 |
def convert(api: "HfApi", model_id: str, force: bool = False) -> Tuple["CommitInfo", List["Exception"]]:
|
|
|
|
| 232 |
raise AlreadyExists(f"Model {model_id} already has an open PR check out {url}")
|
| 233 |
elif library_name == "transformers":
|
| 234 |
if "pytorch_model.bin" in filenames:
|
| 235 |
+
new_pr, errors = convert_single(model_id, folder, api)
|
| 236 |
elif "pytorch_model.bin.index.json" in filenames:
|
| 237 |
+
new_pr, errors = convert_multi(model_id, folder, api)
|
| 238 |
else:
|
| 239 |
raise RuntimeError(f"Model {model_id} doesn't seem to be a valid pytorch model. Cannot convert")
|
| 240 |
else:
|
| 241 |
+
new_pr, errors = convert_generic(model_id, folder, filenames, api)
|
| 242 |
|
| 243 |
print(f"Pr created at {new_pr.pr_url}")
|
| 244 |
finally:
|