robusta-dev / krr

Prometheus-based Kubernetes Resource Recommendations
MIT License
2.57k stars 141 forks source link

krr --install-completion crash #57

Open ganievs opened 1 year ago

ganievs commented 1 year ago

Describe the bug krr --install-completion crashes when krr was install via homebrew

To Reproduce Steps to reproduce the behavior:

$ brew tap robusta-dev/homebrew-krr
$ brew install krr
$ krr --install-completion

Expected behavior Shell completion installed successfuly

Screenshots

Screenshot 2023-05-31 at 12 24 31 Screenshot 2023-05-31 at 12 24 16

Desktop (please complete the following information):

LeaveMyYard commented 1 year ago

Hey, @ganievs

Thanks for finding the bug. Completion feature is provided by the Typer library.

We will try to investigate it. If it will require too much to fix - maybe we will just remove this from the CLI

ganievs commented 1 year ago

Hi there! Seems it's the same issue as described here: https://github.com/tiangolo/typer/issues/54. And solution as described in https://github.com/tiangolo/typer/issues/54#issuecomment-601219336 is to create a python package

ganievs commented 1 year ago

You can publish a package resulting from poetry build and use it in the Homebrew formula.

$ poetry build
$ sha256 dist/robusta_krr-1.3.2.dev0.tar.gz

The Formula's file will look like that:

class Krr < Formula
    include Language::Python::Virtualenv
    desc "Kubernetes Resource Recommender by Robusta"
    homepage "https://github.com/robusta-dev/krr"

    url "https://github.com/ganievs/krr/releases/download/test-homebrew/robusta_krr-1.3.2.dev0.tar.gz"
    version "1.3.2"
    sha256 "75850810d5083ee761662511e0ceefe99e2fad43feae8e53cd393c40e833bf21"

    depends_on "python@3.11"

    def install
        virtualenv_install_with_resources
    end

    test do
        system bin/"krr", "version"
    end
end

I did some tests on my fork and it works well on both Mac and Linux. Test release: https://github.com/ganievs/krr/releases/tag/test-homebrew Homebrew Formula with it: https://github.com/ganievs/homebrew-krr

LeaveMyYard commented 12 months ago

The only issue is that we are building a standalone with pyinstaller to avoid potential dependancy issues But I will think on your solution, thank you for your work

The only think is I am a bit afraid on introducing such a big change for fixing a small problem with --install-completion.

I will come back to this issue in the future after more important stuff is fixed and I will implement your solution. Thanks again

ganievs commented 12 months ago

Sure, No worries!

small problem with --install-completion

I just wanted to highlight the current packaging way might produce some similar bugs https://stackoverflow.com/questions/22241420/execution-of-python-code-with-m-option-or-not

james-sullivan commented 6 months ago

I'm currently having this same issue with version 1.6.0 installing it from homebrew OS: Ventura 13.6.2 M2 Pro

svlandeg commented 3 weeks ago

Hi! Could you check whether https://github.com/tiangolo/typer/pull/237 solves this issue for you?