Skip to main content

A portable configuration tool to manage hyperparameters and settings of your experiments.

Project description

xparameter

A portable configuration tool to manage hyperparameters and settings of your experiments.

Features

:white_check_mark: Support syntax highlighting and autocompletion for attributes
:white_check_mark: Support arguments control through command line
:white_check_mark: Support nested definition (namespaces) to isolate parameters of the same name
:white_check_mark: Inherent Singleton ensuring consistent revision across files
:white_check_mark: Support basic type checking

Quickstart

You can install the latest official version of xparameter from PyPI:

pip install xparameter

Define Custom Configuration

# config.py
from xparameter import Configure as C
from xparameter import Field as F

class Config(C):
    """Define your overall description here"""

    class checkpoint(C):
        """Define group description here"""
        directory       = F(str,   default="./checkpoints", help="Directory to save model checkpoints")

Parse Command-line Arguments

Config.parse_sys_args()

Parameters in Config class will be automatically registered onto a argparse.ArgumentParser(), which acts as a parser to extract parameter values from command line. In this example case, we use

python test.py --checkpoint.directory "/path/to/checkpoints"

The argument Config.checkpoint.directory will be set to "/path/to/checkpoints". This parsing process and the following manual revision will trigger an inherent type check.

Use the help command to print automatically generated help menu:

python test.py --help
Usage: config_01.py [-h] [--checkpoint.directory str]

Define your overall description here

Options:
  -h, --help                  show this help message and exit

Checkpoint:
  Define group description here

  --checkpoint.directory str  Directory to save model checkpoints

Revise Arguments Manually

Manual revision of the argument values can be performed either independently or as a post-processing step following the aforementioned command-line parsing, e.g.,

# Config.parse_sys_args()
Config.checkpoint.directory = "/path/to/checkpoints"

Export as Different Formats

Export as python dict:

Config.as_dict()

Export as json string:

Config.as_json()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xparameter-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xparameter-0.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file xparameter-0.0.1.tar.gz.

File metadata

  • Download URL: xparameter-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for xparameter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 19db36384d513697060726870b73a80fa34c6fdc891596fd696ffaa7b89cc770
MD5 48c2facfb7de330d92d5d4e1878bbece
BLAKE2b-256 3d779762cc3296eba4b829d8faae3dee9665aa410f6828c98604eadaeec351b2

See more details on using hashes here.

File details

Details for the file xparameter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: xparameter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for xparameter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 359686c322be68774a6b07d5373e2cd49481758f6ec0fb29fd2ba9fae30991fd
MD5 017500bed1cbbaeaf09fe7665b2a4ff4
BLAKE2b-256 bfe2c8f5c0cf0eaad801994fb0a858e02907fb372e54b9aa790c6472030a2555

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page