Skip to main content

A Global config tools created by gawainx

Project description

config tool

A tool help you to create config and load in an easy way

Usage

Define and Writing Config to toml

In Python Code

from typing import NamedTuple
import gxconfig

class DataConfig(NamedTuple):
    root:str = "/home/gawainx/data"
    chkp:str = "chkp"

class ModelConfig(NamedTuple):
    embd_dim:int = 768
    hidden_dim:int = 5

class Config(NamedTuple):
    dataConfig:DataConfig = DataConfig()
    modelConfig:ModelConfig = ModelConfig()

cfg = Config()
gxconfig.save_toml(cfg, "config.toml")

Then you can get a toml

[DataConfig]
root = "/home/gawainx/data"
chkp = "chkp"

[ModelConfig]
embd_dim = 768
hidden_dim = 5

Load from Toml

import gxconfig
from typing import NamedTuple
class DataConfig(NamedTuple):
    root:str = "/home/gawainx/data"
    chkp:str = "chkp"

class ModelConfig(NamedTuple):
    embd_dim:int = 768
    hidden_dim:int = 5

class Config(NamedTuple):
    dataConfig:DataConfig = DataConfig()
    modelConfig:ModelConfig = ModelConfig()

cfg = gxconfig.load_toml("config.toml", Config)

Project details


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

gxconfig-0.0.2-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

Supported by

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