-
-
Notifications
You must be signed in to change notification settings - Fork 13
Create a CLI #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a CLI #201
Conversation
|
I usually do not test my CLIs, because they are simply wrappers around backend functions which as well tested. I was not sure what your take on this was so I did not remove it from the coverage. If you would like me to test it, would you happen to have some ideas/feedback to do so? I know |
72ac06f to
485769c
Compare
|
I created another draft PR (#202), which is add a new subcommand, but it is more for discussion for now. Adding the other command was useful to see how to refactor and test the code. I would still like to submit 2 different PRs, one for each command, but I thought it would be a good idea to discuss the implementation beforehand. |
|
In this PR, I removed the I figured out that since there are 3 python versions specified in the file, ALL the versions MUST be installed with |
I don't mind the removal, I believe it was required for tox. I should remove the tox tests as I haven't been using them and instead only testing the earlier versions and other platforms on CI. |
Is it possible to test it in a similar way as was done with the build command? I.e. you just create a subprocess and try to run the command? The argument for testing the CLI is to ensure that, if someone changes the interface of the functions exposed by the CLI, that those tests fail and let the person know to also update the CLI. Understanding this better now, It would be really good to exercise the CLI Python functions. A stretch would be to also execute example CLI commands as described above, they can help serve as examples. I have never worked with CLIs before but want to get better. If you would like, I'm happy to merge this into a feature branch and write the tests on your behalf. I'm equally happy for you to write those tests. |
|
Please add documentation 😄 Please also update the readme with the additional feature. |
That works for me. I'll remove the file. 👍 |
Since argparse uses The |
|
I believe I addressed all your comments. Except for the documentation. The README starts to get really long. What would you think of created a dedicated page for the CLI? Or maybe giving a small example in the README, but the having an "Advance usage page" (something more or less like https://www.scrapd.org/usage.html)? We could also use an extension which generates parts of the CLI documentation based on the argparse: https://sphinx-argparse.readthedocs.io/en/latest/. Let me know what your thoughts are regarding this part and I'll start working on the documentation. |
|
Oh you switched the CI to GitHub Actions! Very cool! However for some reasons which seem unrelated to my PR, the CI is very unhappy with this patch 🤔 |
I think it is because some of them are failing so I assume it cancels the rest once it detects a failure. |
Yeh I think that is ok. It would still be good to have 1 test using |
I think it would just be a feature listed in the readme, it doesn't need an example there. I think that should be ok, I'm curios to see what they look like. It is important that the docs can still be generated locally (using |
open_alchemy/cli.py
Outdated
| """ | ||
| # Ensure the file exists. | ||
| if not specfile.exists(): | ||
| raise exceptions.BaseError(f"the specfile '{specfile}' cannot be found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies, I wasn't specific enough. I wouldn't expect BaseError to ever get raised, I would expect a more specific error to be raised that inherits from BaseError. BaseError is designed to go into a try ... except ... block to catch any OpenAlchemy error. I don't think there is a good error at the moment, perhaps a CliError can be defined?
|
Regarding the tests, it looks like there are quite a few flake8 checks that are failing. I could also spot 2 test cases that failed. Actually, it looks like flake8 was updated to a newer version and is expecting a maximum line length and is also looking for unused imports. There is also a mypy test that is failing. I'll open a branch and try to resolve them and you should then be able to rebase. Do you think that it is caused by the change to the I just tried that and it doesn't cause that behaviour. Very strange. Maybe let's finish off the pull request and I'll stick it into a branch and investigate. The flake8 configuration that should remove those errors is in the |
It looks like none of the available extensions for automatically creating argparse documentation work, so I will abandon this idea 😢 . |
|
My apologies, I intended to review this today but I got stuck at work until ~10 pm |
|
No worries. I still have to fix the tests/linter checks. I'll probably do that over the week end. |
|
Did you change some version or configuration of When running It seems that the For the other errors I am not exactly sure where they come from. When running in the CI (https://github.com/jdkandersson/OpenAlchemy/runs/1303815410?check_suite_focus=true), I get: But I haven't modified any of these files. I did rebase my branch on top of master. That would be great if you would have some pointers to help me get over these errors 🙏 . In meantime, I'll keep digging 😀 |
The Something weird is going on with the CI for this PR, it does look like it is enabling some rules for flake8 that should be turned off. The |
|
Ok, first finding, But I still have a lot of weird errors about modules not found 🤔 |
|
OK, some progress, I got it right on my laptop: |
f65c219 to
706fcd6
Compare
|
Alright! Everything was addressed! ✅ Since I could not get the CLI documentation to be generated from the code, I wrote some instructions by hand, finding some inspiration in the Docker CLI (https://docs.docker.com/engine/reference/commandline/build/). 📚 |
bb0076d to
e82c9a3
Compare
docs/source/cli.rst
Outdated
| Extended Description | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The ``openalchemy build`` command builds a reusable Python package based off of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use :samp:`openalchemy build` for code syntax in rst files 😄
docs/source/cli.rst
Outdated
| └── simple.egg-info | ||
|
|
||
| By default, a source and a wheel package are built, but this behavior can be | ||
| adjusted by using the ``--format`` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use :samp:`--format` for code syntax in rst files 😄
Excellent, so close! I think you just need to add |
Creates a CLI for OpenAlchemy. The first command available allows the users to build a package for the models and a distributable archive. Other workitems: * Adds `cli` marker and unit tests. * Updates the documentation accordingly.
Creates a CLI for OpenAlchemy. The first command available allows the
users to build a package for the models and a distributable archive.