Skip to content

Commit 3ae3632

Browse files
committed
chore: Add files to format Synapse
1 parent 81770d2 commit 3ae3632

File tree

2 files changed

+39813
-0
lines changed

2 files changed

+39813
-0
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import json
2+
from os.path import join, dirname
3+
4+
5+
RAW_SYNAPSE_PATH = join(dirname(__file__), "./synapse_raw_schema.json")
6+
FORMATTED_SYNAPSE_PATH = join(dirname(__file__), "../../bdikit/resource/synapse_schema.json")
7+
8+
data = {'entity':{}, 'subschema':{}}
9+
10+
11+
with open(RAW_SYNAPSE_PATH) as json_file:
12+
sbn_schema = json.load(json_file)
13+
14+
for entry in sbn_schema["@graph"]:
15+
entry_name = entry["rdfs:label"]
16+
entry_description = entry.get("rdfs:comment", "")
17+
entry_parents = entry.get("rdfs:subClassOf", [{}])
18+
19+
if entry_parents[0]['@id'] == "bts:Thing":
20+
21+
if entry_name.endswith("Enum"):
22+
continue
23+
values = entry.get("schema:rangeIncludes", [])
24+
new_entry = {
25+
"column_description": entry_description,
26+
"value_data": {x["@id"].replace("bts:", ""): "" for x in values}
27+
}
28+
data['entity'][entry_name] = new_entry
29+
30+
if entry_name.endswith("Template") and "sms:requiresDependency" in entry:
31+
dependencies = [x["@id"].replace("bts:", "") for x in entry["sms:requiresDependency"]]
32+
data['subschema'][entry_name] = dependencies
33+
34+
with open(FORMATTED_SYNAPSE_PATH, "w") as f:
35+
json.dump(data, f, indent=4)
36+
37+
print("Synapse schema formatted successfully.")

0 commit comments

Comments
 (0)