Skip to content

Commit c8758f7

Browse files
author
Lingling Peng
committed
abolish jsonschema type
1 parent 626b06e commit c8758f7

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

synapseclient/extensions/curator/schema_generation.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ class ValidationRuleName(Enum):
9898
IN_RANGE = "inRange"
9999

100100

101-
class JSONSchemaType(Enum):
102-
"""This enum is the currently supported JSON Schema types"""
103-
104-
STRING = "string"
105-
NUMBER = "number"
106-
INTEGER = "integer"
107-
BOOLEAN = "boolean"
108-
109-
110101
class RegexModule(Enum):
111102
"""This enum are allowed modules for the regex validation rule"""
112103

@@ -1645,7 +1636,7 @@ def is_class_in_schema(self, node_label: str) -> bool:
16451636

16461637
def get_node_column_type(
16471638
self, node_label: Optional[str] = None, node_display_name: Optional[str] = None
1648-
) -> Optional[JSONSchemaType]:
1639+
) -> str:
16491640
"""Gets the column type of the node
16501641
16511642
Args:
@@ -1658,9 +1649,8 @@ def get_node_column_type(
16581649
node_label = self._get_node_label(node_label, node_display_name)
16591650
rel_node_label = self.dmr.get_relationship_value("columnType", "node_label")
16601651
type_string = self.graph.nodes[node_label][rel_node_label]
1661-
if type_string is None:
1662-
return type_string
1663-
return JSONSchemaType(type_string)
1652+
return type_string
1653+
# return JSONSchemaType(type_string)
16641654

16651655
def _get_node_label(
16661656
self, node_label: Optional[str] = None, node_display_name: Optional[str] = None
@@ -2778,7 +2768,7 @@ def define_data_model_relationships(self) -> dict:
27782768
"required_header": False,
27792769
"edge_rel": False,
27802770
"node_attr_dict": {"default": None},
2781-
"allowed_values": [enum.value for enum in JSONSchemaType],
2771+
"allowed_values": ["string", "number", "integer", "boolean"],
27822772
},
27832773
}
27842774

@@ -4360,7 +4350,7 @@ class TraversalNode: # pylint: disable=too-many-instance-attributes
43604350
dependencies: list[str] = field(init=False)
43614351
description: str = field(init=False)
43624352
is_array: bool = field(init=False)
4363-
type: Optional[JSONSchemaType] = field(init=False)
4353+
type: str = field(init=False)
43644354
format: Optional[JSONSchemaFormat] = field(init=False)
43654355
minimum: Optional[float] = field(init=False)
43664356
maximum: Optional[float] = field(init=False)
@@ -4846,7 +4836,7 @@ def _create_array_property(node: Node) -> Property:
48464836

48474837
items: Items = {}
48484838
if node.type:
4849-
items["type"] = node.type.value
4839+
items["type"] = node.type
48504840
_set_type_specific_keywords(items, node)
48514841

48524842
array_type_dict: TypeDict = {"type": "array", "title": "array"}
@@ -4919,10 +4909,10 @@ def _create_simple_property(node: Node) -> Property:
49194909

49204910
if node.type:
49214911
if node.is_required:
4922-
prop["type"] = node.type.value
4912+
prop["type"] = node.type
49234913
else:
49244914
prop["oneOf"] = [
4925-
{"type": node.type.value, "title": node.type.value},
4915+
{"type": node.type, "title": node.type},
49264916
{"type": "null", "title": "null"},
49274917
]
49284918
elif node.is_required:

tests/unit/synapseclient/extensions/unit_test_create_json_schema.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
GraphTraversalState,
2121
JSONSchema,
2222
JSONSchemaFormat,
23-
JSONSchemaType,
2423
TraversalNode,
2524
_create_array_property,
2625
_create_enum_array_property,
@@ -247,7 +246,7 @@ def test_update_property(self) -> None:
247246
)
248247
def test_node_init(
249248
node_name: str,
250-
expected_type: Optional[JSONSchemaType],
249+
expected_type: str,
251250
expected_is_array: bool,
252251
expected_min: Optional[float],
253252
expected_max: Optional[float],

0 commit comments

Comments
 (0)