https://github.com/alignmentresearch/farconf
Easy dataclass-based configuration for ML projects
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.8%) to scientific vocabulary
Repository
Easy dataclass-based configuration for ML projects
Basic Info
- Host: GitHub
- Owner: AlignmentResearch
- Language: Python
- Default Branch: main
- Size: 111 KB
Statistics
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
FARConf: specify configurations for ML workloads
Usage
Specify your configuration as a dataclass. Then, parse your CLI with the parse_cli function.
``` python import dataclasses from farconf import parse_cli
@dataclasses.dataclass class Optimizer: name: str lr: float
@dataclasses.dataclass class Algorithm: optimizer: Optimizer n_steps: int
alg: Algorithm = parsecli(["nsteps=2", '--set-json=optimizer={"name": "adam", "lr": 0.1}'], Algorithm) assert alg == Algorithm(Optimizer("adam", 0.1), 2) ```
Detailed usage
Values can be fetched from YAML and Python files, and specified in the command line. Arguments are applied from left to
right onto the same dict object, and then parsed with farconf.from_dict.
--set=path.to.key=VALUEjust sets attributespath,toandkey(for nested subclasses) to the JSON-parsed valueVALUE.- If parsing the value as JSON fails, and the value does not contain any of the characters
{}[]", then it will be passed as a string. - Equivalently you can use
path.to.key=VALUEas an argument
- If parsing the value as JSON fails, and the value does not contain any of the characters
--set-json=path.to.key="JSON_VALUE". Same as above but if JSON parsing fails, parsing the command line errors.--from-file=/path/to/file.yaml. Incorporate the values specified infile.yamlinto the main dict.--set-from-file=path.to.key=PATH_TO_YAML_FILE. Same as above, but for a sub-path.--from-py-fn=package.module:function_name. Points to a Python file which defines functionfunction_namewhich, when called with empty arguments, will return a dataclass or dict which can be merged into the main dict.- The intended way is to return typed config objects with this
--set-from-py-fn=path.to.key=package.module:function_name. Same as above but setspath.to.keyin the main dict.
Abstract classes
Sometimes you have different fields for different types of objects, e.g. optimizers. FARConf supports this by using
dataclasses which inherit from abc.ABC.
``` python import dataclasses from farconf import parsecli, fromdict import abc
@dataclasses.dataclass class LRSchedule(abc.ABC): lr: float
@dataclasses.dataclass class FlatLRSchedule(LRSchedule): pass
@dataclasses.dataclass class ExpDecayLRSchedule(LRSchedule): discount: float = 0.999
assert fromdict(dict(type="main_:FlatLRSchedule", lr=0.2), LRSchedule) == FlatLRSchedule(0.2)
assert parsecli(["type=main_:ExpDecayLRSchedule", "lr=0.2"], abc.ABC) == ExpDecayLRSchedule(0.2, discount=0.999) ```
Goals
- Support typechecked dataclass-configurations
- Support modular, inheritance-based configurations. For example, you want to specify an optimizer, but not which optimizer, and different optimizers have different attributes
- Make it easy to specify hyperparameter searches
- Ingest arguments from Python files, YAML and JSON files, YAML and JSON from the command line.
- Be easy to maintain
Non-goals
- Generate help text for configuration. Usually it'll be too long and nobody will read it.
Owner
- Name: FAR AI
- Login: AlignmentResearch
- Kind: organization
- Email: hello@far.ai
- Website: https://far.ai
- Repositories: 16
- Profile: https://github.com/AlignmentResearch
FAR AI is an alignment research non-profit working to ensure AI systems are trustworthy and beneficial to society.
GitHub Events
Total
- Delete event: 1
- Push event: 4
- Pull request event: 2
- Create event: 1
Last Year
- Delete event: 1
- Push event: 4
- Pull request event: 2
- Create event: 1
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: less than a minute
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: less than a minute
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- rhaps0dy (1)
Pull Request Authors
- rhaps0dy (8)