Skip to content

Commit

Permalink
LIU-417: PR comments from Sourcery
Browse files Browse the repository at this point in the history
  • Loading branch information
myxie committed Nov 15, 2024
1 parent 551438e commit ae76261
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions daliuge-translator/dlg/dropmake/graph_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ def apply_active_configuration(logical_graph: dict) -> dict:
idx = get_key_idx_from_list(node_id, nodeDataArray)
if idx is None:
LOGGER.warning(
"%s present in activeConfig but not available in Logical Graph."
"%s present in activeConfig but not available in Logical Graph.",
node_id
)
continue
node_name = nodeDataArray[idx]["name"]
for field_id, config_field in activeConfig["nodes"][node_id]["fields"].items():
for field_id, cfg_field in activeConfig["nodes"][node_id]["fields"].items():
fieldidx = get_key_idx_from_list(field_id, nodeDataArray[idx]["fields"])
field = nodeDataArray[idx]["fields"][fieldidx]
prev_value = field["value"]
field["value"] = config_field["value"]
field["value"] = cfg_field["value"]
field_name = field["name"]
LOGGER.info("Updating: Node %s, Field %s, from %s to %s",
node_name, field_name, str(prev_value), str(field["value"]))
Expand Down Expand Up @@ -96,10 +97,10 @@ def is_config_invalid(logical_graph: dict) -> bool:
:return: True if the config has correct keys and they are present.
"""

checkActiveId = logical_graph.get(ACTIVE_CONFIG_KEY, None)
checkActiveId = logical_graph.get(ACTIVE_CONFIG_KEY)
if not checkActiveId:
LOGGER.warning("No %s data available in Logical Graph.", ACTIVE_CONFIG_KEY)
checkGraphConfig = logical_graph.get(CONFIG_KEY, None)
checkGraphConfig = logical_graph.get(CONFIG_KEY)
if not checkGraphConfig:
LOGGER.warning("No %s data available in Logical Graph.", CONFIG_KEY)

Expand Down
4 changes: 2 additions & 2 deletions daliuge-translator/test/dropmake/test_graph_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

try:
from importlib.resources import files, as_file
except (ImportError, ModuleNotFoundError):
except ModuleNotFoundError:
from importlib_resources import files

LOG_PRFIX = "WARNING:dlg.dropmake.graph_config:"
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_apply_with_empty_config(self):
- Keys from the activeGraphConfigId or graphConfigurations are not found in
the logical graph.
"""
lg = get_lg_from_fname(f"ArrayLoopNoActiveID.graph")
lg = get_lg_from_fname("ArrayLoopNoActiveID.graph")
with self.assertLogs('root', level="WARNING") as cm:
alt_lg = apply_active_configuration(lg)
self.assertEqual(
Expand Down

0 comments on commit ae76261

Please sign in to comment.