Skip to main content

a flexible and variable-based tool for multi-type configuration, including json, yaml, and python dict

Project description

RefConfig

Powered by SmartDict.

Usage

  • Configure with references

Install

pip install refconfig

Description

# ./data/zhihu.yaml

dataset: zhihu
store:
  data_dir: data/FANS/${config.dataset}
  save_dir: saving/${config.dataset}/${exp.model}-E${config.model_config.hidden_size}/
model_config:
  hidden_size: 64
  num_hidden_layers: 3
  num_attention_heads: 8
# ./exp/train.yaml

exp: step-${exp.tasks.0.params.steps}
model: bert
mode: train
freeze_emb: false
tasks:
  -
    name: mlm
    params:
      steps: 5
store:
  interval: 10
policy:
  epoch: 200
import refconfig

config = refconfig.parse_yaml(
    exp='./exp/train.yaml',
    config='./data/zhihu.yaml',
)

print(config['config']['store']['data_dir'])  # => data/FANS/zhihu
print(config['config']['store']['save_dir'])  # => saving/zhihu/bert-E64/
print(config['exp']['exp'])  # => step-5

# use with the Oba library to achieve a smoother effect

from oba import Obj

config = Obj(config)
config, exp = config.config, config.exp
print(config.store.data_dir)  # => data/FANS/zhihu
print(config.store.save_dir)  # => saving/zhihu/bert-E64/
print(exp.exp)  # => step-5
# ./data/any.yaml

store:
  data_dir: data/FANS/${dataset}
  save_dir: saving/${dataset}/${exp.model}-E${config.model_config.hidden_size}/
model_config:
  hidden_size: 64
  num_hidden_layers: 3
  num_attention_heads: 8
from refconfig import RefConfig

config = RefConfig().add_yaml(
    exp='./exp/train.yaml',
    config='./data/any.yaml',
).add_raw(
    dataset='youtube',
).parse()

from oba import Obj

config = Obj(config)
config, exp = config.config, config.exp
print(config.store.data_dir)  # => data/FANS/youtube
print(config.store.save_dir)  # => saving/youtube/bert-E64/
print(exp.exp)  # => step-5

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

refconfig-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file refconfig-0.1.2.tar.gz.

File metadata

  • Download URL: refconfig-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for refconfig-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fe6106edea1b7e3d560f89563575173bb1cc638c286f08ccb1d7e66751bc24ce
MD5 37fba3d7f89434569fda2e586a6485dd
BLAKE2b-256 ce995929601e5a870ea70ef5847b99fac01c6a11ce0880047825f8fdea212d81

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