MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / load_schemas

Function load_schemas

modules/module-test-cpp/compare_module_schemas.py:21–49  ·  view source on GitHub ↗

Load the schema files, trying both cpp-module-schema.json and cpp-module-schema-latest.json

()

Source from the content-addressed store, hash-verified

19import os
20
21def load_schemas():
22 """Load the schema files, trying both cpp-module-schema.json and cpp-module-schema-latest.json"""
23 try:
24 with open('rust-module-schema.json', 'r') as f:
25 rust = json.load(f)
26 except FileNotFoundError:
27 print("Error: rust-module-schema.json not found")
28 print("Generate it with: spacetime describe module-test --json > rust-module-schema.json")
29 sys.exit(1)
30 except json.JSONDecodeError as e:
31 print(f"Error parsing rust-module-schema.json: {e}")
32 print("The file may be corrupted or incomplete. Try regenerating it.")
33 sys.exit(1)
34
35 # Try to load C++ schema, checking both possible filenames
36 cpp = None
37 for filename in ['cpp-module-schema-latest.json', 'cpp-module-schema.json']:
38 if os.path.exists(filename):
39 with open(filename, 'r') as f:
40 cpp = json.load(f)
41 print(f"Loaded C++ schema from {filename}")
42 break
43
44 if cpp is None:
45 print("Error: No C++ schema file found")
46 print("Generate it with: spacetime describe module-test-cpp --json > cpp-module-schema.json")
47 sys.exit(1)
48
49 return rust, cpp
50
51def normalize_index(idx):
52 """Normalize index representation for comparison"""

Callers 1

mainFunction · 0.85

Calls 3

exitMethod · 0.80
openFunction · 0.50
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…