From 89427bfcb4ed86cf09ea0f2e1c0dabbeaa7d9d63 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 5 Nov 2024 14:29:51 +0000 Subject: [PATCH] Handle when update fails --- import_schemas.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/import_schemas.py b/import_schemas.py index 0dda323..cf93520 100755 --- a/import_schemas.py +++ b/import_schemas.py @@ -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)