Decorator for stylized interactive constructor using DSL parser
Project description
The argteller package provides the class and method decorators for visual and interactive class object constructor. It frees the user from needing to constantly refer to documentations to figure out what arguments are required and what parameter values are valid inputs. It lists required arguments parsimoniously by only asking the parameters as needed, depending on the previously provided argument values. You can easily encode them in the custom DSL (domain specific language) script.
This tool is useful in the Jupyter interface. It thus caters to the Python’s interactive development capability. It also helps with code reproducibility by providing an easy way to share the parameter configurations.
Install
pip3 install argteller-viz
What does it do?
Let’s take an example use case. Let’s say you have two classes Vehicle and Rider. Each class has the following __init__ signatures:
class Vehicle(): def __init__(self, vehicle_type, n_doors=None, car_name=None, n_motors=None, boat_name=None): """ Parameters ---------- vehicle_type : str Valid inputs: "car" or "boat" n_doors : int Only used when vehicle_type is "car". Valid inputs: 2 or 4 car_name : str Only used when vehicle_type is "car". n_motors : int Only used when vehicle_type is "boar". Valid inputs: 1, 2, or 3 boat_name : str Only used when vehicle_type is "boar" """ # ...Vehicle class definition
class Rider(): def __init__(self, rider_name, rider_height, rider_weight): """ Parameters ---------- rider_name : str rider_height : float rider_weight : float """ # ...Rider class definition
Note the following: (1) there may be predefined list of valid input values for a given parameter and (2) some arguments are required only conditionally (e.g. n_doors is not needed if vehicle_type is set to “boat”). As the number of parameters grow, these will become harder to keep track of, requiring the user to constantly refer to the documentation to figure out the signature requirements.
Without going into code details, let us see what argteller can do for us. The argteller lets us define a separate class, say, CoolConstructor. If you initialize CoolConstructor you will see interactive widgets that will help you fill out the required arguments:
cool_constructor = CoolConstructor()
If you click “car”, the argteller will show you the conditionally required parameters, which you can fill in likewise.
You can fill in the parameter values for the Rider class by clicking on the Rider tab.
Argteller solves the problem of needing to know (1) the (potentially very long) list of parameters, (2) which parameters are required conditionally, and (3) what argument values are valid inputs, where it helps reduce time and hassle to type them in by making them into buttons that you can simply click on to choose.
But how does this work, and how can we use the cool_constructor object to initialize our classes? In sections below, we will explain those details. Also, argteller can do so much more than the short sneak peek demo we just saw. We will slowly get into the rest of the functionalities that argteller has to offer as well.
DSL
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 Distribution
Built Distribution
File details
Details for the file argteller-viz-0.0b45.tar.gz
.
File metadata
- Download URL: argteller-viz-0.0b45.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9caf3505299738b862e8f5bf36e9d05720575545ddb2366e7f415ba22e196685 |
|
MD5 | f412d527f0c8b74d91914e252d4db285 |
|
BLAKE2b-256 | 13057b5f9280b8f88126e8b8467cf6b33b3c03f17366aa3865d9f4717e91d406 |
File details
Details for the file argteller_viz-0.0b45-py3-none-any.whl
.
File metadata
- Download URL: argteller_viz-0.0b45-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c9d0e5a8142b456d2968acc61dae168a4dcd4adc01d1d97ba2b3c5a67fd3c3 |
|
MD5 | e6a981772be95416804ecd4d8ee0dc07 |
|
BLAKE2b-256 | 1516e664b298a23bb3d9db155ae954d2dc28601ae4d81622e4bf7dd2ba744cd8 |