{"id":20425080,"url":"https://github.com/databio/yacman","last_synced_at":"2025-07-31T08:43:27.253Z","repository":{"id":37759281,"uuid":"186722526","full_name":"databio/yacman","owner":"databio","description":"YAML configuration manager","archived":false,"fork":false,"pushed_at":"2024-02-22T00:41:59.000Z","size":358,"stargazers_count":7,"open_issues_count":10,"forks_count":2,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-04-24T09:29:26.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/yacman","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/databio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-15T00:50:50.000Z","updated_at":"2024-06-19T17:40:47.754Z","dependencies_parsed_at":"2023-02-19T11:31:33.813Z","dependency_job_id":"7cbfdb75-de82-491f-95e4-09f00c5196ee","html_url":"https://github.com/databio/yacman","commit_stats":{"total_commits":264,"total_committers":5,"mean_commits":52.8,"dds":"0.36742424242424243","last_synced_commit":"cf7c5d6b664d39507f361f6736f09ed1c019d68c"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databio%2Fyacman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databio%2Fyacman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databio%2Fyacman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databio%2Fyacman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/databio","download_url":"https://codeload.github.com/databio/yacman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618273,"owners_count":21134200,"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":[],"created_at":"2024-11-15T07:12:13.780Z","updated_at":"2025-04-12T18:55:31.403Z","avatar_url":"https://github.com/databio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/databio/yacman/master/docs/img/yacman_logo.svg?sanitize=true\" alt=\"yacman\" height=\"70\"/\u003e\u003cbr\u003e\n![Run pytests](https://github.com/databio/yacman/workflows/Run%20pytests/badge.svg)\n![Test locking parallel](https://github.com/databio/yacman/workflows/Test%20locking%20parallel/badge.svg)\n[![codecov](https://codecov.io/gh/databio/yacman/branch/master/graph/badge.svg)](https://codecov.io/gh/databio/yacman)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/yacman/badges/version.svg)](https://anaconda.org/conda-forge/yacman)\n\nYacman is a YAML configuration manager. It provides some convenience tools for dealing with YAML configuration files.\n\nPlease see [this](docs/usage.md) Python notebook for features and usage instructions and [this](docs/api_docs.md) document for API documentation.\n\n## Upgrading guide\n\nHow to upgrade to yacman v1.0.0.\nYacman v1 provides 2 feature upgrades:\n\n1. Constructors take the form of `yacman.YAMLConfigManager.from_x(...)` functions, to make it clearer how to \ncreate a new `ym` object.\n2. It separates locks into read locks and write locks, to allow mutliple simultaneous readers.\n\nThe `v0.9.3` transition release has 3 versions of the basic yacman object, namely: \n- attmap-based version (YacAttMap)\n- non-attmap-but-mostly-compatible (YAMLConfigManager)\n- new future object (FutureYAMLConfigManager...), which is explicitly not backwards compatible with the attmap version.\n\nIn v1.0.0, FutureYAMLConfigManager will be renamed to YAMLConfigManager and the old stuff will be removed.\nHere's how to transition your code:\n\n### Use the FutureYAMLConfigManager in 0.9.3\n\n1. Import the FutureYAMLConfigManager\n\nChange from:\n\n```python\nfrom yacman import YAMLConfigManager\n```\n\nto \n\n```python\nfrom yacman import FutureYAMLConfigManager as YAMLConfigManager\n```\n\nOnce we switch from `v0.9.3` to `v1.X.X`, you will need to switch back.\n\n2. Update any context managers to use `write_lock` or `read_lock`\n\n```python\nfrom yacman import write_lock, read_lock\n```\n\nChange\n\n```python\nwith ym as locked_ym:\n    locked_ym.write()\n```\t\n\nto\n\n\n```python\nwith write_lock(ym) as locked_ym:\n    locked_ym.rebase()\n    locked_ym.write()\n```\n\nIn the new system, you must use `rebase()` before `write()` if you want to allow for multiple processes to possibly have written the file since you read it in.\n\n\n\nMore examples:\n\n```python\n\nfrom yacman import FutureYAMLConfigManager as YAMLConfigManager\nfrom yacman import read_lock, write_lock\n\ndata = {\"my_list\": [1,2,3], \"my_int\": 8, \"my_str\": \"hello world!\", \"my_dict\": {\"nested_val\": 15}}\n\nym = YAMLConfigManager(data)\n\nym[\"my_list\"]\nym[\"my_int\"]\nym[\"my_dict\"]\n\n# Use in a context manager to write to the file\n\nym[\"new_var\"] = 15\n\n# Use a write-lock, and rebase before writing to ensure you capture any changes since you loaded the file\nwith write(ym) as locked_ym:\n    locked_ym.rebase()\n    locked_ym.write()\n\n\n# use a read lock to rebase -- this will replay any in-memory updates on top of whatever is re-read from the file\nwith read_lock(ym) as locked_ym:\n    locked_ym.rebase()\n\n# use a read lock to reset the in-memory object to whatever is on disk\nwith read_lock(ym) as locked_ym:\n    locked_ym.reset()\n\n```\n\n\n\n\n3. Update any constructors to use the `from_{x}` functions\n\nYou can no longer just create a `YAMLConfigManager` object directly; now you need to use the constructor helpers.\n\nExamples:\n\n```python\nfrom yacman import FutureYAMLConfigManager as YAMLConfigManager\n\ndata = {\"my_list\": [1,2,3], \"my_int\": 8, \"my_str\": \"hello world!\", \"my_dict\": {\"nested_val\": 15}}\nfile_path = \"tests/data/full.yaml\"\nyaml_data = \"myvar: myval\"\n\nyacman.YAMLConfigManager.from_yaml_file(file_path)\nyacman.YAMLConfigManager.from_yaml_data(yaml_data)\nyacman.YAMLConfigManager.from_obj(data)\n\n```\n\nIn the past, you could load from a file and overwrite some attributes with a dict of variables, all from the constructor.\nNow it would is more explicit:\n\n```python\nym = yacman.YacMan.from_yaml_file(file_path)\nym.update_from_obj(data)\n```\n\nTo exppand environment variables in values, use `.exp`.\n\n```python\nym.exp[\"text_expand_home_dir\"]\n```\n\n## From v0.9.3 (using future) to v1.X.X:\n\nSwitch back to: \n\n```\nfrom yacman import YAMLConfigManager\n```\n\n\n\n\n\n## Demos\n\nSome interactive demos\n\n```python\nfrom yacman import FutureYAMLConfigManager as YAMLConfigManager\nym = yacman.YAMLConfigManager(entries=[\"a\", \"b\", \"c\"])\nym.to_dict()\nym\n\nprint(ym.to_yaml())\n\nym = YAMLConfigManager(entries={\"top\": {\"bottom\": [\"a\", \"b\"], \"bottom2\": \"a\"}, \"b\": \"c\"})\nym\nprint(ym.to_yaml())\n\nym = YAMLConfigManager(filepath=\"tests/data/conf_schema.yaml\")\nprint(ym.to_yaml())\nym\n\nym = YAMLConfigManager(filepath=\"tests/data/empty.yaml\")\nprint(ym.to_yaml())\n\nym = YAMLConfigManager(filepath=\"tests/data/list.yaml\")\nprint(ym.to_yaml())\n\nym = YAMLConfigManager(YAMLConfigManager(filepath=\"tests/data/full.yaml\").exp)\nprint(ym.to_yaml())\n\nym = YAMLConfigManager(filepath=\"tests/data/full.yaml\")\nprint(ym.to_yaml(expand=True))\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabio%2Fyacman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatabio%2Fyacman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabio%2Fyacman/lists"}