Skip to content

[azure-ai-ml] Enable hdfs input/output mode for Spark jobs and components - #48314

Open
lavakumarrepala wants to merge 4 commits into
mainfrom
v-rlava/spark-hdfs-input-mode
Open

[azure-ai-ml] Enable hdfs input/output mode for Spark jobs and components#48314
lavakumarrepala wants to merge 4 commits into
mainfrom
v-rlava/spark-hdfs-input-mode

Conversation

@lavakumarrepala

@lavakumarrepala lavakumarrepala commented Jul 28, 2026

Copy link
Copy Markdown
Member

Description

Enables the hdfs input/output delivery mode for Spark jobs and components in azure-ai-ml.

Fixes ICM the service defaults Spark inputs to hdfs, but the Python SDK previously rejected any Spark input/output mode other than direct, so users could not explicitly set mode="hdfs". This blocked region-expansion work for the MSAI Data Platform team.

Root cause

spark_helpers._validate_input_output_mode allowed only InputOutputModes.DIRECT and raised a ValidationException before serialization for any other mode. Adding an HDFS constant/mapping alone (as in #46925) is insufficient because this validator rejects hdfs first.

Changes

  • spark_helpers.py — Spark input/output validator now accepts both direct and hdfs (new _SPARK_SUPPORTED_MODES). Error message updated accordingly.
  • constants/_common.py — added InputOutputModes.HDFS = "hdfs".
  • _input_output_helpers.py — REST mappings HDFS -> "Hdfs" and "Hdfs"/"hdfs" -> HDFS; binding-input path uses .mode.lower() for consistency.
  • pipeline/_io/mixin.py — tolerate both enum and string mode values.
  • Tests — added HDFS REST round-trip test, Spark accepts hdfs/direct test, Spark rejects unsupported mode test; updated 4 existing Spark validation message expectations.
  • CHANGELOG.md — entry under 1.35.0.

Validation

  • New + updated unit tests pass (3 new, 4 updated, 10 spark-related).
  • black formatting clean on changed files.

Note for reviewers

InputDeliveryMode (v2023_04_01_preview) has no Hdfs enum member, so the raw string "Hdfs" is sent on the wire. Per the ICM, other Spark components already submit with hdfs, so the service accepts it — please confirm for this API version.

Checklist

  • Tests added/updated for the changed behavior.
  • No breaking changes.

ICR: https://msdata.visualstudio.com/Vienna/_workitems/edit/3842468

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

Copy link
Copy Markdown
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.

@lavakumarrepala
lavakumarrepala marked this pull request as ready for review July 29, 2026 04:34
Copilot AI review requested due to automatic review settings July 29, 2026 04:34
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds HDFS delivery-mode support for Azure ML Spark jobs and components.

Changes:

  • Adds the public hdfs mode constant and REST input mappings.
  • Expands Spark validation to accept direct and hdfs.
  • 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
Copilot AI review requested due to automatic review settings July 29, 2026 06:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, but SparkJob._to_rest_object() calls to_rest_data_outputs(), which indexes OUTPUT_MOUNT_MAPPING_TO_REST and raises KeyError; reading an HDFS output similarly fails in from_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 hdfs before this validator runs. SparkJobSchema uses InputsField/OutputsField, while DataInputSchema, MLTableInputSchema, and OutputSchema hard-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 Input and Output constructor docstrings still list their accepted modes without hdfs (entities/_inputs_outputs/input.py:38-42 and output.py:79-83). This leaves the API reference inconsistent with the new public constant and changelog. Add hdfs to both mode descriptions and clarify that it is supported for Spark jobs/components.
    HDFS = "hdfs"
    """HDFS asset type."""

Comment on lines +273 to +274
mode_val = val.mode.value if hasattr(val.mode, "value") else val.mode
rest_dataset_literal_inputs[name].update({"mode": mode_val})
Copilot AI review requested due to automatic review settings July 29, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, but to_rest_data_outputs indexes OUTPUT_MOUNT_MAPPING_TO_REST and raises KeyError; output deserialization has the same gap. Add raw Hdfs mappings 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_outputs still evaluates binding["mode"].value; because HDFS must use the raw string "Hdfs", a Spark output bound to a pipeline output will raise AttributeError. 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: hdfs before reaching this validator. SparkJobSchema uses DataInputSchema/ModelInputSchema/MLTableInputSchema and OutputSchema, and their allowed_values omit 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.mode and Output.mode docstrings 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."""

Copilot AI review requested due to automatic review settings July 31, 2026 04:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") reaches to_rest_data_outputs() and indexes OUTPUT_MOUNT_MAPPING_TO_REST["hdfs"], which raises KeyError; deserializing an output returned as Hdfs fails similarly. Add HDFS to both output mappings so the advertised output support actually round-trips.
    InputOutputModes.HDFS: "Hdfs",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants