refconfig


Namerefconfig JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/Jyonn/RefConfig
Summarya flexible and variable-based tool for multi-type configuration, including json, yaml, and python dict
upload_time2023-01-18 10:23:27
maintainer
docs_urlNone
authorJyonn Liu
requires_python
licenseMIT Licence
keywords configuration refer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RefConfig

Powered by [SmartDict](https://pypi.org/project/smartdict/).

## Usage

- Configure with references

## Install 

`pip install refconfig`

## Description

```yaml
# ./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
```

```yaml
# ./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
```

```python
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
```

```yaml
# ./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
```

```python
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
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Jyonn/RefConfig",
    "name": "refconfig",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "configuration,refer",
    "author": "Jyonn Liu",
    "author_email": "i@6-79.cn",
    "download_url": "https://files.pythonhosted.org/packages/9a/31/c8a287ac7c12187a2a49386bdbdaaba3aa96f0eb40090808a195ef5b4c11/refconfig-0.0.3.tar.gz",
    "platform": "any",
    "description": "# RefConfig\n\nPowered by [SmartDict](https://pypi.org/project/smartdict/).\n\n## Usage\n\n- Configure with references\n\n## Install \n\n`pip install refconfig`\n\n## Description\n\n```yaml\n# ./data/zhihu.yaml\n\ndataset: zhihu\nstore:\n  data_dir: data/FANS/${config.dataset}\n  save_dir: saving/${config.dataset}/${exp.model}-E${config.model_config.hidden_size}/\nmodel_config:\n  hidden_size: 64\n  num_hidden_layers: 3\n  num_attention_heads: 8\n```\n\n```yaml\n# ./exp/train.yaml\n\nexp: step-${exp.tasks.0.params.steps}\nmodel: bert\nmode: train\nfreeze_emb: false\ntasks:\n  -\n    name: mlm\n    params:\n      steps: 5\nstore:\n  interval: 10\npolicy:\n  epoch: 200\n```\n\n```python\nimport refconfig\n\nconfig = refconfig.parse_yaml(\n    exp='./exp/train.yaml',\n    config='./data/zhihu.yaml',\n)\n\nprint(config['config']['store']['data_dir'])  # => data/FANS/zhihu\nprint(config['config']['store']['save_dir'])  # => saving/zhihu/bert-E64/\nprint(config['exp']['exp'])  # => step-5\n\n# use with the Oba library to achieve a smoother effect\n\nfrom oba import Obj\n\nconfig = Obj(config)\nconfig, exp = config.config, config.exp\nprint(config.store.data_dir)  # => data/FANS/zhihu\nprint(config.store.save_dir)  # => saving/zhihu/bert-E64/\nprint(exp.exp)  # => step-5\n```\n\n```yaml\n# ./data/any.yaml\n\nstore:\n  data_dir: data/FANS/${dataset}\n  save_dir: saving/${dataset}/${exp.model}-E${config.model_config.hidden_size}/\nmodel_config:\n  hidden_size: 64\n  num_hidden_layers: 3\n  num_attention_heads: 8\n```\n\n```python\nfrom refconfig import RefConfig\n\nconfig = RefConfig().add_yaml(\n    exp='./exp/train.yaml',\n    config='./data/any.yaml',\n).add_raw(\n    dataset='youtube',\n).parse()\n\nfrom oba import Obj\n\nconfig = Obj(config)\nconfig, exp = config.config, config.exp\nprint(config.store.data_dir)  # => data/FANS/youtube\nprint(config.store.save_dir)  # => saving/youtube/bert-E64/\nprint(exp.exp)  # => step-5\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT Licence",
    "summary": "a flexible and variable-based tool for multi-type configuration, including json, yaml, and python dict",
    "version": "0.0.3",
    "split_keywords": [
        "configuration",
        "refer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a31c8a287ac7c12187a2a49386bdbdaaba3aa96f0eb40090808a195ef5b4c11",
                "md5": "9616e5b050536dc5ebe301c275cc0cfa",
                "sha256": "343eb56a6065220e7848b28aab524c40ada53a9a1b1fb2161cb3d4e084a7c76f"
            },
            "downloads": -1,
            "filename": "refconfig-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9616e5b050536dc5ebe301c275cc0cfa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3172,
            "upload_time": "2023-01-18T10:23:27",
            "upload_time_iso_8601": "2023-01-18T10:23:27.833865Z",
            "url": "https://files.pythonhosted.org/packages/9a/31/c8a287ac7c12187a2a49386bdbdaaba3aa96f0eb40090808a195ef5b4c11/refconfig-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-18 10:23:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Jyonn",
    "github_project": "RefConfig",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "refconfig"
}
        
Elapsed time: 0.06594s