-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(all): Add global parameters #4
Conversation
16921cd
to
0b1a049
Compare
can you please divide this pr in small change as is difficult to review all toghether |
ok |
also I don't understand why you want to merge commit and patch with a general kci-dev.toml instead of keeping the current configuration file and trying to move away from standard click usage implementing a ctx context |
0b1a049
to
0c67f2f
Compare
settings have identical functionality, it make sense to make it somewhere single place instead of duplicating function on each subcommand. |
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env python | |||
#!/usr/bin/env python3 |
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.
python2 as been deprecated years ago
python2 shebang is "#!/usr/bin/env python2"
python is usually just a symlink to your distribution python version
your distribution should be able to decide the correct python version for you
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.
According to PEP 394, For Python script publishers:
"Older Linux distributions will provide a python command that refers to Python 2, and will likely not provide a python2 command."
"Some Linux distributions will not provide a python command at all by default, but will provide a python3 command by default."
In my case (Debian bookworm) python is not provided at all (unless i install python-is-python3), so it is preferable to point to python3 which is supposed to work for all.
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.
we should change all the python file not just this one file
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.
we should change all the python file not just this one file
Good point, will change all.
My point is that if we will have for example 4 subcommands (jobretry, commit, patch, patchset), we will have to duplicate --settings and load_toml in each file. So i am applying DRY principle and found way to make it shared, i think only way to do that is to make this option as global, as is it is mostly identical. |
my idea about this was to move such duplicated code to a sort of common library script file, and just call the kernelci.toml reading function on each sub-command as needed. This would make each sub-command more flexible but still preventing to duplicate code. |
Agree, if it is common function that still have to be present on each subcommand (for example API call wrapper). |
right, so I think we can go with your patch. |
This PR looks good just be sure to have reformatted everything with python black (https://black.readthedocs.io/en/stable/index.html) |
Regarding load_toml, to place in some common library, where do you prefer to put it / name this library? |
kci-dev/libs/common.py looks better thanks for helping on this |
0c67f2f
to
bd0a9b3
Compare
I added isort and python black check with GitHub action through poetry |
sure, will do today |
Many distributions don't have python by default, but have python3. Update shebang to reflect that. Signed-off-by: Denys Fedoryshchenko <[email protected]>
92aab24
to
09bf3b3
Compare
I will do by small bits for now, i will open separate PR for --instance support and few more things |
Following DRY principle creating common library and moving load_toml there to deduplicate functions. Signed-off-by: Denys Fedoryshchenko <[email protected]>
As we use same settings file for all subcommands it make sense to make it global, parse in the beginning, and pass to subcommands already parsed result. Signed-off-by: Denys Fedoryshchenko <[email protected]>
09bf3b3
to
ee9e7be
Compare
thanks you |
1)Moving load_toml to main file, as it is common for all files. 2)Adding context to forward instance and settings to subcommands 3)Modifying at least "commit" subcommand to support latest Pipeline API 4)Add automatic repo info retrieval for "commit" with option to override by cli arguments.