Skip to content
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

BUG/FEATURE REQUEST: "Param" does not support spaces #758

Open
0lionelzhang0 opened this issue Aug 9, 2024 · 3 comments
Open

BUG/FEATURE REQUEST: "Param" does not support spaces #758

0lionelzhang0 opened this issue Aug 9, 2024 · 3 comments
Labels

Comments

@0lionelzhang0
Copy link

0lionelzhang0 commented Aug 9, 2024

Script config in UI:
image

The test script:

from argparse import ArgumentParser


def parse_args():
    parser = ArgumentParser()
    parser.add_argument("--extra_label", nargs=2, action="append", metavar=("LABEL_NAME", "LABEL_VALUE"))
    return parser.parse_args()


args = parse_args()
print(args.extra_label)

Output error:
image

When I copy paste the command that was supposed run in the "HISTORY" menu, it runs successfully:
image


The suspected reason for error, is that there can't be spaces in the command ("result"). E.g. when I added the two lines that are commented below, it would work (and commenting out the original append option_name line).

image

@MNeill73
Copy link

MNeill73 commented Aug 9, 2024 via email

@bugy bugy added the feature label Aug 9, 2024
@bugy
Copy link
Owner

bugy commented Aug 9, 2024

Hi @0lionelzhang0, it's supposed to work this way. Everything is sent to scripts as isolated arguments, i.e. effectively the same as being wrapped in quotes, e.g. script.py '--extra_label LabelB' bb in your case. To override such a behaviour, script server would need an explicit parameter for it OR allow to specify param as an array (I think this is a cleaner option).
If you can mark the parameter as required, you can add a constant value before this parameter as a workaround.

@MNeill73 from what I know, argparse won't work with this syntax. Thanks for the suggestion though!

@0lionelzhang0
Copy link
Author

0lionelzhang0 commented Aug 9, 2024

Thank you for getting back to me so quickly! I understand that this behavior is expected based on the implementation. It was just a little unintuitive and frustrating when trying to debug, since the command shown in the "HISTORY" and log files doesn't reflect the "invisible" single-quotes that the backend executes the command with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants