-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve support for keyword-positional arguments #254
Conversation
- Split up repeated code to improve readability - Add flag to identify_named_ports to allow for the addition of positional arguments to keyword argument dicionaries (required for the PyFunc drops to work).
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.
Hey @myxie - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 6 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
logger.debug("Checking against keyargs: %s", keyargs) | ||
portargs = {} | ||
posargs = list(posargs) | ||
logger.debug("Checking against keyargs: %s", keywordArgs) |
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.
suggestion: Consider using f-strings for logging
Using f-strings for logging can improve readability and performance. For example: logger.debug(f"Checking against keyargs: {keywordArgs}")
.
logger.debug("Checking against keyargs: %s", keywordArgs) | |
logger.debug(f"Checking against keyargs: {keywordArgs}") |
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 suggestion is incorrect and conflicts with pylint and the Python documentation.
positionalArgs = _get_args(appArgs, positional=True) | ||
keywordArgs = _get_args(appArgs, positional=False) |
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.
suggestion: Combine _get_args calls
Consider combining the two _get_args
calls into a single line for better readability: positionalArgs, keywordArgs = _get_args(appArgs, positional=True), _get_args(appArgs, positional=False)
.
positionalArgs = _get_args(appArgs, positional=True) | |
keywordArgs = _get_args(appArgs, positional=False) | |
positionalArgs, keywordArgs = _get_args(appArgs, positional=True), _get_args(appArgs, positional=False) |
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 do not agree that this adds readability.
@awicenec This is the work I've done to give us (optional) positional-and-keyword arguments. Would you mind providing a review? |
@awicenec just a 'bump' to confirm you're happy with these changes? |
Hi Ryan,
Yes, please go ahead and merge these.
Andreas
…On Thu, 6 June 2024, 03:00 Ryan Bunney, ***@***.***> wrote:
@awicenec <https://github.com/awicenec> just a 'bump' to confirm you're
happy with these changes?
—
Reply to this email directly, view it on GitHub
<#254 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJVMSARIWKRX3LDRBHLRXTZF67ERAVCNFSM6AAAAABH7DMJZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJRGI3TKMZXG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Improve support for keyword-positional arguments
Issue
Previously, we addressed the issue that the positional parameter option currently does not work for Docker and Bash applications; a temporary fix was introduced in #248.
Unfortunately, that solution did not allow for the potential Keyword-and-Positional argument combination, which is used in the
PyFunc
DROP classes. By commenting out the addition toportargs
to fix positional arguments for Docker and Bash apps, I inadvertently broke the PyFunc apps.Solution
I have added a flag to the
identify_named_ports
methods that allows for the addition of positional arguments to the keyword argument dictionary, which required for the PyFunc drops to work.I have also added some support functions to reduce the incidence of duplicated coded in
replace_named_ports
, to improve readability and make a bit more explicit that we are doing a lot of in-place manipulation of dictionaries (as opposed to modifying and returning them).