← Back to Pull requests

fix(trainer): build container paths with POSIX separators #849

Open
singhharsh1708 opened this pull request with 115 lines diff across 3 files
View on GitHub
singhharsh1708 singhharsh1708 commented on Oct 10, 2026 14:04 UTC
Author

What this PR does / why we need it:

DATASET_PATH, MODEL_PATH, the TorchTune dataset args and the MPI function file path point inside the Linux container but were joined with os.path.join, so a Windows client sent /workspace\dataset and /home/mpiuser\train.py in the TrainJob. This joins them with posixpath. Nothing changes on Linux or macOS.

The new tests swap os.path for ntpath in the module under test, so they fail without the fix on any OS.

Which issue(s) this PR fixes _(optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged)_:

Fixes #848

Checklist:

  • Docs included if any changes are user facing
  • Diff: 115 lines (+101 / -14) across 3 files Reviewer: RobuRishabh Review duration: 78061m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.41) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 115 lines diff across 3 files
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.284
    Real PR Conversation Timeline
    12 items
    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 10, 2026 14:04 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

    google-oss-prow[bot] google-oss-prow[bot] commented on Oct 10, 2026 14:04 UTC
    Bot

    [APPROVALNOTIFIER] This PR is NOT APPROVED

    This pull-request has been approved by:
    Once this PR has been reviewed and has the lgtm label, please assign andreyvelich for approval. For more information see the Kubernetes Code Review Process.

    The full list of commands accepted by this bot can be found here.

    <details open>
    Needs approval from an approver in each of these files:

  • OWNERS
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":["andreyvelich"]} -->

    RobuRishabh RobuRishabh commented on Oct 11, 2026 04:45 UTC
    Contributor

    /ok-to-test

    RobuRishabh RobuRishabh commented on code on Oct 11, 2026 06:05 UTC
    Code Review
    kubeflow/trainer/constants/constants.py:1
    @@ -75,10 +76,10 @@
     WORKSPACE_PATH = "/workspace"
     
     # The path where initializer downloads dataset.
    -DATASET_PATH = os.path.join(WORKSPACE_PATH, "dataset")
    +DATASET_PATH = posixpath.join(WORKSPACE_PATH, "dataset")
     
     # The path where initializer downloads model.
    -MODEL_PATH = os.path.join(WORKSPACE_PATH, "model")
    +MODEL_PATH = posixpath.join(WORKSPACE_PATH, "model")

    Could we add an OS-independent regression assertion for MODEL_PATH as well? The new Windows simulation protects the MPI and dataset paths, but changing this line back to os.path.join() would still leave the focused tests passing. Existing container tests compare OUTPUT_PATH with constants.MODEL_PATH, so both values would be wrong together on Windows. A direct assertion that the Windows simulation still produces "/workspace/model" would cover the remaining requirement from issue #848.

    RobuRishabh RobuRishabh commented on Oct 11, 2026 06:05 UTC
    Reviewer

    Hi @singhharsh1708 thanks for the contribution, left a comment, PTAL

    singhharsh1708 singhharsh1708 commented on code on Oct 12, 2026 18:29 UTC
    Code Review
    kubeflow/trainer/constants/constants.py:1
    @@ -75,10 +76,10 @@
     WORKSPACE_PATH = "/workspace"
     
     # The path where initializer downloads dataset.
    -DATASET_PATH = os.path.join(WORKSPACE_PATH, "dataset")
    +DATASET_PATH = posixpath.join(WORKSPACE_PATH, "dataset")
     
     # The path where initializer downloads model.
    -MODEL_PATH = os.path.join(WORKSPACE_PATH, "model")
    +MODEL_PATH = posixpath.join(WORKSPACE_PATH, "model")

    Added a test for both DATASET_PATH and MODEL_PATH. It fails if either one goes back to os.path.join.

    RobuRishabh RobuRishabh commented on Oct 14, 2026 00:28 UTC
    Contributor

    /lgtm

    andreyvelich andreyvelich commented on code on Oct 31, 2026 00:08 UTC
    Code Review
    kubeflow/trainer/backends/kubernetes/utils_test.py:1
    @@ -1069,6 +1072,55 @@ def test_get_args_using_torchtune_config(test_case: TestCase):
         print("test execution complete")
     
     
    +@pytest.fixture
    +def windows_client(monkeypatch):
    +    """Make the module under test resolve os.path the way a Windows client does."""
    +    monkeypatch.setattr(utils, "os", SimpleNamespace(path=ntpath))
    +
    +
    +def test_get_command_using_train_func_mpi_paths(windows_client):
    andreyvelich andreyvelich commented on Oct 31, 2026 00:09 UTC
    Contributor

    Thank you for fixing our SDK on Windows platforms @singhharsh1708!

    google-oss-prow[bot] google-oss-prow[bot] commented on Nov 03, 2026 06:11 UTC
    Bot

    New changes are detected. LGTM label has been removed.

    singhharsh1708 singhharsh1708 commented on code on Nov 03, 2026 06:13 UTC
    Code Review
    kubeflow/trainer/backends/kubernetes/utils_test.py:1
    @@ -1069,6 +1072,55 @@ def test_get_args_using_torchtune_config(test_case: TestCase):
         print("test execution complete")
     
     
    +@pytest.fixture
    +def windows_client(monkeypatch):
    +    """Make the module under test resolve os.path the way a Windows client does."""
    +    monkeypatch.setattr(utils, "os", SimpleNamespace(path=ntpath))
    +
    +
    +def test_get_command_using_train_func_mpi_paths(windows_client):

    Done, they're TestCases with client_os: windows now and the standalone ones are gone.

    Reviewers
    Assignees
    singhharsh1708 singhharsh1708
    Labels
    risk: low confidence: 89.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 41.4% (MEDIUM) · Higher = larger blast radius
    41.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.3% · Lower = rushed or shallow review
    89.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.4% · Safe to merge
    4.4%
    Repository