Author of Fire here. Was super happy to pass the 10000 star mark on GitHub today thanks to this HN post :) -- that boosted my spirits on an otherwise long and rainy (and now delayed) bus ride.
Hope you find Fire useful!
What's next for Python Fire? We're working on improving the help screens and usage outputs so it feels less like a developer tool and more like a professional grade CLI. So stay tuned as it gets better!
Great library. Excited to see that in 0.1.2 you removed nearly every dependency except `six` (esp ipython).
This caused me to have to remove `fire` from a project repo's requirements.txt so that ipython wouldn't be included in production builds. Then in the testing script that used it, there was a comment saying "you're going to need ipython for this"
Allow me to fan the flames. I find for simple scripts, docopt[0] is more than enough. It looks like the click's docs has a discussion of the differences.
Click makes python attractive for CLI's. It is far better than bash and perl for simple stuff. Fire looks useful for hacks but Click has been excellently intuitive for me.
Perl6 has nice builtin cli construction from method definitions and doc comments
cat > cli.pl6
#| Duplicates without frobnication
multi sub MAIN( 'duplicate', Int $times, Str $text ) {
say $text x $times;
}
#| Frobnicates up to a limit
multi sub MAIN('frobnicate', Int :$length = 24, Bool :v(:$verbose))
{
say 'Verbosity ', ($verbose ?? 'on' !! 'off');
}
perl6 cli.pl
Usage:
cli.pl6 duplicate <times> <text> -- Duplicates without frobnication
cli.pl6 [--length=<Int>] [-v|--verbose] frobnicate -- Frobnicates up to a limit
perl6 cli.pl6 duplicate 3 blah...
blah...blah...blah...
Fire is an interesting project that's great for testing and hacking. But for crafting Python CLIs from scratch, I fail to understand why Argh[0] doesn't receive more attention.
My only frustrations are a missing default handler for --version, and that I can't use argument names colliding with builtins such as 'input'. All the flexibility of argparse without boilerplate.
I am the author of commandeer[1], which does similar things and has been around since 2013. Try that, too, if you're interested!
Seeing another library that makes it easier to access things from the command line is awesome, and finding that there are even more I didn't know about in the comments is even better.
I was looking for something similar to click / fire that uses type annotations to validate/cast the inputs today. Came across this https://github.com/Lucretiel/autocommand
I think it would be really nice to have a library that takes the type annotated functions and lets you expose them as a CLI, GUI, REST API and a web form. Practically just combining click, flask, rest framework and Gooey. Would be a great tool for data scientists.
cool. two questions: is gooey cross-platform? and can I build an app starting with gooey rather "port" an existing cli app? what I mean is can I pick and widgets and stuff from the gooey widget library by hand rather than make it parse my Args thing object.
Yep! It'll run on most flavors of Windows, Linux, and OSX.
On the latter part, nah, not really. Gooey builds all of its widgets internally. There has been some interest in Gooey exposing the little pre-baked components it uses as a util library, but I haven't explored the option super deeply
Wow this is interesting. I never knew a tool like this existed. Seeing all the alternatives in the comments here is great too. It's like getting a solution to a problem I never knew I had! Super excited to use this on my next project!
Nice! This is an approach I hope will be used much more, to generate CLIs and other interfaces.
Luigi [1] does something similar, in that it auto-creates an API that lets you call any task in your task dependency graph, and provide parameters as arguments to flags. One of the things that made working with Luigi such a breeze (although we experienced other problems for our use cases).
I've been using a similar library in Nim called cligen[0]. Like Fire, it infers the CLI long form/short form switches from the arguments of the function it is linking to. Follow the repo link for examples.
seems great for my reinforcement learning models. instead of parsing my hyperparameters through the tensorflow cli API and editing the training file a line at a time to take in an additional hyperparameter, I can just directly set them through the cli with fire.
but then how will you keep track of which parameters worked well? I've been essentially storing my kwargs in json and not felt a need to control anything directly from the CLI.
Good question, for me I programatically generate a folder with the hyperparameter key - values in the name and store the checkpoints under it. As you can imagine, it can get out of control quickly if not managed well, but it works for 1-3 person projects. For anything more large scale or organized, I would recommend looking into Comet ML which lets you query and filter your experiments by hyperparameter ranges instead of manually looking at folder names.
I did that until I hit the Linux directory name length limit, lol. Now I hash the hyperparameters dict to get the directory name, and store a json file within. Totally ad hoc and I'm sure a better solution exists.
I always wondered how far human laziness can go? This is an absolutely terrible library. Every command line is a HUMAN INTERFACE for interactions with your program, should not exposed random methods for command line usage...
Also, developing a Python library and not keeping the most basic standard (PEP8)? You should not be allowed near Python.
I really have no better words for this, just fucking lazy. I hate lazy developers, because you are the reason most software is shit.
Hope you find Fire useful!
What's next for Python Fire? We're working on improving the help screens and usage outputs so it feels less like a developer tool and more like a professional grade CLI. So stay tuned as it gets better!