[azure-ai-ml] Enable hdfs input/output mode for Spark jobs and components - #48314
[azure-ai-ml] Enable hdfs input/output mode for Spark jobs and components#48314lavakumarrepala wants to merge 4 commits into
Conversation
Adds InputOutputModes.HDFS and REST mappings, and updates the Spark input/output mode validator to accept 'hdfs' in addition to 'direct'. Previously the Python SDK rejected any Spark input/output mode other than 'direct', blocking users from explicitly setting 'hdfs' delivery mode (ICM 586585073). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b49997ca-8f69-4ee8-beca-78dadc4816e5
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds HDFS delivery-mode support for Azure ML Spark jobs and components.
Changes:
- Adds the public
hdfsmode constant and REST input mappings. - Expands Spark validation to accept
directandhdfs. - Adds tests and release notes for the new behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
CHANGELOG.md |
Documents HDFS support. |
constants/_common.py |
Defines InputOutputModes.HDFS. |
_input_output_helpers.py |
Adds HDFS input REST mappings. |
pipeline/_io/mixin.py |
Handles string and enum input modes. |
spark_helpers.py |
Allows HDFS during Spark validation. |
test_pipeline_job_schema.py |
Tests HDFS input round-tripping and validation. |
test_pipeline_job_entity.py |
Updates validation-message expectations. |
|
|
||
| # Only "direct" mode is supported for spark job inputs and outputs | ||
| # Only "direct" and "hdfs" modes are supported for spark job inputs and outputs | ||
| _SPARK_SUPPORTED_MODES = (InputOutputModes.DIRECT, InputOutputModes.HDFS) |
| InputOutputModes.EVAL_MOUNT: InputDeliveryMode.EVAL_MOUNT, | ||
| InputOutputModes.EVAL_DOWNLOAD: InputDeliveryMode.EVAL_DOWNLOAD, | ||
| InputOutputModes.DIRECT: InputDeliveryMode.DIRECT, | ||
| InputOutputModes.HDFS: "Hdfs", |
Regenerated API surface to include the new HDFS enum member so the api-md-consistency CI check passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b49997ca-8f69-4ee8-beca-78dadc4816e5
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/_input_output_helpers.py:118
- The HDFS mapping is only added for inputs. A standalone Spark
Output(mode="hdfs")now passes_validate_input_output_mode, butSparkJob._to_rest_object()callsto_rest_data_outputs(), which indexesOUTPUT_MOUNT_MAPPING_TO_RESTand raisesKeyError; reading an HDFS output similarly fails infrom_rest_data_outputs(). Add the raw"Hdfs"mapping in both output mapping directions.
InputOutputModes.HDFS: "Hdfs",
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/spark_helpers.py:125
- YAML-loaded Spark jobs still reject
hdfsbefore this validator runs.SparkJobSchemausesInputsField/OutputsField, whileDataInputSchema,MLTableInputSchema, andOutputSchemahard-code allowed modes without HDFS (_schema/job/input_output_entry.py:99-161). Add HDFS to the applicable Spark job YAML schemas and cover loading a Spark YAML with HDFS input/output modes.
_SPARK_SUPPORTED_MODES = (InputOutputModes.DIRECT, InputOutputModes.HDFS)
sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py:840
- The public
InputandOutputconstructor docstrings still list their accepted modes withouthdfs(entities/_inputs_outputs/input.py:38-42andoutput.py:79-83). This leaves the API reference inconsistent with the new public constant and changelog. Addhdfsto both mode descriptions and clarify that it is supported for Spark jobs/components.
HDFS = "hdfs"
"""HDFS asset type."""
| mode_val = val.mode.value if hasattr(val.mode, "value") else val.mode | ||
| rest_dataset_literal_inputs[name].update({"mode": mode_val}) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/_input_output_helpers.py:118
- HDFS is added only to the input mappings. A Spark
Output(mode="hdfs")now passes validation, butto_rest_data_outputsindexesOUTPUT_MOUNT_MAPPING_TO_RESTand raisesKeyError; output deserialization has the same gap. Add rawHdfsmappings in both output directions.
InputOutputModes.HDFS: "Hdfs",
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_io/mixin.py:274
- This enum-or-string fallback is applied only to inputs.
_to_rest_outputsstill evaluatesbinding["mode"].value; because HDFS must use the raw string"Hdfs", a Spark output bound to a pipeline output will raiseAttributeError. Apply the same normalization to output bindings.
mode_val = val.mode.value if hasattr(val.mode, "value") else val.mode
rest_dataset_literal_inputs[name].update({"mode": mode_val})
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/spark_helpers.py:125
- Spark jobs loaded from YAML still reject
mode: hdfsbefore reaching this validator.SparkJobSchemausesDataInputSchema/ModelInputSchema/MLTableInputSchemaandOutputSchema, and theirallowed_valuesomit HDFS (_schema/job/input_output_entry.py:79-160). Add HDFS to the applicable Spark job schemas and cover standalone and inline Spark YAML loading.
# Only "direct" and "hdfs" modes are supported for spark job inputs and outputs
_SPARK_SUPPORTED_MODES = (InputOutputModes.DIRECT, InputOutputModes.HDFS)
sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py:840
- The public
Input.modeandOutput.modedocstrings still list only the previous modes, so generated API documentation does not describe when this new public value is supported. Update both mode descriptions to include HDFS for Spark jobs/components.
HDFS = "hdfs"
"""HDFS asset type."""
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/_input_output_helpers.py:118
- HDFS is added only to the input mappings, but the validator now accepts it for outputs too. Serializing a Spark
Output(mode="hdfs")reachesto_rest_data_outputs()and indexesOUTPUT_MOUNT_MAPPING_TO_REST["hdfs"], which raisesKeyError; deserializing an output returned asHdfsfails similarly. Add HDFS to both output mappings so the advertised output support actually round-trips.
InputOutputModes.HDFS: "Hdfs",
Description
Enables the
hdfsinput/output delivery mode for Spark jobs and components inazure-ai-ml.Fixes ICM the service defaults Spark inputs to
hdfs, but the Python SDK previously rejected any Spark input/output mode other thandirect, so users could not explicitly setmode="hdfs". This blocked region-expansion work for the MSAI Data Platform team.Root cause
spark_helpers._validate_input_output_modeallowed onlyInputOutputModes.DIRECTand raised aValidationExceptionbefore serialization for any other mode. Adding anHDFSconstant/mapping alone (as in #46925) is insufficient because this validator rejectshdfsfirst.Changes
spark_helpers.py— Spark input/output validator now accepts bothdirectandhdfs(new_SPARK_SUPPORTED_MODES). Error message updated accordingly.constants/_common.py— addedInputOutputModes.HDFS = "hdfs"._input_output_helpers.py— REST mappingsHDFS -> "Hdfs"and"Hdfs"/"hdfs" -> HDFS; binding-input path uses.mode.lower()for consistency.pipeline/_io/mixin.py— tolerate both enum and stringmodevalues.hdfs/directtest, Spark rejects unsupported mode test; updated 4 existing Spark validation message expectations.Validation
blackformatting clean on changed files.Note for reviewers
InputDeliveryMode(v2023_04_01_preview) has noHdfsenum member, so the raw string"Hdfs"is sent on the wire. Per the ICM, other Spark components already submit withhdfs, so the service accepts it — please confirm for this API version.Checklist
ICR: https://msdata.visualstudio.com/Vienna/_workitems/edit/3842468