datawork.api.config

Basic Option and Config functionality.

class datawork.api.config.Config(options)[source]

A ‘Config’ is a collection of ‘Option’s.

__init__(options)[source]

Construct a Config with given list of ‘Option’s.

__setattr__(name, val)[source]

Overload setattr to only allow setting of listed options.

__str__()[source]

Convert to string by listing all options.

get_hash()[source]

Return hash of the dictionary representation of this ‘Config’.

parents()[source]

Return empty list of parents.

to_dict()[source]

Convert to dictionary to prepare for JSON conversion.

class datawork.api.config.Configurable[source]

A Configurable class contains a ‘Config’ attribute called ‘.config’.

__init__()[source]

Set a default .config using the class attribute ‘.OPTIONS’.

parents()[source]

Return .config as the only parent.

class datawork.api.config.Option(desc=None, name=None, required=False, default=None)[source]

An Option is a JSON serializable argument to a function.

__init__(desc=None, name=None, required=False, default=None)[source]

Construct an ‘Option’ with name, default value, and description.

__str__()[source]

Show value and name for this Option.

add_argument(parser)[source]

Add an argument to an argparse ‘ArgumentParser’.

get_value()[source]

Get the set value or raise a ValueError.

set_value(value)[source]

Implement a guarded setter for this Option type.

value

Get the set value or raise a ValueError.