Skip to content

[sdk] CLI installs duplicate shell completion entries on repeated --install-completion #12689

@Riddhima8

Description

@Riddhima8

Environment

  • KFP version:
    N/A (CLI usage, not a deployed Kubeflow Pipelines cluster)

  • KFP SDK version:
    main branch (local install from https://github.com/kubeflow/pipelines)

  • All dependencies version:
    pip list | grep kfp

Steps to reproduce

  1. Install shell completion for bash:
    kfp --install-completion bash

2.Run the same command again:
kfp --install-completion bash

3.Open the shell configuration file:
cat ~/.bashrc

Observe that the shell completion initialization line has been appended
multiple times.

*Expected result
The CLI should check whether the shell completion initialization line already
exists in the target shell configuration file before appending it.

Running kfp --install-completion <shell> multiple times should not result in
duplicate entries in the shell configuration file.

*Materials and Reference
Source code:
sdk/python/kfp/cli/cli.py

*Relevant function:
_install_completion(shell: str)

*Current behavior:
The completion statement is appended unconditionally using file append mode,
which leads to duplicate shell completion entries.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions