Skip to content

Commit 9990cf5

Browse files
authored
Remove internal import from pipeline builder (Azure#28857)
Signed-off-by: Brynn Yin <[email protected]>
1 parent ac12f80 commit 9990cf5

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_internal/_utils/_utils.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

sdk/ml/azure-ai-ml/azure/ai/ml/_internal/entities/_input_outputs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from typing import Dict, Optional, Union
55

66
from azure.ai.ml import Input, Output
7+
from azure.ai.ml._internal._schema.input_output import SUPPORTED_INTERNAL_PARAM_TYPES
8+
from azure.ai.ml._utils.utils import get_all_enum_values_iter
9+
from azure.ai.ml.constants import AssetTypes
10+
from azure.ai.ml.constants._common import InputTypes
711
from azure.ai.ml.constants._component import ComponentParameterTypes, IOConstants
812

913
_INPUT_TYPE_ENUM = "enum"
@@ -127,3 +131,22 @@ def _from_base(cls, _output: Union[Output, Dict]) -> Optional["InternalOutput"]:
127131
_output.__class__ = InternalOutput
128132
return _output
129133
return InternalOutput(**_output)
134+
135+
def map_pipeline_output_type(self):
136+
"""Map output type to pipeline output type."""
137+
138+
def _map_primitive_type(_type):
139+
"""Convert double and float to number type."""
140+
_type = _type.lower()
141+
if _type in ["double", "float"]:
142+
return InputTypes.NUMBER
143+
return _type
144+
145+
if self.type in list(get_all_enum_values_iter(AssetTypes)):
146+
return self.type
147+
if self.type in SUPPORTED_INTERNAL_PARAM_TYPES:
148+
return _map_primitive_type(self.type)
149+
if self.type in ["AnyFile"]:
150+
return AssetTypes.URI_FILE
151+
# Handle AnyDirectory and the other types.
152+
return AssetTypes.URI_FOLDER

sdk/ml/azure-ai-ml/azure/ai/ml/dsl/_pipeline_component_builder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from inspect import Parameter, signature
1212
from typing import Callable, Union
1313

14-
from azure.ai.ml._internal._utils._utils import _map_internal_output_type
1514
from azure.ai.ml._utils._func_utils import get_outputs_and_locals
1615
from azure.ai.ml._utils.utils import (
1716
is_valid_node_name,
@@ -259,6 +258,13 @@ def _build_pipeline_outputs(self, outputs: typing.Dict[str, NodeOutput]):
259258
is_control=value.is_control,
260259
)
261260

261+
# Hack: map internal output type to pipeline output type
262+
def _map_internal_output_type(_meta):
263+
"""Map component output type to valid pipeline output type."""
264+
if type(_meta).__name__ != "InternalOutput":
265+
return _meta.type
266+
return _meta.map_pipeline_output_type()
267+
262268
# Note: Here we set PipelineOutput as Pipeline's output definition as we need output binding.
263269
output_meta = Output(
264270
type=_map_internal_output_type(meta),

0 commit comments

Comments
 (0)