Metadata-Version: 2.1
Name: argcomb
Version: 1.0.0
Summary: A simple library for building command-line arguments
Home-page: https://github.com/percyliang/argcomb
Author: Percy Liang
Author-email: percyliang@gmail.com
License: MIT
Description: # Quickstart
        
        argcomb (argument combiner) is a simple utility that allows you to build
        complex command-line arguments in a modular fashion.
        
        To install it:
        
            pip install argcomb
        
        Suppose we want to run the following combination of commands (e.g., if you're
        doing a hyperparameter sweep):
        
            echo train --eta 0.1 --num-iters 5 --greedy
            echo train --eta 0.1 --num-iters 5
            echo train --eta 0.1 --num-iters 10 --greedy
            echo train --eta 0.1 --num-iters 10
        
        You can write the following `argcomb` program (called `example1.py` in this repo):
        
            from argcomb import *
        
            run(
                "echo", "train",
                arg("eta", 0.1),
                selarg(None, "num-iters", 5, 10),
                sel(None, [], arg("greedy")),
            )
        
        Here `run` takes a (hierarchical) list of arguments to be concatenated.
        Special functions like `sel` allow us to specify the selection/iteration over
        multiple possible values in place (as opposed to having a big for loop on the
        outside).
        
        To run it:
        
            # Actually executes the commands
            python example1.py
        
            # Print out the commands rather than execute them
            python example1.py -n
        
        We can also use environment variables (e.g., `@mode`) to parametrize the runs.
        For example:
        
            from argcomb import *
        
            run(
                "echo", "train",
                let_if_undefined("@mode", "slow"),  # Set default
                sel("@mode", {
                    "fast": [arg("num-iters", 5), arg("greedy")],
                    "slow": arg("num-iters", 10),
                }),
                arg("output", fmt("@mode.out")),
            )
        
        To run it:
        
            python example.py             # slow (default)
            python example.py @mode=fast  # fast
        
        # Development
        
        Handy commands:
        
            # Install environment
            virtualenv -p python3.7 venv
            venv/bin/pip install -r requirements.txt
        
            # Format code (skip `example*.py`)
            venv/bin/black -t py37 argcomb test_argcomb.py
        
            # Do type checking
            venv/bin/python -m mypy argcomb test_argcomb.py example*.py
        
            # Run unit tests
            venv/bin/python -m pytest test_argcomb.py
        
            # Build PyPI package and deploy it
            venv/bin/python setup.py sdist
            venv/bin/twine upload dist/*
        
Keywords: command-line
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
