Skip to content

Commit 8b1dd74

Browse files
author
GnanasundaramSampath
committed
[azure-ai-ml] Add hdfs input mode mapping for job input serialization
1 parent 5fb0e03 commit 8b1dd74

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ class InputOutputModes:
836836
"""Evaluation download asset type."""
837837
DIRECT = "direct"
838838
"""Direct asset type."""
839+
HDFS = "hdfs"
840+
"""HDFS asset type."""
839841

840842

841843
class ConnectionTypes:

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/_input_output_helpers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
InputDeliveryMode.DIRECT: InputOutputModes.DIRECT,
7070
InputDeliveryMode.EVAL_MOUNT: InputOutputModes.EVAL_MOUNT,
7171
InputDeliveryMode.EVAL_DOWNLOAD: InputOutputModes.EVAL_DOWNLOAD,
72+
"Hdfs": InputOutputModes.HDFS,
73+
"hdfs": InputOutputModes.HDFS,
7274
}
7375

7476
INPUT_MOUNT_MAPPING_TO_REST = {
@@ -79,6 +81,7 @@
7981
InputOutputModes.EVAL_MOUNT: InputDeliveryMode.EVAL_MOUNT,
8082
InputOutputModes.EVAL_DOWNLOAD: InputDeliveryMode.EVAL_DOWNLOAD,
8183
InputOutputModes.DIRECT: InputDeliveryMode.DIRECT,
84+
InputOutputModes.HDFS: "Hdfs",
8285
}
8386

8487

@@ -249,7 +252,7 @@ def to_rest_dataset_literal_inputs(
249252
input_data = LiteralJobInput(value=input_value.path)
250253
# set mode attribute manually for binding job input
251254
if input_value.mode:
252-
input_data.mode = INPUT_MOUNT_MAPPING_TO_REST[input_value.mode]
255+
input_data.mode = INPUT_MOUNT_MAPPING_TO_REST[input_value.mode.lower()]
253256
if getattr(input_value, "path_on_compute", None) is not None:
254257
input_data.pathOnCompute = input_value.path_on_compute
255258
input_data.job_input_type = JobInputType.LITERAL
@@ -279,7 +282,8 @@ def to_rest_dataset_literal_inputs(
279282
input_data = LiteralJobInput(value=str(input_value["value"]))
280283
# set mode attribute manually for binding job input
281284
if "mode" in input_value:
282-
input_data.mode = input_value["mode"]
285+
input_mode = str(input_value["mode"])
286+
input_data.mode = INPUT_MOUNT_MAPPING_TO_REST.get(input_mode.lower(), input_mode)
283287
else:
284288
input_data = LiteralJobInput(value=str(input_value))
285289
input_data.job_input_type = JobInputType.LITERAL

sdk/ml/azure-ai-ml/tests/pipeline_job/unittests/test_pipeline_job_schema.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from azure.ai.ml.entities._inputs_outputs import Input, Output
3333
from azure.ai.ml.entities._job._input_output_helpers import (
3434
INPUT_MOUNT_MAPPING_FROM_REST,
35+
from_rest_inputs_to_dataset_literal,
36+
to_rest_dataset_literal,
3537
validate_pipeline_input_key_characters,
3638
)
3739
from azure.ai.ml.entities._job.automl.search_space_utils import _convert_sweep_dist_dict_to_str_dict
@@ -53,6 +55,24 @@
5355
@pytest.mark.unittest
5456
@pytest.mark.pipeline_test
5557
class TestPipelineJobSchema:
58+
def test_hdfs_input_mode_round_trip(self):
59+
rest_inputs = to_rest_dataset_literal(
60+
{
61+
"hdfs_input": Input(
62+
type=AssetTypes.URI_FOLDER,
63+
path="azureml://datastores/workspaceblobstore/paths/data/",
64+
mode=InputOutputModes.HDFS,
65+
)
66+
},
67+
job_type=None,
68+
)
69+
70+
assert rest_inputs["hdfs_input"].mode == "Hdfs"
71+
72+
sdk_inputs = from_rest_inputs_to_dataset_literal(rest_inputs)
73+
assert isinstance(sdk_inputs["hdfs_input"], Input)
74+
assert sdk_inputs["hdfs_input"].mode == InputOutputModes.HDFS
75+
5676
def test_validate_pipeline_job_keys(self):
5777
def validator(key, assert_valid=True):
5878
if assert_valid:

0 commit comments

Comments
 (0)