Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Conversation

@skekre98
Copy link
Contributor

@skekre98 skekre98 commented Oct 28, 2020

I have currently initialized the cli with version and setup. I have currently left the setup function open since I believe the set up workflow is a work in progress. Let me know how you'd like me to handle this and what else to build out.

@turbaszek
Copy link
Member

I have currently left the setup function open since I believe the set up workflow is a work in progress.

@skekre98 it would be awesome to rewrite it to using click 👍

@turbaszek
Copy link
Member

Also the click library should be added to required dependencies in setup.py:

➜ kibble version
Traceback (most recent call last):
  File "/Users/turbaszek/.pyenv/versions/kibble/bin/kibble", line 33, in <module>
    sys.exit(load_entry_point('apache-kibble', 'console_scripts', 'kibble')())
  File "/Users/turbaszek/.pyenv/versions/kibble/bin/kibble", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/Users/turbaszek/.pyenv/versions/3.8.0/lib/python3.8/importlib/metadata.py", line 75, in load
    module = import_module(match.group('module'))
  File "/Users/turbaszek/.pyenv/versions/3.8.0/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/turbaszek/code/kibble/kibble/__main__.py", line 17, in <module>
    import click
ModuleNotFoundError: No module named 'click'

Adding this click==7.1.2 to setup.py INSTALL_REQUIREMENTS should solve the issue

Copy link
Member

@turbaszek turbaszek left a comment

Choose a reason for hiding this comment

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

The current changes don't work. Please see the comments. Once fixed it should look good!

➜ kibble
Usage: kibble [OPTIONS] COMMAND [ARGS]...

  A simple command line tool for kibble

Options:
  --help  Show this message and exit.

Commands:
  setup    starts the setup process for kibble
  version  displays the current kibble versio

@turbaszek turbaszek added the area:cli CLI related issues label Oct 28, 2020
@skekre98
Copy link
Contributor Author

Hi @turbaszek, how are you building the actual cli? I was testing by running python __main__.py 😅. In other words how can I run kibble version or other commands with kibble?

@turbaszek
Copy link
Member

Hi @turbaszek, how are you building the actual cli? I was testing by running python __main__.py 😅. In other words how can I run kibble version or other commands with kibble?

Here are basic information:
https://github.com/apache/kibble/blob/main/CONTRIBUTING.md#development-installation

You need to install kibble package, the -e flag is for editable installation.

@skekre98
Copy link
Contributor Author

skekre98 commented Nov 1, 2020

@turbaszek apologies for the delay. I've been able to successfully migrate save_config from setup.py to __main__.py by using KibbleConfigParser. Will work on implementing create_index using click as well. Let me know if there is anything else you would like to see as well.

@skekre98
Copy link
Contributor Author

skekre98 commented Nov 1, 2020

This is the current output with the cli:

(home) Sharvils-MacBook-Pro:kibble sharvilkekre$ kibble
Usage: kibble [OPTIONS] COMMAND [ARGS]...

  A simple command line tool for kibble

Options:
  --help  Show this message and exit.

Commands:
  setup    starts the setup process for kibble
  version  displays the current kibble version
(home) Sharvils-MacBook-Pro:kibble sharvilkekre$ kibble version
1.0.0dev
(home) Sharvils-MacBook-Pro:kibble sharvilkekre$ kibble setup
Welcome to the Apache Kibble setup script!
Elasticsearch: elasticsearch:9200
~/projects/kibble/kibble/api/yaml/kibble.yaml already exists! Writing to ~/projects/kibble/kibble/api/yaml/kibble.yaml.tmp instead
Writing Kibble config to ~/projects/kibble/kibble/api/yaml/kibble.yaml.tmp

All done, Kibble should...work now :)

This is currently only missing create_index

setup.py Outdated
"python-dateutil==2.8.1",
"PyYAML==5.3.1",
"tenacity==6.2.0",
"click==7.1.2",
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep this list in alphabetical order 👌

@turbaszek
Copy link
Member

@skekre98 could you please rebase?

Comment on lines 104 to 108
save_config(
mlserver=conf.get("mail", "mailhost"),
conn_uri=conn_uri,
dbname=conf.get("elasticsearch", "dbname"),
)
Copy link
Member

Choose a reason for hiding this comment

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

The setup command should do much more than this (especially that after #83 we can abandon saving the config). The setup command should perform whole logic of:
https://github.com/apache/kibble/blob/6959f3c51a594941abc08face115cf3057aaed88/kibble/setup/setup.py#L233-L276

Also it should parse the arguments using click not argparse - that's the main point of using click 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, so is it taking in more arguments than what is in kibble.ini?

Copy link
Member

Choose a reason for hiding this comment

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

The argparser is implementing a cli. But we would like to migrate to click as it's easier to use. So we need to preserve whole logic of this argument parser (cli):
https://github.com/apache/kibble/blob/6959f3c51a594941abc08face115cf3057aaed88/kibble/setup/setup.py#L41-L87

So we need to use @click.option decorators for every option in existing cli

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh got it. So we are not trying to use KibbleConfigParser? Apologies for the misunderstanding.

Copy link
Member

Choose a reason for hiding this comment

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

@skekre98 we are using it to set default values like that:
https://github.com/apache/kibble/blob/6959f3c51a594941abc08face115cf3057aaed88/kibble/setup/setup.py#L47

We don't have to create KibbleConfigParser instance every time we want to access it. It's enough to use the conf object:
https://github.com/apache/kibble/blob/6959f3c51a594941abc08face115cf3057aaed88/kibble/configuration.py#L32-L33

@turbaszek
Copy link
Member

Hey @skekre98 any update on this one?

@skekre98
Copy link
Contributor Author

skekre98 commented Nov 9, 2020

Hi @turbaszek, this is still in progress. I have been caught up with work the past few days.

@github-actions github-actions bot removed the area:dev label Nov 12, 2020
@skekre98
Copy link
Contributor Author

Got it, I've noticed this PR has quite a lot of fluff so I'm going to go ahead and close this one and open a new one with the correct changes. Apologies for the misunderstanding 😅

@skekre98 skekre98 closed this Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area:cli CLI related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants