shx2 / apegears Goto Github PK
View Code? Open in Web Editor NEWAn improved ArgumentParser.
License: MIT License
An improved ArgumentParser.
License: MIT License
Not sure if you've heard of this project, kinda cool: https://github.com/chriskiehl/Gooey
Would be great to have apeagears support
Attempt:
@classmethod
def from_string(cls, s):
return cls(**loads(s))
@classmethod
def __argparse__(cls):
return dict(from_string=cls.from_string)
But this just puts it all on the first argument, like so:
$ ipython3
Python 3.8.6 (default, Oct 8 2020, 14:06:32)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.0.dev -- An enhanced Interactive Python. Type '?' for help.
In [1]: from apegears import ArgumentParser, register_spec
In [2]: from ml_params_tensorflow.ml_params.config import TrainConfig
In [3]: from json import loads
In [4]: parser = ArgumentParser()
In [5]: parser.add_argument('-t', type=TrainConfig)
Out[5]: _StoreAction(option_strings=['-t'], dest='t', nargs=None, const=None, default=None, type=<class 'ml_params_tensorflow.ml_params.config.TrainConfig'>, choices=None, help=None, metavar=None)
In [6]: parser.parse_args(['-t', '{"epochs": 1, "loss": "CategoricalCrossentropy", "optimizer": "Adam", "callbacks": ["TensorBoard"], "metrics": [], "m
...: etric_emit_freq": None, "save_directory": None, "output_type": "infer", "validation_split": 0.2, "batch_size": 128, "kwargs": None, "return_typ
...: e": None}'])
Out[6]: Namespace(t=TrainConfig(epochs='{"epochs": 1, "loss": "CategoricalCrossentropy", "optimizer": "Adam", "callbacks": ["TensorBoard"], "metrics": [], "metric_emit_freq": None, "save_directory": None, "output_type": "infer", "validation_split": 0.2, "batch_size": 128, "kwargs": None, "return_type": None}', loss=None, optimizer=None, callbacks=None, metrics=None, metric_emit_freq=None, save_directory=None, output_type='infer', validation_split=0.1, batch_size=128, kwargs=None, return_type=<_collections._tuplegetter object at 0x106af1970>))
I'm sure I'm doing something wrong. I've also tried without classmethod
and just manipulating the class
symbol that I import inβ¦
What's the right way to pass many arguments to the given class
type? - Also is there a way to give per argument --help
text and errors?
Happy to help implement. https://github.com/SamuelMarks/doctrans is what I'm working on.
Thanks for making apegears
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.