Skip to content

Commit 28d53ac

Browse files
authored
[ML][Pipelines] Avoid bool test for expression in do-while scenario (Azure#27212)
* fix: avoid two bool test for expression * fix: avoid one place bool test
1 parent 1076ba3 commit 28d53ac

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_builders/condition_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _validate_params(self, raise_error=True) -> MutableValidationResult:
5858
if isinstance(self.condition, InputOutputBase) and self.condition._meta is not None:
5959
# pylint: disable=protected-access
6060
output_definition = self.condition._meta
61-
if output_definition and not output_definition.is_control:
61+
if output_definition is not None and not output_definition.is_control:
6262
validation_result.append_error(
6363
yaml_path="condition",
6464
message=f"'condition' of dsl.condition node must have 'is_control' field "

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_builders/do_while.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ def _validate_port(self, port, node_ports, port_type, yaml_path):
192192
port_obj = node_ports.get(port, None)
193193
else:
194194
port_obj = port
195-
if port_obj and port_obj._owner._instance_id != self.body._instance_id: # pylint: disable=protected-access
195+
if (
196+
port_obj is not None
197+
and port_obj._owner._instance_id != self.body._instance_id # pylint: disable=protected-access
198+
):
196199
# Check the port owner is dowhile body.
197200
validation_result.append_error(
198201
yaml_path=yaml_path,
@@ -201,7 +204,7 @@ def _validate_port(self, port, node_ports, port_type, yaml_path):
201204
f"dowhile only accept {port_type} of the body: {self.body.name}."
202205
),
203206
)
204-
elif not port_obj or port_obj._name not in node_ports: # pylint: disable=protected-access
207+
elif port_obj is None or port_obj._name not in node_ports: # pylint: disable=protected-access
205208
# Check port is exist in dowhile body.
206209
validation_result.append_error(
207210
yaml_path=yaml_path,

0 commit comments

Comments
 (0)