{"id":30768028,"url":"https://github.com/diyer22/zcs","last_synced_at":"2025-09-04T20:20:41.904Z","repository":{"id":62590966,"uuid":"197398713","full_name":"DIYer22/zcs","owner":"DIYer22","description":"Z Configuration System: a flexible powerful configuration system which takes advantage of both `argparse` and `yacs`","archived":false,"fork":false,"pushed_at":"2023-04-13T05:21:49.000Z","size":80,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-20T18:35:36.392Z","etag":null,"topics":["argparse","config","gflags","yacs","zcs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DIYer22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-17T13:49:34.000Z","updated_at":"2024-01-04T16:35:48.000Z","dependencies_parsed_at":"2023-01-22T07:45:11.547Z","dependency_job_id":null,"html_url":"https://github.com/DIYer22/zcs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DIYer22/zcs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIYer22%2Fzcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIYer22%2Fzcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIYer22%2Fzcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIYer22%2Fzcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DIYer22","download_url":"https://codeload.github.com/DIYer22/zcs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIYer22%2Fzcs/sbom","scorecard":{"id":35377,"data":{"date":"2025-08-11","repo":{"name":"github.com/DIYer22/zcs","commit":"6cf9d31e108e6d131bc11720f0d3d4e0073a717a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-14T20:10:57.101Z","repository_id":62590966,"created_at":"2025-08-14T20:10:57.101Z","updated_at":"2025-08-14T20:10:57.101Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273667077,"owners_count":25146511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argparse","config","gflags","yacs","zcs"],"created_at":"2025-09-04T20:20:38.315Z","updated_at":"2025-09-04T20:20:41.896Z","avatar_url":"https://github.com/DIYer22.png","language":"Python","readme":"# Z Configuration System\nA flexible powerful configuration system which takes advantage of both `argparse` and `yacs`\n\n## ▮ Install\n```\npip install zcs\n```\n\nEnglish version README is coming soon\n\n# zcs 中文说明\n\n**`zcs`** is short of \"\u003cstrong\u003eZ\u003c/strong\u003e  \u003cstrong\u003eC\u003c/strong\u003eonfiguration \u003cstrong\u003eS\u003c/strong\u003eystem\": 结合了 `argparse` and `yacs` 的优点而打造出的**灵活, 强大**的配置管理系统\n\n## 竞品对比\n\n| configuration system | 缺点 | 优点 |\n| :-- | -- | -- |\n| `argparse` | 不支持配置文件, 不支持层级结构, 难以有效的 dump 和复现实验参数 | `add_argument` 强大的 default, type 和 help 参数易于使用 |\n| `yacs` | 类型系统只支持仅有的几种类型, 不支持 `None`, 且类型 check 令人困惑 | 1. 灵活易用的层级配置; 2. 方便的 dump 和 load, 能有效的对实验参数进行记录与复现 |\n\n\n为此, 我将 `argparse` 和 `yacs` 整合在一起, 打造出了集两者优点于一身的 **`zcs`** :\n1. 具有和 `argparse.add_argument` 一样的定义 argument 的接口, 支持 NoneType, 自定义 Type, 易于使用\n1. 和 `yacs` 具有同样的层级配置管理能力, 及方便的 dump 和 load, 能有效的对实验参数进行记录与复现\n1. 用法完全兼容 `yacs` 和 `argparse`, 学习成本低\n\n\n\n## Example\n使用 `zcs` 科学管理 config 的一个样例, 样例的代码在 [zcs/example](./example)\n\n**文件结构:**   \n```bash\nexample/\n├── configs  # 可选配置文件\n│   ├── resnet_50.py\n│   └── senet_152.yaml\n├── defaults.py  # config 的模版\n└── main.py\n```\n1. 首先得定义一个 config 的模版: **defaults.py**   \n\n```python\nfrom zcs.config import CfgNode as CN\n#　zcs 具有和 yacs 一样的接口和用法\nfrom zcs import argument \n\ncfg = CN()\n\ncfg.LR = 1e-3\n# 完全兼容 yacs 形式的自动识别 type\n\ncfg.OUTPUT = argument(default=None, type=str, help=\"Output dir\")\n# 使 argument 来配置 default, type, help.\n# argument 用法和 parser.add_argument 一样\n\ncfg.MODEL = CN()  # 新建节点\n\ncfg.MODEL.LAYERS = argument(101, int, \"How many layers of model\")\n# 等价于 parser.add_argument(default=101, type=int, help=\"...\")\n\n# 支持 choices 等多种 parser.add_argument 的接口\ncfg.MODEL.BACKBONE = argument(\n        default='resnet', \n        choices=['resnet', 'shufflenet', 'senet'],\n        help=\"Backbone of the model\",\n        )\n```\n\n2. 接下来需要对每个实验写一个配置文件:  \n\n```yaml\n# configs/senet_152.yaml\nOUTPUT: 'outputs/senet_152'\nMODEL:\n    BACKBONE: 'senet'\n    LAYERS: 152\n```\n\n当然, 配置文件也可以是 python 文件, 这样会更加灵活和智能:   \n```python\n# configs/resnet_50.py\nfrom zcs.config import CfgNode as CN\n\ncfg = CN()\ncfg.OUTPUT = 'outputs/resnet_50'\ncfg.MODEL = CN()\ncfg.MODEL.LAYERS = 50\n```\n\n3. 在 **main.py** 内融合各层次的配置, 并生成最终的 cfg\n\n```python\nimport os\nimport argparse\nfrom defaults import cfg\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\n    '--config',\n    default=\"\",\n    metavar=\"FILE\",\n    help=\"Path to config file\",\n)\nparser.add_argument(\n    \"opts\",\n    help=\"Modify config options using the command-line\",\n    default=[],\n    nargs=argparse.REMAINDER,\n)\n\nif __name__ == \"__main__\":\n    args = parser.parse_args()\n    \n    # 复制一份 cfg\n    cfg = cfg.clone()  \n    # 融合 args.config 指定的的配置文件\n    cfg.merge_from_file(args.config)  \n    # 融合来自命令行的成对配置\n    cfg.merge_from_list(args.opts)    \n    # dump 每次实验参数, 方便复现\n    cfg.dump(os.path.join(cfg.OUTPUT, 'dump.yaml'))\n    \n    print(cfg)\n```\n\n\n4. 比如, 现在要做一个基于 senet_152 学习率调大到 0.05 的实验  \n\n```bash\n$ python main.py --config configs/senet_152.yaml LR 0.005 OUTPUT outputs/senet_152_lr0.005\n\nLR: 0.005\nMODEL:\n  BACKBONE: senet\n  LAYERS: 152\nOUTPUT: outputs/senet_152_lr0.005\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiyer22%2Fzcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiyer22%2Fzcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiyer22%2Fzcs/lists"}