A command line argument parsing utility using python class-based namespace for better IDE static auto-completion
Project description
Todo
Done
[x] publish
[x] add test
Installation
pip install params_proto
Usage
from .params_proto import cli_parse, is_hidden, ParamsProto, proto_signature
def test_cli_proto():
@cli_parse
class G(ParamsProto):
"""Supervised MAML in tensorflow"""
npts: "number of points to sample from distribution" = 100
num_epochs: "number of epochs to train" = 70000
num_tasks: "number of tasks in the inner loop" = 10
num_grad_steps: "number of gradient descent steps in the inner loop" = 1
num_points_sampled: "effectively the k-shot" = 10
fix_amp: "controls the sampling, fix the amplitude of the sample distribution if True" = False
assert G.npts == 100
G.npts = 10
assert G.npts == 10
print("showing the dictionary from G: ", vars(G))
print("showing the original namespace class: ", G.__proto__)
print('showing the properties of G: ', G.__props__())
def test_proto_signature():
@cli_parse
class G(ParamsProto):
"""some parameter proto"""
npts: "number of points to sample from distribution" = 100
@proto_signature(G.__proto__)
def main_demo(**kwargs):
print('npts = ', kwargs['npts'])
pass
# First way is to use proto_signature decorator. The dynamically generated signature
# however does not show up in pyCharm. It does however, show during run time.
import inspect
print("main_demo<Function> signature:", inspect.signature(main_demo))
main_demo(npts=10)
To Develop
git clone https://github.com/episodeyang/params_proto.git
cd params_proto
make dev
To test, run
make test
This make dev command should build the wheel and install it in your current python environment. Take a look at the https://github.com/episodeyang/params_proto/blob/master/Makefile for details.
To publish, first update the version number, then do:
make publish
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for params_proto-0.5.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a6eccd2dd34bb1b8188d88ea8f20486666b42669ab6ea8c102c3fefe3839115 |
|
MD5 | 0672cbedbba6fca1ad91eb860f824d19 |
|
BLAKE2b-256 | 5b93544b36275f4fe4b94b67df38ddd1701e9e411f98dc6358aaa41aa6cbbd52 |