kedro-org / kedro

Kedro is a toolbox for production-ready data science. It uses software engineering best practices to help you create data engineering and data science pipelines that are reproducible, maintainable, and modular.
https://kedro.org
Apache License 2.0
10.02k stars 906 forks source link

`kedro --version` isn't working #4296

Closed ankatiyar closed 2 weeks ago

ankatiyar commented 2 weeks ago

Description

Reported by @noklam, since adding lazy loading of Kedro subcommands, the --version/-V option isn't working.

Context

This bug is originating in Kedro 0.19.7 -> https://github.com/kedro-org/kedro/pull/3883

noklam commented 2 weeks ago

Usage: kedro [OPTIONS] COMMAND [ARGS]... Try 'kedro -h' for help.

Error: No such option: -v

This is the stack trace when run kedro -V, kedro -v or kedro --version

noklam commented 2 weeks ago

While investgating this issue, I think it's worth checking why CI didn't catch this error, we have this test inplace.

    def test_print_version(self):
        """Check that `kedro --version` and `kedro -V` outputs contain
        the current package version."""
        result = CliRunner().invoke(cli, ["--version"])

        assert result.exit_code == 0
        assert version in result.output
DimedS commented 2 weeks ago

how to reproduce the error? the command works well for me

noklam commented 2 weeks ago

@DimedS kedro -V,r kedro --version as mentioned. Are you using the main branch? Can you copy the terminal log when you do kedro?

astrojuanlu commented 2 weeks ago

I confirm kedro -V and kedro --version both give No such option errors with 0.19.9

ankatiyar commented 2 weeks ago

I figured out what the problem is: https://github.com/kedro-org/kedro/blob/a1fae5018f35243a5e49a54a9dd3223b2c4ea743/kedro/framework/cli/cli.py#L220

Due to the changes in lazy loading PR, I re-ordered the global commands list to consider

So if any plugin with global commands (eg. Kedro-Viz) is installed in your env, the --version option doesn't work. It works when you uninstall Kedro viz. Which is why it must be working in the CI and for @DimedS

The solution is simply to re-order the command groups to [cli, *load_entry_points("global"), global_commands] but that would mean that users can't overwrite kedro info which I think is acceptable.