Handle when update fails

This commit is contained in:
Paul
2024-11-05 14:29:51 +00:00
parent cdd0430a03
commit 89427bfcb4
+8 -4
View File
@@ -38,10 +38,14 @@ def update_schemas(update=False):
schema_path = os.path.join(schemas_directory, schema_filename)
if update or schema_filename not in existing_schemas:
m = replicate.models.get(model)
with open(schema_path, "w", encoding="utf-8") as f:
f.write(m.json())
print(f"{'Updated' if update else 'Added'} schema for {model}")
try:
m = replicate.models.get(model)
with open(schema_path, "w", encoding="utf-8") as f:
f.write(m.json())
print(f"{'Updated' if update else 'Added'} schema for {model}")
except replicate.exceptions.ReplicateError as e:
print(f"Error fetching schema for {model}: {str(e)}")
continue
format_json_files_in_directory(schemas_directory)