[Feature Request] Emulate conventional commandline args
See original GitHub issueHi, this is not a feature request and more a general usage question. I’d you really like to give hydra a try in one of my existing projects. I have a program that from the outside looks like this to the user:
python main.py --arg1="ABC" --arg2="DEF"
I know that you can create required arguments using ???
(like described here ). A program using hydra would look like this:
python main.py arg1="ABC" arg2="DEF"
Is it somehow possible to add the --
(minus minus)? This may not sound like a big deal, but it is somewhat of a big deal to me, because it not, I would have to change several interface, when I use hydra.
Thank you, Flo
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
argparse — Parser for command-line options, arguments and ...
The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv . The argparse module...
Read more >Python Command Line Arguments
To use Python command line arguments in this tutorial, you'll implement some partial features of two utilities from the Unix ecosystem:.
Read more >Command-line syntax overview for System.CommandLine
An introduction to the command-line syntax that the System.CommandLine library recognizes by default. Mentions exceptions where syntax in ...
Read more >picocli - a mighty tiny command line interface
The converter annotation does not require a CommandLine instance so it can be used ... Positional parameters of type boolean or Boolean require...
Read more >Passing command line arguments to VirtualUI apps
If you have defined command line arguments in the application profile and need to send new arguments to the application by url, don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hannw:
You need to write a arg-preprocessing function that remaps your “–args val” or “–args=val” parameters to “cfg.something.arg=val”. This can be done by accessing and rewriting sys.argv before calling main. If you need the mapping to be dynamic (I did), you can pass it as an argument to the function itself.
Since many real-life scenarios (e.g.: AzureML HyperDrive) require this, such a utility function should be included with hydra, but sadly isn’t, and probably won’t ever be from what I read. As I wrote earlier, it’s quite frustrating and time-consuming for everyone
I included some code here. This should help those who are stuck with legacy code, or third-party calling sites.
Disclaimer: It’s a stripped-down version of my code, and I haven’t tested this stripped down version, but the code it’s based on works well, so it should be somewhat ok.
hydra_argv_remapper.zip
Thanks for the elaborate response!