{"id":13757215,"url":"https://github.com/rbgirshick/yacs","last_synced_at":"2025-05-14T16:02:00.512Z","repository":{"id":38975321,"uuid":"145613569","full_name":"rbgirshick/yacs","owner":"rbgirshick","description":"YACS -- Yet Another Configuration System","archived":false,"fork":false,"pushed_at":"2022-04-13T12:22:36.000Z","size":60,"stargazers_count":1303,"open_issues_count":30,"forks_count":91,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-12T01:53:05.526Z","etag":null,"topics":["configuration-management","experimental-design","python","research"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbgirshick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-21T20:03:58.000Z","updated_at":"2025-04-10T04:24:07.000Z","dependencies_parsed_at":"2022-07-14T03:30:41.721Z","dependency_job_id":null,"html_url":"https://github.com/rbgirshick/yacs","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbgirshick%2Fyacs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbgirshick%2Fyacs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbgirshick%2Fyacs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbgirshick%2Fyacs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbgirshick","download_url":"https://codeload.github.com/rbgirshick/yacs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505873,"owners_count":21115354,"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","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":["configuration-management","experimental-design","python","research"],"created_at":"2024-08-03T12:00:29.601Z","updated_at":"2025-04-12T01:53:10.236Z","avatar_url":"https://github.com/rbgirshick.png","language":"Python","funding_links":[],"categories":["2.For Experiment"],"sub_categories":["Configures Management"],"readme":"## YACS\n\n### Introduction\n\nYACS was created as a lightweight library to define and manage\nsystem configurations, such as those commonly found in software\ndesigned for scientific experimentation. These \"configurations\"\ntypically cover concepts like hyperparameters used in training a\nmachine learning model or configurable model hyperparameters, such\nas the depth of a convolutional neural network. Since you're doing\nscience, **reproducibility is paramount** and thus you need a reliable\nway to serialize experimental configurations. YACS\nuses YAML as a simple, human readable serialization format.\nThe paradigm is: `your code + a YACS config for experiment E (+\nexternal dependencies + hardware + other nuisance terms ...) =\nreproducible experiment E`. While you might not be able to control\neverything, at least you can control your code and your experimental\nconfiguration. YACS is here to help you with that.\n\nYACS grew out of the experimental configuration systems used in:\n[py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn) and\n[Detectron](https://github.com/facebookresearch/Detectron).\n\n### Usage\n\nYACS can be used in a variety of flexible ways. There are two main\nparadigms:\n\n- Configuration as *local variable*\n- Configuration as a *global singleton*\n\nIt's up to you which you prefer to use, though the local variable\nroute is recommended.\n\nTo use YACS in your project, you first create a project config\nfile, typically called `config.py` or `defaults.py`. *This file\nis the one-stop reference point for all configurable options.\nIt should be very well documented and provide sensible defaults\nfor all options.*\n\n```python\n# my_project/config.py\nfrom yacs.config import CfgNode as CN\n\n\n_C = CN()\n\n_C.SYSTEM = CN()\n# Number of GPUS to use in the experiment\n_C.SYSTEM.NUM_GPUS = 8\n# Number of workers for doing things\n_C.SYSTEM.NUM_WORKERS = 4\n\n_C.TRAIN = CN()\n# A very important hyperparameter\n_C.TRAIN.HYPERPARAMETER_1 = 0.1\n# The all important scales for the stuff\n_C.TRAIN.SCALES = (2, 4, 8, 16)\n\n\ndef get_cfg_defaults():\n  \"\"\"Get a yacs CfgNode object with default values for my_project.\"\"\"\n  # Return a clone so that the defaults will not be altered\n  # This is for the \"local variable\" use pattern\n  return _C.clone()\n\n# Alternatively, provide a way to import the defaults as\n# a global singleton:\n# cfg = _C  # users can `from config import cfg`\n```\n\nNext, you'll create YAML configuration files; typically you'll make\none for each experiment. Each configuration file only overrides the\noptions that are changing in that experiment.\n\n```yaml\n# my_project/experiment.yaml\nSYSTEM:\n  NUM_GPUS: 2\nTRAIN:\n  SCALES: (1, 2)\n```\n\nFinally, you'll have your actual project code that uses the config\nsystem. After any initial setup it's a good idea to freeze it to\nprevent further modification by calling the `freeze()` method. As\nillustrated below, the config options can either be used a global\nset of options by importing `cfg` and accessing it directly, or\nthe `cfg` can be copied and passed as an argument.\n\n```python\n# my_project/main.py\n\nimport my_project\nfrom config import get_cfg_defaults  # local variable usage pattern, or:\n# from config import cfg  # global singleton usage pattern\n\n\nif __name__ == \"__main__\":\n  cfg = get_cfg_defaults()\n  cfg.merge_from_file(\"experiment.yaml\")\n  cfg.freeze()\n  print(cfg)\n\n  # Example of using the cfg as global access to options\n  if cfg.SYSTEM.NUM_GPUS \u003e 0:\n    my_project.setup_multi_gpu_support()\n\n  model = my_project.create_model(cfg)\n```\n\n#### Command line overrides\n\nYou can update a `CfgNode` using a list of fully-qualified key, value pairs.\nThis makes it easy to consume override options from the command line. For example:\n\n```python\ncfg.merge_from_file(\"experiment.yaml\")\n# Now override from a list (opts could come from the command line)\nopts = [\"SYSTEM.NUM_GPUS\", 8, \"TRAIN.SCALES\", \"(1, 2, 3, 4)\"]\ncfg.merge_from_list(opts)\n```\n\nThe following principle is recommended: \"There is only one way to\nconfigure the same thing.\" This principle means that if an option\nis defined in a YACS config object, then your program should set\nthat configuration option using `cfg.merge_from_list(opts)` and\nnot by defining, for example, `--train-scales` as a command line\nargument that is then used to set `cfg.TRAIN.SCALES`.\n\n#### Python config files (instead of YAML)\n\n`yacs\u003e= 0.1.4` supports loading `CfgNode` objects from Python source files. The\nconvention is that the Python source must export a module variable named `cfg` of\ntype `dict` or `CfgNode`. See examples using a [CfgNode](example/config_override.py)\nand a [dict](example/config_override_from_dict.py) as well as usage in the unit tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbgirshick%2Fyacs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbgirshick%2Fyacs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbgirshick%2Fyacs/lists"}