-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Refactor podman python varlink bindings #748
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
Conversation
|
@jwhonce I'll give it a review, but I warn you it's been years since I did serious work in Python 😄 |
wking
left a comment
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.
I've only made it up to libs/images.py, but here are some initial suggestions. I'm not a maintainer, so feel free to ignore anything that doesn't seem useful ;).
contrib/pylibpod/README.md
Outdated
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.
Should we just call it libpod, and have it's Python-ness implied by it's presence in PyPI? import libpod, called from Python, is not going to pull in a Go library by mistake ;).
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.
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.
SGTM
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.
done
contrib/pylibpod/README.md
Outdated
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.
This can be a relative link:
See [libpod](../../).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.
Can we use SemVer and start with 0.1.0?
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.
Agreed, Done.
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.
I haven't seen __title__ before. Can you link to docs or such discussing it? I'd expect the package name to be sufficient without repeating it here.
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.
@wking pkutils use it. If the final packager we use doesn't support this then I'll remove it.
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.
@wking pkutils use it.
I've filed reubano/pkutils#2 to make it optional ;).
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.
I find these imports easier to maintain if you put each imported symbol on its own line:
from .libs.errors import (
ContainerNotFound,
ErrorOccurred,
ImageNotFound,
RuntimeError,
)That way it's easier to use your editor to alphabetize and you don't have to worry about re-wrapping as you add/remove symbols.
Alternatively, you could stay DRY by defining __all__ in these subpackages and then using a wildcard import here:
from .libs.errors import *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.
++
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.
@wking My IDE (atom/python-ide) already sorts imported objects, unfortunately the formatter won't keep them as a list. I'll take a todo to research this. IDE too productive to dump. :)
I missed I had all vs __all__ defined. Fixed that.
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.
Is this ellipsis a TODO?
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.
Yes
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.
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.
I chose returncode here because that is what the subprocess module uses.
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.
This seems like something that is going to need arguments (e.g. whether or not to follow a stream, or whether to only get the last n lines). But maybe those aren't supported by the varlink API yet.
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.
@wking Correct, once we have streaming there will be changes. I added *args, **kwargs to better future proof this method.
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.
Do you mean to pass *args and **kwargs through here?
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.
@wking They are on the method signature waiting on this varlink method to be implemented. A bit of future-proofing.
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.
If data contains an id key, why bother with _id and __init__'s separate id argument/
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.
Makefile
Outdated
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.
is this change needed?
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.
I removed the pushd/popd calls.
contrib/pylibpod/pylibpod/client.py
Outdated
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.
add model for consistency
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.
done
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.
does it make sense to combine these two into a return? dealers choice
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.
@baude I've kept them separate for two reasons:
- the client socket connection is open for the duration of the with statement. So I've coded that to be the minimum number statements for the day when we go remote. processes() could have yielded within the with, but then the connection to podman would be open until the caller exhausted the list of processes.
- I personally don't like the style of method()[0] unless the method call is trivial. :)
|
@jwhonce big undertaking, good work! |
|
@jwhonce Gitvalidation is complaining about whitespace errors in one of your commits |
f673797 to
0666aba
Compare
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.
Why is this called CrioTestCase? Does this require Crio?
|
Jhon great work, love all of the tests. Only question is why call this stuff Crio? |
0666aba to
cfa81f2
Compare
|
@rhatdan History. Named changed to reflect current usage. |
|
Really nice work! Will this be a dedicated library? |
contrib/pylibpod/LICENSE.txt
Outdated
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.
This paragraph should not be indented. And you might want to just copy the root LICENSE file here anyway.
contrib/pylibpod/README.md
Outdated
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.
I think you want a terminal . here.
contrib/pylibpod/README.md
Outdated
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.
This should be:
```console
$ python3 setup.py clean -a && python3 setup.py bdist_wheel
```
or
```sh
python3 setup.py clean -a && python3 setup.py bdist_wheel
```
The python syntax highlighting is for content that can be parsed as valid Python, but your line is POSIX shell syntax invoking Python.
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.
Yup, my editor autofilled something wrong and then I corrected it to something wrong. :)
contrib/pylibpod/test/test_libs.py
Outdated
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.
Typo: hanlded -> handled
mheon
left a comment
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.
Weak LGTM - I'm not comfortable enough with Python to really do a proper review.
cfa81f2 to
4d689ba
Compare
|
My biggest request is the library needs to be named podman import podman No one knows what libpod is, and libpod means something different. I would figure libpod python bindings would give me access to some of the internals or databases of libpod. Change the name to podman and we can merge this. (Although I like the idea of calling it podcast, but that would confuse users.) |
4d689ba to
348f920
Compare
348f920 to
c31a69b
Compare
2144a03 to
aa21e08
Compare
|
@rh-atomic-bot retry |
|
bot, please retest |
|
bot, retest this please |
|
@jwhonce Are the Travis failures flakes, or actual misconfiguration? It looks like it's throwing errors in the Python tests for the varlink bindings? |
- More pythonic - Leverage context managers to help with socket leaks - Add system unittest's - Add image unittest's - Add container unittest's - Add models for system, containers and images, and their collections - Add helper functions for datetime parsing/formatting - GetInfo() implemented - Add support for setuptools - Update documentation - Support for Python 3.4-3.6 Signed-off-by: Jhon Honce <jhonce@redhat.com>
aa21e08 to
814c6af
Compare
|
@mheon Python version support issue. Code downgraded for Python 3.4 support. |
|
Tests seem to be green. I'll leave final decision on merge to @baude as our resident varlink expert. |
|
📌 Commit 814c6af has been approved by |
|
☀️ Test successful - status-papr |
Todo:
Signed-off-by: Jhon Honce jhonce@redhat.com