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.0.3.tar.gz (3.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for refconfig-0.0.3.tar.gz
Algorithm Hash digest
SHA256 343eb56a6065220e7848b28aab524c40ada53a9a1b1fb2161cb3d4e084a7c76f
MD5 9616e5b050536dc5ebe301c275cc0cfa
BLAKE2b-256 9a31c8a287ac7c12187a2a49386bdbdaaba3aa96f0eb40090808a195ef5b4c11

See more details on using hashes here.

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