GithubHelp home page GithubHelp logo

sngjuk / argparse-to-class Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 2.0 116 KB

Transform argparse into class format for Jupyter Notebook execution

License: MIT License

Python 80.41% HTML 14.71% PHP 4.88%
argparse jupyter arguments jupyter-notebook argument-parser ipython-notebook

argparse-to-class's Introduction

Argparse2class for Jupyter execution.

Argparse transformation for Jupyter Notebook execution. (for quick testing in .ipynb)
Copy & paste class-formatted arguments to replace argparse.

Notice! It's better to use args = parser.parse_args(args=[]) syntax - https://stackoverflow.com/a/47587545/3618853

quick web transformation :

http://35.192.144.192:8000/arg2cls.html

usage :

python3 arg2cls.py [target.py] [target2.py(optional)] ...

make argument parser into-

parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language Model')
parser.add_argument('--data', type=str, default='./data/penn',
                    help='location of the data corpus')
parser.add_argument('--model', type=str, default='LSTM',
                    help='type of recurrent net (RNN_TANH, RNN_RELU, LSTM, GRU)')
parser.add_argument('--emsize', type=int, default=200,
                    help='size of word embeddings')
parser.add_argument('--nhid', type=int, default=200,
                    help='number of hidden units per layer')

class format

class args:
    data = './data/penn'
    model = 'LSTM'
    emsize = 200
    nhid = 200

input (argparse lines) :

alt text

ouput (args class) :

alt text

transformed usage :

If there's no default value for argument, It will have warning value. (###manual_setting_required###)

alt text

argparse-to-class's People

Contributors

seongwook avatar sngjuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

argparse-to-class's Issues

args type issue

currently not support, argument type selection option.
e.g) parser.add_argument('--data', type=int, default='100', help='location of the data corpus')

in this case data is defined as string. '100'

bugs list - Mar 31, 19

bug list

  • - argname (ex, --V-min)
  • - default value as list
  • - choices syntax with default value bug.
  • - argument names with no dash are not counted.
  • - required syntax shows string after keyword automatically.
  • - last element showing some bug.
  • - 'default' string matching problem(e.g, default string in help description)
  • - 'dest' keyword handling
  • - set_default() with multiple arguments is not working properly.

Sorry for bugs.
It will be fixed soon or later.

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.