Skip to content

Encoding problem while importing schemas #20

Description

@adeerkhan

The UnicodeDecodeError occurred because the format_json_file function in import_schemas.py was opening JSON files without specifying the encoding. On Windows, Python defaults to the system encoding (cp1252), but the schema files were saved in UTF-8 encoding by the replicate library.

Updated function in import_schemas.py

def format_json_file(file_path):
    try:
        with open(file_path, "r", encoding="utf-8") as f:
            data = json.load(f)
            data["run_count"] = 0

        with open(file_path, "w", encoding="utf-8") as f:
            json.dump(data, f, indent=4, ensure_ascii=False)
    except json.JSONDecodeError:
        print(f"Error: {file_path} contains invalid JSON")
    except IOError:
        print(f"Error: Could not read or write to {file_path}")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions