Giter Site home page Giter Site logo

apegears's People

Contributors

samuelmarks avatar shx2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

samuelmarks

apegears's Issues

How to provide arguments to custom class?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.