Skip to content

Commit

Permalink
sort keys
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Jan 22, 2025
1 parent a4e1be7 commit 5fdc225
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/marvin/utilities/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"""

import hashlib
import json
import re
from copy import deepcopy
from dataclasses import MISSING, field, make_dataclass
Expand All @@ -58,7 +59,6 @@
StringConstraints,
model_validator,
)
from pydantic_core import to_json
from typing_extensions import NotRequired, TypedDict

__all__ = ["jsonschema_to_type", "JSONSchema"]
Expand Down Expand Up @@ -142,7 +142,7 @@ class Name:

def hash_schema(schema: Mapping[str, Any]) -> str:
"""Generate a deterministic hash for schema caching."""
return hashlib.sha256(to_json(schema)).hexdigest()
return hashlib.sha256(json.dumps(schema, sort_keys=True).encode()).hexdigest()


def resolve_ref(ref: str, schemas: Mapping[str, Any]) -> Mapping[str, Any]:
Expand Down

0 comments on commit 5fdc225

Please sign in to comment.