Skip to content

Commit 7f2c061

Browse files
committed
changed display name to display label for consistency
1 parent 87bddfe commit 7f2c061

2 files changed

Lines changed: 49 additions & 49 deletions

File tree

synapseclient/extensions/curator/schema_generation.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4630,9 +4630,9 @@ class TraversalNode: # pylint: disable=too-many-instance-attributes
46304630
name: The name of the node
46314631
source_node: The name of the node where the graph traversal started
46324632
dmge: A DataModelGraphExplorer with the data model loaded
4633-
display_name: The display name of the node
4633+
display_label: The display name of the node
46344634
valid_values: The valid values of the node if any
4635-
valid_value_display_names: The display names of the valid values of the node if any
4635+
valid_value_display_labels: The display names of the valid values of the node if any
46364636
is_required: Whether or not this node is required
46374637
dependencies: This nodes dependencies
46384638
description: This nodes description, gotten from the comment in the data model
@@ -4977,16 +4977,16 @@ def update_processed_nodes_with_current_node(self) -> None:
49774977
self._processed_nodes.append(self.current_node.name)
49784978

49794979
def get_conditional_properties(
4980-
self, use_node_display_names: bool = True
4980+
self, use_display_labels: bool = True
49814981
) -> list[tuple[str, str]]:
49824982
"""Returns the conditional dependencies for the current node
49834983
49844984
Raises:
49854985
ValueError: If there is no current node
49864986
49874987
Arguments:
4988-
use_node_display_names: If True the the attributes in the
4989-
conditional dependencies are return with their display names
4988+
use_display_labels: If True the the attributes in the
4989+
conditional dependencies are return with their display labels
49904990
49914991
Returns:
49924992
The watched_property, and the value for it that triggers the condition
@@ -4998,7 +4998,7 @@ def get_conditional_properties(
49984998
if value in self._valid_values_map:
49994999
properties = sorted(self._valid_values_map[value])
50005000
for watched_property in properties:
5001-
if use_node_display_names:
5001+
if use_display_labels:
50025002
watched_property = self.dmge.get_nodes_display_names(
50035003
[watched_property]
50045004
)[0]
@@ -5007,32 +5007,32 @@ def get_conditional_properties(
50075007
return conditional_properties
50085008

50095009
def _update_valid_values_map(
5010-
self, node_display_name: str, valid_values_display_names: list[str]
5010+
self, node_display_label: str, valid_values_display_labels: list[str]
50115011
) -> None:
50125012
"""Updates the valid_values map
50135013
50145014
Arguments:
5015-
node_display_name: The display name of the node
5016-
valid_values_display_names: The display names of the the nodes valid values
5015+
node_display_label: The display label of the node
5016+
valid_values_display_labels: The display labels of the the nodes valid values
50175017
"""
5018-
for node in valid_values_display_names:
5018+
for node in valid_values_display_labels:
50195019
if node not in self._valid_values_map:
50205020
self._valid_values_map[node] = []
5021-
self._valid_values_map[node].append(node_display_name)
5021+
self._valid_values_map[node].append(node_display_label)
50225022

50235023
def _update_reverse_dependencies(
5024-
self, node_display_name: str, node_dependencies_display_names: list[str]
5024+
self, node_display_label: str, node_dependencies_display_labels: list[str]
50255025
) -> None:
50265026
"""Updates the reverse dependencies
50275027
50285028
Arguments:
5029-
node_display_name: The display name of the node
5030-
node_dependencies_display_names: the display names of the reverse dependencies
5029+
node_display_label: The display label of the node
5030+
node_dependencies_display_labels: the display labels of the reverse dependencies
50315031
"""
5032-
for dep in node_dependencies_display_names:
5032+
for dep in node_dependencies_display_labels:
50335033
if dep not in self._reverse_dependencies:
50345034
self._reverse_dependencies[dep] = []
5035-
self._reverse_dependencies[dep].append(node_display_name)
5035+
self._reverse_dependencies[dep].append(node_display_label)
50365036

50375037
def _update_nodes_to_process(self, nodes: list[str]) -> None:
50385038
"""Updates the nodes to process with the input nodes
@@ -5137,7 +5137,7 @@ def update_property(self, property_dict: dict[str, Property]) -> None:
51375137
def _set_conditional_dependencies(
51385138
json_schema: JSONSchema,
51395139
graph_state: GraphTraversalState,
5140-
use_display_names: bool = True,
5140+
use_display_labels: bool = True,
51415141
) -> None:
51425142
"""
51435143
This sets conditional requirements in the "allOf" keyword.
@@ -5177,19 +5177,19 @@ def _set_conditional_dependencies(
51775177
Arguments:
51785178
json_schema: The JSON Scheme where the node might be set as a property
51795179
graph_state: The instance tracking the current state of the graph
5180-
use_display_names: If True, the properties and enums in the JSONSchema
5181-
will be written using display names, otherwise the formatted labels will be used
5180+
use_display_labels: If True, the properties and enums in the JSONSchema
5181+
will be written using display labels, otherwise the formatted labels will be used
51825182
51835183
"""
51845184
if graph_state.current_node is None:
51855185
raise ValueError("Node Processor contains no node.")
51865186

5187-
if use_display_names:
5187+
if use_display_labels:
51885188
node_name = graph_state.current_node.display_name
51895189
else:
51905190
node_name = graph_state.current_node.name
51915191

5192-
conditional_properties = graph_state.get_conditional_properties(use_display_names)
5192+
conditional_properties = graph_state.get_conditional_properties(use_display_labels)
51935193
for prop in conditional_properties:
51945194
attribute, value = prop
51955195
conditional_schema = {
@@ -5203,7 +5203,7 @@ def _set_conditional_dependencies(
52035203

52045204

52055205
def _create_enum_array_property(
5206-
node: TraversalNode, use_display_names: bool = True
5206+
node: TraversalNode, use_display_labels: bool = True
52075207
) -> Property:
52085208
"""
52095209
Creates a JSON Schema property array with enum items
@@ -5218,13 +5218,13 @@ def _create_enum_array_property(
52185218
52195219
Arguments:
52205220
node: The node to make the property of
5221-
use_display_names: If True, the properties and enums in the JSONSchema
5222-
will be written using display names, otherwise the formatted labels will be used
5221+
use_display_labels: If True, the properties and enums in the JSONSchema
5222+
will be written using display labels, otherwise the formatted labels will be used
52235223
52245224
Returns:
52255225
JSON object
52265226
"""
5227-
if use_display_names:
5227+
if use_display_labels:
52285228
valid_values = node.valid_value_display_names
52295229
else:
52305230
valid_values = node.valid_values
@@ -5269,7 +5269,7 @@ def _create_array_property(node: TraversalNode) -> Property:
52695269

52705270

52715271
def _create_enum_property(
5272-
node: TraversalNode, use_display_names: bool = True
5272+
node: TraversalNode, use_display_labels: bool = True
52735273
) -> Property:
52745274
"""
52755275
Creates a JSON Schema property enum
@@ -5282,13 +5282,13 @@ def _create_enum_property(
52825282
52835283
Arguments:
52845284
node: The node to make the property of
5285-
use_display_names: If True, the properties and enums in the JSONSchema
5286-
will be written using display names, otherwise the formatted labels will be used
5285+
use_display_labels: If True, the properties and enums in the JSONSchema
5286+
will be written using display labels, otherwise the formatted labels will be used
52875287
52885288
Returns:
52895289
JSON object
52905290
"""
5291-
if use_display_names:
5291+
if use_display_labels:
52925292
valid_values = node.valid_value_display_names
52935293
else:
52945294
valid_values = node.valid_values
@@ -5347,27 +5347,27 @@ def _set_type_specific_keywords(schema: dict[str, Any], node: TraversalNode) ->
53475347
def _set_property(
53485348
json_schema: JSONSchema,
53495349
node: TraversalNode,
5350-
use_display_names: bool = True,
5350+
use_display_labels: bool = True,
53515351
) -> None:
53525352
"""
53535353
Sets a property in the JSON schema. that is required by the schema
53545354
53555355
Arguments:
53565356
json_schema: The JSON Scheme where the node might be set as a property
53575357
graph_state: The node the write the property for
5358-
use_display_names: If True, the properties and enums in the JSONSchema
5359-
will be written using display names, otherwise the formatted labels will be used
5358+
use_display_labels: If True, the properties and enums in the JSONSchema
5359+
will be written using display labels, otherwise the formatted labels will be used
53605360
"""
5361-
if use_display_names:
5361+
if use_display_labels:
53625362
node_name = node.display_name
53635363
else:
53645364
node_name = node.name
53655365

53665366
if node.valid_values:
53675367
if node.is_array:
5368-
prop = _create_enum_array_property(node, use_display_names)
5368+
prop = _create_enum_array_property(node, use_display_labels)
53695369
else:
5370-
prop = _create_enum_property(node, use_display_names)
5370+
prop = _create_enum_property(node, use_display_labels)
53715371

53725372
else:
53735373
if node.is_array:
@@ -5391,7 +5391,7 @@ def _process_node(
53915391
json_schema: JSONSchema,
53925392
graph_state: GraphTraversalState,
53935393
logger: Logger,
5394-
use_display_names: bool = True,
5394+
use_display_labels: bool = True,
53955395
) -> None:
53965396
"""
53975397
Processes a node in the data model graph.
@@ -5401,8 +5401,8 @@ def _process_node(
54015401
Argument:
54025402
json_schema: The JSON Scheme where the node might be set as a property
54035403
graph_state: The instance tracking the current state of the graph
5404-
use_display_names: If True, the properties and enums in the JSONSchema
5405-
will be written using display names, otherwise the formatted labels will be used
5404+
use_display_labels: If True, the properties and enums in the JSONSchema
5405+
will be written using display labels, otherwise the formatted labels will be used
54065406
"""
54075407
if graph_state.current_node is None:
54085408
raise ValueError("Node Processor contains no node.")
@@ -5414,15 +5414,15 @@ def _process_node(
54145414
_set_conditional_dependencies(
54155415
json_schema=json_schema,
54165416
graph_state=graph_state,
5417-
use_display_names=use_display_names,
5417+
use_display_labels=use_display_labels,
54185418
)
54195419
# This is to ensure that all properties that are conditional dependencies are not
54205420
# required, but only become required when the conditional dependency is met.
54215421
graph_state.current_node.is_required = False
54225422
_set_property(
54235423
json_schema=json_schema,
54245424
node=graph_state.current_node,
5425-
use_display_names=use_display_names,
5425+
use_display_labels=use_display_labels,
54265426
)
54275427
graph_state.update_processed_nodes_with_current_node()
54285428
logger.info("Property set in JSON Schema for %s", graph_state.current_node.name)
@@ -5467,7 +5467,7 @@ def create_json_schema( # pylint: disable=too-many-arguments
54675467
write_schema: bool = True,
54685468
schema_path: Optional[str] = None,
54695469
jsonld_path: Optional[str] = None,
5470-
use_display_names: bool = True,
5470+
use_display_labels: bool = True,
54715471
) -> dict[str, Any]:
54725472
"""
54735473
Creates a JSONSchema dict for the datatype in the data model.
@@ -5494,7 +5494,7 @@ def create_json_schema( # pylint: disable=too-many-arguments
54945494
when it is hosted on the Internet).
54955495
schema_path: Where to save the JSON Schema file
54965496
jsonld_path: Used to name the file if the path isn't supplied
5497-
use_display_names: If True, the properties and enums in the JSONSchema
5497+
use_display_labels: If True, the properties and enums in the JSONSchema
54985498
will be written using display names, otherwise the formatted labels will be used
54995499
55005500
Returns:
@@ -5514,7 +5514,7 @@ def create_json_schema( # pylint: disable=too-many-arguments
55145514
json_schema=json_schema,
55155515
graph_state=graph_state,
55165516
logger=logger,
5517-
use_display_names=use_display_names,
5517+
use_display_labels=use_display_labels,
55185518
)
55195519
graph_state.move_to_next_node()
55205520

@@ -5718,7 +5718,7 @@ def generate_jsonschema(
57185718
logger=synapse_client.logger,
57195719
write_schema=True,
57205720
schema_path=schema_path,
5721-
use_display_names=(data_model_labels == "display_label"),
5721+
use_display_labels=(data_model_labels == "display_label"),
57225722
)
57235723
for data_type, schema_path in zip(data_types, schema_paths)
57245724
]

tests/unit/synapseclient/extensions/unit_test_create_json_schema.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ def test_create_json_schema_with_class_label(
922922
datatype=datatype,
923923
schema_name=f"{datatype}_validation",
924924
schema_path=test_path,
925-
use_display_names=False,
925+
use_display_labels=False,
926926
logger=logger,
927927
)
928928
with open(expected_path, encoding="utf-8") as file1, open(
@@ -997,7 +997,7 @@ def test_create_json_schema_with_class_label_using_jsonld(
997997
datatype=datatype,
998998
schema_name=f"{datatype}_validation",
999999
schema_path=test_path,
1000-
use_display_names=False,
1000+
use_display_labels=False,
10011001
logger=logger,
10021002
)
10031003
with open(expected_path, encoding="utf-8") as file1, open(
@@ -1161,7 +1161,7 @@ def test_set_conditional_dependencies_nothing_added(
11611161
gts.current_node.name = "CancerType"
11621162
gts.current_node.display_name = "Cancer Type"
11631163
_set_conditional_dependencies(
1164-
json_schema=json_schema, graph_state=gts, use_display_names=False
1164+
json_schema=json_schema, graph_state=gts, use_display_labels=False
11651165
)
11661166
assert json_schema == {"allOf": []}
11671167

@@ -1245,7 +1245,7 @@ def test_set_conditional_dependencies(
12451245
gts.current_node.name = "CancerType"
12461246
gts.current_node.display_name = "Cancer Type"
12471247
_set_conditional_dependencies(
1248-
json_schema=json_schema, graph_state=gts, use_display_names=False
1248+
json_schema=json_schema, graph_state=gts, use_display_labels=False
12491249
)
12501250
assert json_schema == expected_schema
12511251

@@ -1338,7 +1338,7 @@ def test_set_property(
13381338
) -> None:
13391339
"""Tests for set_property"""
13401340
schema = JSONSchema()
1341-
_set_property(schema, test_nodes[node_name], use_display_names=False)
1341+
_set_property(schema, test_nodes[node_name], use_display_labels=False)
13421342
assert schema == expected_schema
13431343

13441344

0 commit comments

Comments
 (0)