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

passing json string for command line args is overly complex #5

Open
poldrack opened this issue Apr 4, 2022 · 1 comment
Open

passing json string for command line args is overly complex #5

poldrack opened this issue Apr 4, 2022 · 1 comment

Comments

@poldrack
Copy link
Contributor

poldrack commented Apr 4, 2022

I checked on this with my development team and got several comments and suggestions:

I see two issues. The first is that it will violate expectations of CLI tools, which is fine if your documentation is good and users aren't picky. The second is that it's expecting the entire JSON to be a single string, so quotes are going to have to be carefully escaped and painful to debug. If I were to do this, I would probably make all of these --flag ARG arguments and then add in a special --json PATH argument that would allow you to pass in a file instead. I would not do JSON as a single positional argument.

The shell script is using the traditonal --flag styling, I'd recommend using a library like click (to help set the boolean flags etc) in python and then argv can be passed directly through the shell script without that inital switch statement.
or put everything in json files like [@Markiewicz] said, then your configuration is saved to some place other than the history file.

If you’re refactoring, I don’t really see a benefit of checking the args in the bash file - I think it’s more beneficial to have an argument parser in the python script (gives you type validation, help generation). Then you can remove L10-82 in the submission script and just replace with ARGS=($@)

I would probably just go with the third suggestion as I think it's simplest, though it will require some rework because args will be an argparse object rather than a dict, though it could be easily converted for backwards compatibilty. I will try these out and see.

@bellabrez
Copy link
Contributor

excellent! indeed this was overly complex.

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

No branches or pull requests

2 participants